2019-01-21 12:59 AM
Hey guys,
I have expereinced a very strange behaviour of my STM32F429ZIT6 custom board:
When I execute the following code the processor behaves differently in free running then in manual stepped mode or my oscilloscope seems to be completely broken - which I doubt.
_5_PLUS_COIL_HIGH;
delay_TIM10(50);
STANDARD_COIL_LOW;
_5_MINUS_COIL_LOW;
the macros behinde _5_PLUS_COIL_HIGH , STANDARD_COIL_LOW and _5_MINUS_COIL_LOW are simply GPIO output state settings:
#define STANDARD_COIL_HIGH STANDARD_COIL_GPIO_Port->BSRR = STANDARD_COIL_Pin
#define STANDARD_COIL_LOW STANDARD_COIL_GPIO_Port->BSRR = (STANDARD_COIL_Pin << 16U)
#define _5_PLUS_COIL_HIGH _5_PLUS_COIL_GPIO_Port->BSRR = _5_PLUS_COIL_Pin
#define _5_PLUS_COIL_LOW _5_PLUS_COIL_GPIO_Port->BSRR = (_5_PLUS_COIL_Pin << 16U)
and the function delay_TIM10(50) is a msec delay function:
#pragma GCC push_options
#pragma GCC optimize ("O3")
void delay_TIM7(uint32_t ucnt) // IMPORTANT!! always check with clock speed for correct delays in STM32CubeMX
{
uint32_t start = TIM7->CNT;
while(tim7_tick() - start < ucnt);
}
void delay_TIM10(uint32_t mcnt) // IMPORTANT!! always check with clock speed for correct delays in STM32CubeMX
{
uint32_t start = TIM10->CNT;
while(tim10_tick() - start < mcnt);
}
#pragma GCC pop_options
#define tim7_tick() (TIM7->CNT)
#define tim10_tick() (TIM10->CNT)
I halt the program per breakpoint at _5_PLUS_COIL_HIGH and trigger my oscilloscope on that pin to check for a rising edge, as the pin is LOW prior. Normally I would just hit run and the socilloscope would get triggered. But for a reason I don't know, the oscilloscope gets not triggered. When I maually step from the breakpoint the oscilloscope gets triggered.
Has anybody a clue why this is the case?
My processor runs only at 68MHz.
best regards
Benjamin
Solved! Go to Solution.
2019-01-22 06:33 AM
Puh....ok. I made a complete new project where I only toggle GPIOs inside main while(). Guess what, this statement is simply not executed in debugging run mode:
while (1)
{
HAL_GPIO_WritePin(_5_PLUS_COIL_GPIO_Port,_5_PLUS_COIL_Pin, GPIO_PIN_SET);
HAL_Delay(100);
HAL_GPIO_WritePin(_5_PLUS_COIL_GPIO_Port,_5_PLUS_COIL_Pin, GPIO_PIN_RESET);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
if I put the delay up to 300 or make manual stepping it is executed...I checked this with analog probes...WTF?!?!
2019-01-22 07:13 AM
I finally found the problem:
I used open-drain outputs. Now I switched them to push-pull and everything works fine (the delays and the GPIO switching). I must admit that I not really understand why this was the reason.. I am having a logic buffer connected to these GPIOs, but as far as I thought the buffer just needs a clear HIGH or LOW state as it is a high impedance input. I will look deeper int this.
Anyhow thanks for all the help and effort from different people!
P.S. Off course this could not work, as a logic "1" on an open-drain output is a high impedance state, so floating.