Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular Buffer HAL - Not working with Keil and compiler optimization > O0 #4

Open
glitch911 opened this issue Jan 21, 2022 · 0 comments

Comments

@glitch911
Copy link

Hello and thank you for great work and tutorial !

Your code is working well with CubeIDE, even with release optimisation (Os) and with Keil without compiler optimization (O0) but as soon as I try other optimization (O1,... Os) on Keil µVision, it doesn't work.
I managed to get it work using "volatile" keyword before variables declaration in uartRingBufDMA.c but I'm not sure what's going on ^^.

Regarding TIMEOUT variable wouldn't it be better managed this way:
in uartRingBufDMA.h:
extern volatile int32_t TIMEOUT;
in uartRingBufDMA.c:
volatile int32_t TIMEOUT = 0;
in stm32xxxx_it.c:
#include uartRingBufDMA.h:
/* USER CODE BEGIN SysTick_IRQn 1 /
TIMEOUT--;
/
USER CODE END SysTick_IRQn 1 */

volatile int isOK = 0; seems nice, otherwise it will be optimize and it will kill usage of isConfirmed() same for isDataAvailable

Regarding others variable I'm not quite sure, seems it's working with only Head and Tail set as volatile ...

Another unrelated question : can you explain what's the purpose of HAL_Delay(100) in your uartRingBufDMA.c functions ?

Again, thank you so much for great content sharing !

Have a good day,

Thomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant