AnsweredAssumed Answered

Mutex and Cortex synchronization primitives

Question asked by Martin Rentschler on Mar 31, 2015
Latest reply on Apr 2, 2015 by Mark Butcher

Hi,

 

I'm currently doing a baremetal c project on a MK10 and MK20 (both with Cortex M4 cores) with the help of the Processor Expert LDDs.

 

I want to have the FTM0 free-running with certain channels in capture and others in compare mode. Now, when an edge is detected (captured) the correspondig ISR will be called, which in return writes the current value to a buffer. This buffer is then periodically (not deterministic as of right now) read and processed by a frequency calculation function. To protect against a read-while-write operation I'm thinking about using a mutex variable. I've read in the Cortex-M4 User Guide that such synchronization primitives exist, but I haven't found a demo or a ready to use c function for kinetis. Are either available? Or will I have to get my own assembler instructions running?

 

Any other solutions for the problem described here? A ringbuffer/fifo? Blocking/disabling the interrupts isn't a good option, because I don't want to miss out on one of those. Doing the processing in the isr isn't the solution I'm looking for either.

Does the DMA make use of such primitives?

 

As a note: It isn't bad if capture values for the correspondig FTM channel are lost to the mutex every now and then. To protect from that I could just double the buffer (from 2 values to 4) and have either one accessed with a dirty/fresh flag.

Attachments

Outcomes