2019-12-05 03:00 AM
Hi I am trying to assign values to an array to send for an spi transaction, I declared the variable and assigned each index of the array in a loop, but when I am debugging it the array is constantly 0 for each of its elements unless I defined it as a const, does anyone know why that is the case?
Thanks!
2019-12-05 03:09 AM
It would probably be very helpful to post some relvant parts of your code.
2019-12-05 03:41 AM
I literally just have uint8_t aTxBuffer[1024] = {0}; and then a loop: for (i = 0; i < 1024; i++){
aTxBuffer[i] = 10;
}
I do also HAL_Init(); and CPU_CACHE_Enable(); I tried invalidate the buffer using SCB_InvalidateDCache_by_Addr ((uint32_t *)aTxBuffer, BUFFERSIZE); but that didn't work either
2019-12-05 04:05 AM
Also it seems that if I assign values before I call CPU_CACHE_Enable it gets assigned, so I think it is problem with the CPU_CACHE_Enable, but I have no idea how to solve this since I used SCB_InvalidateDCache_by_Addr and it didn't work
2019-12-05 04:35 AM
Example code for the F7 used to call CPU_CACHE_Enable() as well as very first thing in main, which translates to calls of SCB_EnableICache() and SCB_EnableDCache().
I have no experinece with the H7 devices.
2019-12-05 04:38 AM
So for F7 how if you want to assign values to an array after you called CPU_CACHE_Enable what would you do?
2019-12-05 06:33 AM
Not much different from what you described.
Where do you declare the buffer, and how (auto, static, volatile, ...) ?
Have you tried a debugger to see what happens ?
Perhaps on instruction (assembly) level ?
What does the map file say about your array ?
I hardly use newer STM32 variants which have only Cube/HAL support.
2019-12-05 06:53 AM
When you write to memory from the MCU side, you need to flush (a.k.a. clean) the cache, not invalidate.
Invalidation discards updates from the MCU side.
2019-12-05 07:51 AM
SCB_InvalidateDCache_by_Addr() doesn't like do what you think it does, most likely you'll crash the system using this.
What tools are you using?
Is this a custom board?
Is there a project someone could actually rebuild/replicate the scenario?