Problem with chThdSleepSeconds() STM32F407
Posted: Wed Mar 04, 2015 10:59 pm
Hello gentelmens! Really need your help. I studied CHIBIOS and now there is a problem with the function call chThdSleepMilliseconds(). Actually, it works fine, as in the main thread, and in the simple regular threads (like led blinking). But now there was a need revival thread on the external interrupt. I used the example that comes with the OS in the test folder and examples of site. There is my code
After reset "Green led" is blinking. After external interrupting green flashing stops and the orange LED lights up , but does not blink. From this I concluded that the system is hung on the process chThdSleepSeconds(1) from the tread. Rly dont know what to do. Please help. Thank you!
Code: Select all
static void extcb1(EXTDriver *extp, expchannel_t channel) {
(void)extp;
(void)channel;
chSysLockFromIsr();
palSetPad(GPIOD, GPIOD_LED5); // red led
chSchReadyI(tp);
tp=NULL;
chSysUnlockFromIsr();
}
static const EXTConfig extcfg = {
{
{EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, extcb1},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL}
}
};
static WORKING_AREA(waThread1, 256);
static msg_t Thread1(void *arg) {
(void)arg;
chRegSetThreadName("blinker");
tp=chThdSelf();
chSysLock();
chSchGoSleepS(THD_STATE_SUSPENDED);
chSysUnlock();
while (TRUE) {
palSetPad(GPIOD, GPIOD_LED3); /* Orange. */
chThdSleepSeconds(1);
palClearPad(GPIOD, GPIOD_LED3); /* Orange. */
chThdSleepSeconds(1);
}
}
/*
* Application entry point.
*/
int main(void) {
uint8_t i;
halInit();
chSysInit();
palSetPadMode(GPIOD, GPIOD_LED4, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOD, GPIOD_LED3, PAL_MODE_OUTPUT_PUSHPULL);
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
extStart(&EXTD1, &extcfg);
while (TRUE)
{
palSetPad(GPIOD, GPIOD_LED4); /* Green. */
chThdSleepSeconds(1);
palClearPad(GPIOD, GPIOD_LED4); /* Green. */
chThdSleepSeconds(1);
}
}
After reset "Green led" is blinking. After external interrupting green flashing stops and the orange LED lights up , but does not blink. From this I concluded that the system is hung on the process chThdSleepSeconds(1) from the tread. Rly dont know what to do. Please help. Thank you!