Using Semaphore - to create sequential code


I am trying to figure the best way to create a “sequential” solution which sends and receives messages on UART:

// Simple view of Upload Code – which uploads code to the uC connected to UART

   for(i=0; i < Sectors; i++){
      for(j=0; j < BlocksPerSector; j++) {
           for(k=0; k <LinesPerBlock> 0){

bool handlerDataReceive(u16 DataSize, u8 * Data )
    // Wake up code interested in this data

I was expecting that adl_semConsume will block and give back control to the OS and when data on UART is received handlerDataReceive will be invoked which will produce a semaphore and unblock the Upload code.

However the Upload code gets blocked and handlerDataReceive is not invoked.

Any ideas on a good way to solve this issue?



I think the semaphore service can only be used for high level interruption handlers. And as far as I know, the UART handling does not fall into this category!

Why don’t you call the code interested in the data right after you have received the data?

Best Regards,


A State Machine?