Page 1 of 1

Reading register twice (in the next clock cycle)

Posted: Tue Aug 01, 2017 8:56 am
by xrCyhxcPN
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

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

Posted: Tue Aug 01, 2017 10:21 am
by ESP_igrr
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.