Etpu - Semaphores between Host and Etpu - MPC5746R

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Etpu - Semaphores between Host and Etpu - MPC5746R

493 Views
demian91
Contributor III

Hi im using the IDE CW eTPU 10.3 and S32DS 2.1 for the MPC5746R microcontroller.

Is it possible to use semaphores between the Host and the eTPU?. For the other hand, i understand that we have 4 semaphores in the eTPU between the two Engines A and B, only one sempahore can be active, but i not sure how is the syntax.

while(CC.SMLCK);
channel.SMPR = SMPR_LOCK_0;

//Code

channel.SMPR = SMPR_FREE;

Is that correct?

 

0 Kudos
1 Reply

475 Views
johndiener
Contributor IV

The eTPU hardware semaphores are only for synchronization/resource protection between eTPU engines A and B. Host/eTPU coherency is supported for 2 parameters via the Coherent Dual-parameter Controller (host-side) or automatically via consecutive memory accesses (eTPU side). For more than 2 parameters techniques involving flagging or double-buffering and host service requests are typically employed.

As you state, only one semaphore can be locked by an eTPU engine at any one time. Thus if say engine B has semaphore 2 locked, and eTPU code running on this engine (B) executes "channel.SMPR = SMPR_LOCK_1", semaphore 2 is released, regardless of whether the take of semaphore 1 succeeded (engine A does NOT have semaphore 1 locked) or fails (engine A has semaphore 1 locked).

When locking a semaphore, code should be of the form:

  do { channel.SMPR = SMPR_LOCK_0; } while (CC.SMLCK);

As you note, to free the one locked semaphore (whichever it is), the code would be:

  channel.SMPR = SMPR_FREE;

John Diener