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.

TMS320F280034: GPIO toggling seems slow in a CLA task

Part Number: TMS320F280034
Other Parts Discussed in Thread: C2000WARE

We are using the CLA to speed up control law execution with our power electronic system and toggling a GPIO to allow us to profile the execution times on the CLA. We have a system which uses the EPWM1 to trigger an ADC measurement and the EOC for the ADC measurement then triggers the CLA task 1. This all works as expected. Initially I have just toggled an LED in the CLA task in order to check how long things take, here is the CLA task code:-

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//-----------------------------------------------------------------------------
//
// Task 1 - PWM control loop
//
// Description: PWM control logic can be implemented here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt)) void Cla1Task1 ( void )
{
//
// Turn ON Loop1 Profiling GPIO
//
GPIO_writePin(16,1);
loop1_task();
//
// Turn OFF Loop1 Profiling GPIO
//
GPIO_writePin(16,0);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The task is triggered every 20us as expected but the toggling of the LED on and off takes ~2us. This seems like a long time, especially for the CLA which should be a very fast peripheral. THE CLA is in direct control of hte GPIO and this is what we get:-

GPIO Toggling in CLA task 1

Any idea why turning an LED on and off like this in a CLA task would take so long to execute?

  • I should also say that when I measured the GPIO pin timing shown above, the 'loop1_task();' was commented out so we are just looking at the timing for the lines which set the GPIO pin 16 high and then set it low.

  • Iain, 

    My apologies for the delay in response due to out of office around the US holidays.

    Driverlib functions abstract the hardware for ease of use but this is at a price of taking more cycles vs writing directly to a register.  In addition, the "debug" version of the driverlib will take more cycles than the "release" version. 

    To get around this, the register can be written to directly. There is an example in C2000Ware that does this from the CLA code using the HWREG macro:

    • C:\ti\c2000\C2000Ware_<version>\driverlib\f28003x\examples\cla\
    • cla_ex5_adc_just_in_time

    The highlighted line will write to the SET register for GPIOA.SET register bit corresponding to GPIO2 (0x4 = b0100)

    Regards

    Lori

  • Hi Lori,

    Thanks for taking a look into this for me. I'll be back in the lab on Thursday so will try this out and let you know how it impacts the speed. 

    Kind Regards,

    Iain

  • Hi Lori,

    I just tried using the HWREG command and this makes things much better! With the CLA task with just the HWREG to set the GPIO high and immediately low again, we get the following measured behaviour:-

    So, we now see a high pulse of about 16ns. We have a 120MHz internal clock so this looks like about two clock cycles to set high and then two cycles to set low again.

    thanks very much for your help with this,

    Best Wishes, Iain