Reading register twice (in the next clock cycle)

xrCyhxcPN
Posts: 6
Joined: Sun Jul 23, 2017 8:43 am

Reading register twice (in the next clock cycle)

Postby xrCyhxcPN » Tue Aug 01, 2017 8:56 am

Hi,

I have the following code and I would like to read the register twice without spending a single clock for flushing buffers etc.
If I use the

Code: Select all

REG_READ
define, it results into 5 opcodes but I would like to know the register content within the next clock cycle. Is there any chance to do so?

Code: Select all

 50       	volatile uint32_t val0 = REG_READ(WDEV_RND_REG);
4008294f:   l32r    a8, 0x400806b4
40082952:   memw    
40082955:   l32i.n  a9, a8, 0
40082957:   memw    
4008295a:   s32i.n  a9, a1, 0
thanks and best regards
Patrick

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Reading register twice (in the next clock cycle)

Postby ESP_igrr » Tue Aug 01, 2017 10:21 am

Not in C, i think. You can use inline assembly to do that, though (just put two l32i instructions one after another).

Keep in mind that the each of these loads may not happen in one CPU cycle, if the CPU is clocked higher than 80MHz. Random number generator registers are on the APB bus, which is clocked at 80MHz, while the CPU may be clocked at 160MHz or 240MHz. So the read of a register may have to wait until the next APB cycle.

Who is online

Users browsing this forum: No registered users and 124 guests