amsffrtos wrote on Saturday, May 30, 2015:
Thanks for confirming those points. It’s nice to know that my mental model of how the OS should work matches with how it does work, but at the same time I’ve obviously still made a terrible mistake somewhere or it wouldn’t be crashing
I take care of variables like AFEFrameWR by issuing them with the ‘volatile’ qualifier, which in the compiler I use indicates that it is modified by interrupts so every time it is referenced it is first loaded from memory. That said, this particular variable is only used inside the ISR to keep track of where the next write should occur.
What’s going on in the part of the code that seems to have trouble is that I have data streaming in over UART3 which goes via a DMA channel to fill a buffer.
When the block transfer is complete (when the buffer is full) the DMA interrupt fires to direct the DMA to the next buffer, and emits a semaphore that unblocks a task.
//Wait for the next frame of AFE data
//Ship out the previous frame for processing/logging.
xQueueSendToBack(LFQueue, ( void * ) &Messtart, ( TickType_t ) 1 );
//Set the time stamp in the next set of AFE data
//Convert it to a CPU time and week number if applicable
//load these in to the next frame
AFEnextframetime=AFEnextframetime+(20*16*numAFEsetstocollect); //Since the cpu clocks are locked, we know exactly how many 20 MHz timer ticks until the next frame
xSemaphoreTake(xMutexTimestampCPUT,portMAX_DELAY); //Lock the PPS table before proceeding
flags=TimestampCPUT(AFEnextframetime, &TOWGPSps, &WNGPS);
This task inserts a pointer to the completed message in to a queue, puts a time stamp in to the next message buffer, and then suspends until the semaphore from the DMA channel is emitted again.
If I comment out the line where the data is added to the queue the crashes seem to go away. If an element is added to an already full queue could this cause the crash?
edit: There’s a * missing in the above post - I am using angle brackets and the word code to insert a code block. The tags seem to be recognized, but is there a different way to put in code snippits? I can’t find it in the formatting guidelines, just highlighting instructions.