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.

Urgent probem! why GPIO APIs like GPIOSetBit or GPIOClrBit need so much time to toggle

Hi ,

I encountered one puzzling probem while using  GPIO functionality on platforms of OMAP3730 WINCE.

The issue is that  APIs like GPIOSetBit() or GPIOClrBit would take several microseconds to take effect and  I am wondering why the time should not be so long. 

 It seems the clock gate settings to GPIO  should be optimized, but  where to modify. Could anyone help on this .issue,thanks.

Best Regards

Jun

 

  • Why would you say this is puzzling? I would suspect a few microseconds to be quite normal.

  • Hi David,

    Thank you for your reply.

    I think the toggle rate for GPIO on A8 chip should reach tens of Mega HZ, that is ,grade of  ns, not  limited to  microseconds. In fact, GPIO and MCU can guarantee ns level toggle rit.

    So i am trying to find where to modify in the WINCE bsp to increase to a higher clock rate as above.

  • If you are looking to do some kind of high frequency oscilator on a GPIO line then do it in assembly. The GPIO API in the BSP is ment for general purpose IO, like enabling/disabling peripherals tied to GPIO lines etc. You can do medimum frequency stuff like like controlling the LCD backlight intensity via toggling a GPIO line whith the API but the basic OS overhead will prevent you from getting into the Mhz range. I would suspect maybe a few 10's of Khz would be the upper end using this technique. Another option would be use the advanced timer peripheral on the part itself as this can be programmed to automously toggle a GPIO line at very high frequencies without any OS overhead.

  • Hi David ,

    Thank you so much on your kindly reply.

    I would like to describe some background about the GPIO usage.

    1. In  fact, i am connecting SPI1 interface to one SPI-CAN chip, MCP2510.  But, unluckly,  i was stuck on SPIWriteRead operation. Both SPIOpen and SPIConfigure API can be sucessfully performed, And besides, i can get correct waveform of  MOSI pin, that is, transmiting pin after configration. But i can just get zero from MISO(input ) after trying many types of settings.  Here is the setting of SPI1 in bsp_padcfg.h.

    #define MCSPI1_PADS \
        PAD_ENTRY(MCSPI1_CS0, INPUT_DISABLED | PULL_RESISTOR_DISABLED | MUXMODE(0)) \
        PAD_ENTRY(MCSPI1_SOMI,INPUT_ENABLED | PULL_RESISTOR_DISABLED | MUXMODE(0)) \
        PAD_ENTRY(MCSPI1_SIMO,INPUT_DISABLED | PULL_RESISTOR_DISABLED | MUXMODE(0)) \
        PAD_ENTRY(MCSPI1_CLK, INPUT_ENABLED | PULL_RESISTOR_DISABLED | MUXMODE(0)) 

    And also, test demo is as below:

    bool OMAP_SPI_Init(void)
    {
     
     bool dResult = false;

     hSPI = SPIOpen(L"SPI1:");  // open SPI1 port
     if (hSPI == NULL)
     {
      return false;
     }
     //RETAILMSG(1,TEXT(" SPI1 OPEN successful\n"));
       
     config = /*MCSPI_PHA_ODD_EDGES|
           MCSPI_POL_ACTIVEHIGH|*/
        MCSPI_CHCONF_CLKD(40)|
        MCSPI_CSPOLARITY_ACTIVELOW|
        MCSPI_CHCONF_WL(8) |
        MCSPI_CHCONF_TRM_TXRX|
        MCSPI_CHCONF_DPE0;
     config &= ~MCSPI_CHCONF_DPE1;
     config &= ~MCSPI_CHCONF_IS;
     
     RETAILMSG(1,(TEXT( " config=0x%x\n"),config) );
     if(!SPIConfigure(hSPI,0,config))
     {
      hSPI=NULL;
      return false;
     }
     dResult = true;
     return dResult;
     
    }

    2. So i turn to GPIO for help, and I can communicate with MCP2510 successfully, but the baudrate is too low, which would cause frame missing or other mistakes in CAN.

    If you are familiar with SPI also, please help suggest your ideas.

     

    Best Regards

    Jun