eTPU_C

eTPU_C

How do I make better use of ETPU_function parameters from inside a subordinate C function?

ETPU_function parameters don't just pertain to the code in the ETPU_function body; they are relevant to everything that happens in the thread. It would be undesirable to pass these parameters around, and very difficult to get a globally-valid reference.

This item describes a way to use a matched set of ETPU_function parameters and a special global pointer to get access to the parameters in a C function.

eTPU_C

I want to assign an ETPU_function to more than one channel. Will all channels share static variables in common?

Each channel, when it runs a shared ETPU_function, can have its own function frame based at its own CPBA setting. This allocation contains parameters and local static variables.

eTPU_C

How do I access the angle clock?

The angle clock hardware allows microcode to watch the turning of a gear, and act at angles or rotations.

The TPR register, type register_tpr is specified as a structure:

eTPU_C

How do I use eTPU semaphores?

The short answer: assign a number from 0 to 3 to channel.SMPR, and loop until channel.SMPR tests true. Perform the sensitive work to be protected by the semaphore, and assign -1 to channel.SMPR.

Alternatively, use these macros in eTPUC_common.h:

eTPU_C

Does eTPU_C support signed divide?

No. Signed divide is not supported at this time.

eTPU_C

I've performed an MDU division in my code. How can I access the remainder?

Access the MACH register directly:

Result = Value1 / Value2;  
Remainder = mach;
eTPU_C

The host and eTPU are performing read-modify-writes but the eTPU is overwriting the host's update. Is this a bug?

I'm having problems when the host and eTPU are using variables in the same PRAM word. Both are performing read-modify-write sequences on their own words, but the eTPU is overwriting the host's update. Is this a bug?

No, but it will require you to use semaphores to arbitrate access to the PRAM location.

eTPU_C

How can I recover the the contents of the Capture registers after ERT_A/B have been written over by programming a match?

Invoke:

chan = chan;

The compiler will not optimize this out, as there are side effects.

Recovering the Capture register values

When a thread starts, ERT_A/B are loaded with the values of the Capture registers. This code reloads those values after using ERT_A/B for other purposes.

eTPU_C

I need to place variables manually. How can I do this?

You can place variables in their declaration:

type identifier @ address;

Simply append an @ symbol and a valid address. Since eTPU_C can calculate constant expressions at compile time, you can use relative addresses:

eTPU_C

How do I access parameters coherently?

Add the following declarations to your program:

Syndicate content