Page 1 of 1

how to reset the ccount register?

Posted: Mon Jun 26, 2017 3:36 pm
by deathaephx
Sorry it might be a dumb question but I couldn't find any assembler references for the esp8266.

So my question is how do I reset the ccount register in asm("")?

Re: how to reset the ccount register?

Posted: Mon Jun 26, 2017 5:24 pm
by kolban
Its possible you can't. I would also be nervous about re-setting its value even if we could. The ccount is a high speed register that I take to mean that it constantly increments. It is also a "global" (being a CPU register). There may be logic that has recorded the current value and is using that as timing to determine an elapsed duration which would be ccountNow - ccountRecorded. If you were to change the value of ccount, then that would break logic elsewhere.

Is there a specific reason that you want to reset it to zero? Can your logic not record its current value and perform arithmetic to determine elapsed time on a future read?

Re: how to reset the ccount register?

Posted: Mon Jun 26, 2017 6:04 pm
by f.h-f.s.
Have you read https://esp32.com/viewtopic.php?t=293?
According to the xtensa ISA there is a wsr instruction, that would write to a special register.
You could try it out. What are you planning to use this for? If you plan to generate a signal RMT would be the way to go.
I do agree with Kolban, I don't think it is a register you are supposed to write to.

Re: how to reset the ccount register?

Posted: Tue Jun 27, 2017 2:31 am
by ESP_Sprite
To add to what's said above: If you do manage to write there, be aware that it probably breaks FreeRTOS: we use the ccompare functionality (which depends on ccount monotonically increasing) for scheduler timing, so resetting ccount will most likely break pre-emptive scheduling.