PRU Timing in C

I’ve encountered a big issue trying to provide accurate timing of pulses sent from pru0. I’m toggling one pin and trying to set another pin low for just a single low cycle of the first pin. This worked fine in assembler language but in C the timing of the second pin based on the first pin being low is not consistent. It gets delayed somehow and so sometimes goes low when the first pin is high but at other times when the first pin is low. Is this possibly an overhead problem with the C compiler and thus cannot be trusted for accurate timing? If so, is there a way to leave this section in assembler but still easily receive analog data from the Beaglebone and communicate with the ARM?

Thanks,

Mike Pitman

I’ve encountered a big issue trying to provide accurate timing of pulses sent from pru0. I’m toggling one pin and trying to set another pin low for just a single low cycle of the first pin. This worked fine in assembler language but in C the timing of the second pin based on the first pin being low is not consistent. It gets delayed somehow and so sometimes goes low when the first pin is high but at other times when the first pin is low. Is this possibly an overhead problem with the C compiler and thus cannot be trusted for accurate timing?

The way to see what is going on is to leave the assembly around.

For the TI compiler, see http://www.ti.com/lit/ug/spruhv7a/spruhv7a.pdf

Look for the c_src_interlist option.

If so, is there a way to leave this section in assembler but still easily receive analog data from the Beaglebone and communicate with the ARM?

Yes, you can use either inline assembly or follow C calling conventions in your assembly source and call the assembly function from C.

6.6 Interfacing C and C++ With Assembly Language

http://www.ti.com/lit/ug/spruhv7a/spruhv7a.pdf