Hi team
I am playing with the prefetch buffer on my stm32 today, I have found no performance difference with it enable or disable? (In both tests my code finished at 190ms) I thought it can speed up instruction execution speed as it prefetch instruction. Did I use it wrong, or did I understand it wrong?
This is the register I am talking about:
Here is how I test it:
I am playing with the prefetch buffer on my stm32 today, I have found no performance difference with it enable or disable? (In both tests my code finished at 190ms) I thought it can speed up instruction execution speed as it prefetch instruction. Did I use it wrong, or did I understand it wrong?
This is the register I am talking about:
C++:
/* enable prefetch buffer */
FLASH->ACR |= FLASH_ACR_PRFTBE
/* disable prefetch buffer */
FLASH->ACR &= (~FLASH_ACR_PRFTBE)
C:
volatile uint32_t counter = 0;
volatile uint32_t ticks_start = 0;
volatile uint32_t ticks_diff = 0;
uint8_t test_data1[] = {0x9A, 0xEB, 0x05, 0x8A, 0x02, 0x8A, /* header */
0x81, 0x5A, 0x80, 0x00, /* payload */
0x33, 0x30, 0x20, 0x4E,
0x6F, 0x76, 0x20, 0x30,
0x30, 0x3A, 0x30, 0x30,
0xFF, 0x00, 0xFF, 0xFF,
0x1A, 0xED}; /* packet CRC */
/* calculate CCITT CRC16 */
uint16_t calculateCRC16(uint8_t *data_ptr, int size);
void mainr(){
for(;;){
/* get ticks at start */
ticks_start = HAL_GetTick();
/* do it 1000 times */
uint32_t dummyVal = 0;
for(uint32_t i = 0; i < 1000; i++){
dummyVal = dummyVal + calculateCRC16(test_data1, sizeof(test_data1));
}
/* Calculate ticks difference
* prefetch buffer enable, finished at 190ms
* prefetch buffer disable, finished at 190ms
*/
ticks_diff = HAL_GetTick() - ticks_start;
/* number of iteration */
counter++;
}
}
Last edited: