AnsweredAssumed Answered

32F429IDISCOVERY interference between LEDs [solved]

Question asked by Simon Wright on Nov 24, 2014
Latest reply on Nov 25, 2014 by Clive One
Using STM32Cube_FW_F4_V1.3.0 and a GCC 4.7.4 toolchain I built on Mac OS X, the attached demo (based on Projects/STM32F429I-Discovery/Examples/BSP) toggles one of the LEDs every 250 ms and the other every 500 ms.

SystemClock_Config() is the same as in the original except for checking the status returns of the HAL calls.

I’ve set up a tick callback,

volatile unsigned ticks = 0;
 
void HAL_SYSTICK_Callback(void)
{
  ticks++;
}

and this is checked in the main loop,

while (1) {
  const unsigned ticks_now = ticks;
  if ((ticks_now % 250) == 0) {
    BSP_LED_Toggle(LED4);
  }
  if ((ticks_now % 500) == 0) {
    BSP_LED_Toggle(LED3);
  }
}

and what happens is that the short-period LED (LED4 here) flickers when the other LED is off and (appears to be) on all the time that the other LED is on.

I can make the LEDs work the way I expected by inserting HAL_Delay(1) immediately after the first BSP_LED_Toggle(),

if ((ticks_now % 250) == 0) {
  BSP_LED_Toggle(LED4);
  HAL_Delay(1);
}
if ((ticks_now % 500) == 0) {
  BSP_LED_Toggle(LED3);
}

The demonstration also works as expected if I remove the SystemClock_Config()call but that doesn’t seem like a good way ahead!


Attachments

Outcomes