This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TM4C1294NCPDT: Critical section or similar?

Part Number: TM4C1294NCPDT

Tool/software: TI C/C++ Compiler

In my application I receive setup data via UDP. Data that is to be sent on to external devices via GPIO based on hardware handshake interrupt.

Setup data is in general organized in a fixed pattern, that is repeated over and over. Usually smaller changes in maybe two words in the beginning of the pattern, can happen from time to time.

How do I ensure, that those changes are allowed to go into the pattern, before the transmitter send it out?

Under Windows I am used to Critical Sections, Mutex etc, where processing is put on stand-by, until released. But on a microcontroller with, at the time, no x-tra threads?

I can see one solution in, that the receiver simply tells the output sequencer to do the changes.

Are there other options?

  • First, don't discount being able to run a multi-threaded operating system complete with mutex on a microcontroller. You may want to look at the features of TI-RTOS.

    However, that is not necessary for what I think you are trying to do. If I understand correctly, you get data by ethernet and send it out based on a GPIO interrupt. The question is how to preserve the data congruence since both of these events are interrupt driven. The critical section is when you copy new data from the input buffer to the output buffer. I suggest you recreate the function of a Mutex by setting a variable,  a critical output flag (volatile bool), to true when you enter the interrupt routine to output the data.  Then clear that flag once the critical data has been transmitted.

    In the main routine you would loop waiting for a flag saying you have new data via UDP. Then, disable interrupts and check the critical output flag. If that flag is true, just re-enable the interrupts. If the flag is false, copy the new data into the output buffer and then re-enable the interrupts.