I am having a problem where the microcontroller is ending up in a chSysHalt because of chThdResumeI. What i am using is a rising edge pin-interrupt to send an event to a thread to make that specific code run. This code uses a lot of SPI commands. The first thing the thread does is to access the SPI. This has worked for a long time, but now that i am trying to put the SPI slave into 'sleep' mode, the IRQ pin is getting a noisy signal straight after this is happening. I do not really understand how this can happen. Help would be much appreciated!
IRQ event thread code:
Code: Select all
THD_FUNCTION(myThread, arg) {
(void)arg;
chRegSetThreadName("DW1000 interrupt thread");
trp = chThdGetSelfX();
while (true) {
/* Waiting for the IRQ to happen.*/
//TODO: check correct event
chEvtWaitAny(1);
/* Perform processing here.*/
dw1000_irq_event(&dw);
}
}
void start_thd(void){
chThdCreateStatic(mythreadwa, sizeof(mythreadwa),
HIGHPRIO, myThread, NULL);
}
void extcb1(EXTDriver *extp, expchannel_t channel) {
(void)extp;
(void)channel;
chSysLockFromISR();
//chThdResumeI(&trp, (msg_t)0x1337); /* Resuming the thread.*/
if( trp != NULL)
{
chEvtSignalI(trp, 1);
}
chSysUnlockFromISR();
}
void start_interrupt_handler(){
// start thread to be activated by interrupt.
start_thd();
extStart(&EXTD1, &extcfg);
}
We suspect that the cause may be that the interrupt tries to wake/resume the thread when it has been suspended by the SPI. If this feasible and how should we prevent this?
Backtrace:
Code: Select all
(gdb) bt
#0 chSysHalt (reason=reason@entry=0x8008bf0 <__func__.6511> "chThdResumeI")
at ../ChibiOS/os/rt/src/chsys.c:179
#1 0x08001690 in chThdResumeI (trp=trp@entry=0x200011b0 <SPID1+8>, msg=msg@entry=0)
at ../ChibiOS/os/rt/src/chthreads.c:572
#2 0x0800530c in osalThreadResumeI (msg=0, trp=0x200011b0 <SPID1+8>)
at ../ChibiOS/os/hal/osal/rt/osal.h:728
#3 spi_lld_serve_rx_interrupt (spip=0x200011a8 <SPID1>, flags=<optimized out>)
at ../ChibiOS/os/hal/ports/STM32/LLD/SPIv1/spi_lld.c:149
#4 0x08003fe0 in Vector120 () at ../ChibiOS/os/hal/ports/STM32/LLD/DMAv2/stm32_dma.c:269
#5 0xffffffec in ?? ()
- Kristoffer