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.

Fastest way to toggle GPIO with DSP/BIOS on OMAPL138 C67xx Core

Other Parts Discussed in Thread: OMAPL138

Hi,

I'm using the OMAPL138 processor (CLOCK=300 MHz) and startet with a DSP/BIOS (5.41.11.38) applikation. I also implementet the PSP-GPIO-Driver (1.30.01) . But when control the pinvalue, as shown in the PSP-example, and put the following code in a while-loop:

pinCmdArg.pin   = GPIO8_14_PIN;

pinCmdArg.value = 0;

Gpio_setPinVal(gpio0, &pinCmdArg);

pinCmdArg.pin   = GPIO8_14_PIN;

pinCmdArg.value = 1;

Gpio_setPinVal(gpio0, &pinCmdArg);

 

The measured frequency on this pin is at 520 kHz. No parallel Task is running. The Symbol "PSP_DISABLE_INPUT_PARAMETER_CHECK" is defined, performance the same than without this defined symbol. To get a higher toggle frequence, I extracted the following lines from the PSP-Driver and put it also in a while loop:

gpioBaseAddress->BANK[4].SET_DATA = (1u<<14);

gpioBaseAddress->BANK[4].CLR_DATA = (1u<<14);

The measured frequency on the pin is now 8.222 MHz but in my mind still slow.

 

Can anybody suggest me a way how to increase the speed of this procedure?

 

Thanks a lot,

Christian

 

 

  • You could putting as much as you can into registers and avoid any repetitive address calculations. Something like:

    void toggle(int bank, int gpio, int n)
    {
      register int nr = n;
      register volatile Uint32 *pSET = &gpioBaseAddress->BANK[bank].SET_DATA;
      register volatile Uint32 *pCLR = &gpioBaseAddress->BANK[bank].CLR_DATA;
      register Uint32 mask = 1u<<gpio;
      do
      {
        *pSET = mask;
        *pCLR = mask;
      }
      while(--nr);
    }

    The compiler probably already produces the same code in release mode.

  • Thanks for your answer.

    in your version, i'm able now to let the pin toggle with 12.5 MHz.

    Is this the highest reachable frequency?

     

     

  • There are few posts about GPIO speed in this forum. Here's a few:

    http://e2e.ti.com/support/dsp/omap_applications_processors/f/42/t/127628.aspx
    http://e2e.ti.com/support/dsp/omap_applications_processors/f/42/t/135631.aspx

    You could try hand coding in assembler with C67xx specfic opcodes. Or in C if the intrinsic library has the opcode your want. I have doubts you can get much faster as the GPIO controller itself has large delays. Unrolling the loop and removing the loop counter test for a fixed number of cycles might be faster as well. All depends on the instruction cache and pipeline. Instruction cache favours tight loops. Pipeline favours unrolled loops. I don't know enough to say which is better.