how to reset the ccount register?

deathaephx
Posts: 1
Joined: Mon Jun 26, 2017 3:28 pm

how to reset the ccount register?

Postby deathaephx » Mon Jun 26, 2017 3:36 pm

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("")?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: how to reset the ccount register?

Postby kolban » Mon Jun 26, 2017 5:24 pm

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?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

f.h-f.s.
Posts: 215
Joined: Thu Dec 08, 2016 2:53 pm

Re: how to reset the ccount register?

Postby f.h-f.s. » Mon Jun 26, 2017 6:04 pm

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.

ESP_Sprite
Posts: 9759
Joined: Thu Nov 26, 2015 4:08 am

Re: how to reset the ccount register?

Postby ESP_Sprite » Tue Jun 27, 2017 2:31 am

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.

Who is online

Users browsing this forum: Baidu [Spider] and 85 guests