Program crash after few running minutes Topic is solved

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
User avatar
tfAteba
Posts: 551
Joined: Fri Oct 16, 2015 11:03 pm
Has thanked: 91 times
Been thanked: 50 times

Program crash after few running minutes

Post by tfAteba »

Hi all,

By trying to help an member "RTOSman" you can see here: http://forum.chibios.org/phpbb/viewtopic.php?f=21&t=3155

I made a few test and here is my configuration:
- ChibiOS 3.0.4
- Nucléo F401 RE board

The code juste blink the on board LED.

Code: Select all

  #include "ch.h"
  #include "hal.h"
 
  /*
   * LED blinker thread, times are in milliseconds.
   */
  static THD_WORKING_AREA(waThread1, 128);
  static THD_FUNCTION(Thread1, arg){
 
      uint32_t time = ST2MS(chVTGetSystemTime());
 
      (void)arg;
      chRegSetThreadName("blinker");
     
      while (true){
          palTogglePad(GPIOA, GPIOA_LED_GREEN);
          time += 1000;
          chThdSleepUntil(MS2ST(time));
      }
  }
 
  /*
   * Application entry point.
   */
  int main(void){
      /*
      * System initializations.
      * - HAL initialization, this also initializes the configured device drivers
      *   and performs the board-specific initializations.
      * - Kernel initialization, the main() function becomes a thread and the
      *   RTOS is active.
      */
      halInit();
      chSysInit();
 
      /*
      * Creates the blinker thread.
      */
      chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
 
      /*
      * Normal main() thread activity, in this demo it does nothing except
      * sleeping in a loop.
      */
      while (true){
          chThdSleepMilliseconds(1);
      }
  }                                                                                                               


As a result, the on board led blink but after 7 minutes of running it turn off and stop blink.
Did I made miss something?
How can I used the debugger to catch such event?

Cheers,
Theo
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Program crash after few running minutes

Post by Giovanni »

Hi,

Theodore ATEBA wrote:How can I used the debugger to catch such event?


This could help: http://chibios.org/dokuwiki/doku.php?id ... ebug_guide

Giovanni
User avatar
tfAteba
Posts: 551
Joined: Fri Oct 16, 2015 11:03 pm
Has thanked: 91 times
Been thanked: 50 times

Re: Program crash after few running minutes

Post by tfAteba »

Hi Giovanni,

Thanks, I'm going to try to locate the problem. But in géneral, what can cause such problem?

cheers,

Theo.
User avatar
tfAteba
Posts: 551
Joined: Fri Oct 16, 2015 11:03 pm
Has thanked: 91 times
Been thanked: 50 times

Re: Program crash after few running minutes

Post by tfAteba »

Sorry, all is explain in the debugger guide.

Thanks.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Program crash after few running minutes

Post by Giovanni »

Hi,

I will spare you a debug session, this time only :)

Look at your loop and compare with the example here: http://www.chibios.org/dokuwiki/doku.ph ... :kb:timing

Hint, it is not equivalent.

Giovanni
User avatar
tfAteba
Posts: 551
Joined: Fri Oct 16, 2015 11:03 pm
Has thanked: 91 times
Been thanked: 50 times

Re: Program crash after few running minutes

Post by tfAteba »

Hi Giovanni,

Thank you for you help and you hint ;) .

I did not use the MS2ST function properly. While the system tick was under the value I passed to the chThdSleepUntil function every thing was ok.
But this was not true every time so that why the program stopped when this condition was false.

Thank you,

cheers, Theo.
Post Reply