Other Parts Discussed in Thread: HALCOGEN
My RM46 Launchpad seems to take an awfully long time reading a register.
My measurements indicates that it takes 42 clock cycles to read gioREG->GCR0 and store it in a variable on the stack.
The prime suspect is the compiler/debugger, I suspect some debug feature for register data is slowing things down, but I can't find any settings in the IDE which seems to be a plausible cause
IDE: IAR EWARM FS 7.40 (With setup from HALCoGen) No optimizing.
OS: FreeRTOS
GCLK = 160 MHz.
Method of measurement: Set a pin, read a register and clear the pin again. The duration of the logic high indicates the register read time.
Test code: Two for loops with 150 iterations each (FIFO_DEPTH).
Loop one is a reference which just toggles a pin. This measures how long it takes to toggle a pin.
Loop two is the measurement.
/*************************************************************************************************************/
while (1) {
xTaskNotifyWait( 0x00, 0, &ulNotifiedValue, portMAX_DELAY );
volatile uint32_t temp = 0;
int i;
gioPORTA->DCLR = 1 << FIFO_CHA_READEN;
for (i = 0; i < FIFO_DEPTH; i++) {
gioPORTA->DSET = 1 << FIFO_CHA_CLK;
gioPORTA->DCLR = 1 << FIFO_CHA_CLK;
}
gioPORTA->DSET = 1 << FIFO_CHA_READEN;
gioPORTA->DCLR = 1 << FIFO_CHB_READEN;
for (i = 0; i < FIFO_DEPTH; i++) {
gioPORTA->DSET = 1 << FIFO_CHB_CLK;
temp = gioREG->GCR0;
gioPORTA->DCLR = 1 << FIFO_CHB_CLK;
}
gioPORTA->DSET = 1 << FIFO_CHB_READEN;
}
/*************************************************************************************************************/
The reference loop has a logic high duration of 20 nanoseconds
The measurement loop has a logic high duration of 280 nanoseconds
If this means that the register read takes 260 nanoseconds at a clock speed of 160 MHz, then it took ~42 clock cycles to complete the read and store operation.
Is this normal?
Where do I go from here? Am I right to suspect the compiler/debugger?
/*************************************************************************************************************/
Here's the assembly for loop 2 (the measurement loop)
;gioPORTA->DSET = 1 << FIFO_CHB_CLK;
0xbc9c: 0x2120 MOVS R1, #32 ; 0x20
0xbc9e: 0x4a08 LDR.N R2, [PC, #0x20] ; [0xbcc0] GIOSETA
0xbca0: 0x6011 STR R1, [R2]
;temp = gioREG->GCR0;
0xbca2: 0x4908 LDR.N R1, [PC, #0x20] ; [0xbcc4] 0xfff7bc00 (-541696)
0xbca4: 0x6809 LDR R1, [R1]
0xbca6: 0x9100 STR R1, [SP]
;gioPORTA->DCLR = 1 << FIFO_CHB_CLK;
0xbca8: 0x2120 MOVS R1, #32 ; 0x20
0xbcaa: 0x4a04 LDR.N R2, [PC, #0x10] ; [0xbcbc] 0xfff7bc44 (-541628)
0xbcac: 0x6011 STR R1, [R2]
/*************************************************************************************************************/


