2021-06-17 07:13 AM
Hello,
I want to be able to do multiple routines in my stm32 code. I went for the option to use Switch case statements. The problem is after the code has done one iteration the variable that is used in the switch statement(routine_test) changes on its own. My code is in the attachment.
Best regards
2021-06-17 07:23 AM
routine_test changed from 0 to 1?
JW
2021-06-17 08:15 AM
Variables don't change on their own, look for another explanation. You have "routine_test = 1;" within HAL_GPIO_EXTI_Callback, is that what you're talking about?
2021-06-17 08:34 AM
I wanted when I press the button to start the routine which sets routine_test to 1. and it should stay like that forever. I only change the variable from 0 to 1 in that one function. But when I execute the code it changes back to 0.
2021-06-17 08:52 AM
You can set up a hardware watchpoint on the memory address used by that variable to figure out what is changing it. Probably your DMA buffers are writing out of bounds, since the variable is directly after them.
/* USER CODE BEGIN PV */
//ADC Buffers
uint16_t adc1_val[FULLBUFFERSIZE];
uint16_t adc2_val[FULLBUFFERSIZE];
uint16_t adc3_val[FULLBUFFERSIZE];
// lock flags
uint8_t button_locked = 0;
2021-06-17 09:14 AM
Are there anywhere minimal examples showing how to handle multiple routines starting with an switch statement in main?