Tom Junkans

_lwsem_ problem with SPI slave ISR -MQX4.0, CW10.3, K20dx256

Discussion created by Tom Junkans on Apr 17, 2013
Latest reply on Apr 17, 2013 by Tom Junkans
  • Running a K20dx256 using CW10.3 / MQX4.0
  • I have a 32 bit SPI slave generating an interrupt when the RX buffer is not empty (RFDF bit in SPI2_SR)
  • Everything works fine until I _lwsem_post in the SPI ISR then _lwsem_wait in a task. When I do this I get a _Hard_Fault interrupt. No fun...
  • When I replace the ISR with a simple loop that reads the RFDF bit in SPI2_SR, the _lwsem_post & _lwsem_wait work fine. This makes me think it is interrupt related, but the interrupts work fine without the lw semaphore. ???
  • I built the 32Bit SPI slave driver with interrupts. This works great without the lwSem stuff.
  • Putting a breakpoint just before the _lwsem_wait gets rid of the problem. weird
  • Putting a _time_delay(100) just before the _lwsem_wait gets rid of the problem. ?
  • Putting a _time_delay(20) just before the _lwsem_wait does Not gets rid of the problem.

 

Has anyone seen this type of weirdness?

 

Any ideas would be great.

 

Cheers,

Tom

 

Outcomes