Non Blocking IO Port using ThreadX

Hi 

   I am using Synergy S7G2  MCU, I have run into a peripheral device which uses Two-Wire Serial Digital Interface (Not I2C) more of a Two wire SPI version. In this device  I need to POLL the Input and wait for the the Input to get High and after that send clock cycles to fetch the data I do not want to poll the input as the device takes a lot of time 10ms for the data to get ready and other processes stall (Graphics etc.) due to polling.

Is there a non-blocking way to poll the Input pin of the device, I do not have any IRQ input pin available! Is it possible to poll the input state using threads or any framework so that the thread waits for the input and processes it whenever the input is available so that other threads work properly.

Warm Regards

Pranav

Parents
  • You haven't said which Synergy device you are using or how you are actually interfacing to the peripheral. If you are using an SPI peripheral (Simple SPI on SCI, or RSPI) you could switch the input pin to a GPIO input pin (using the ioport API), then poll the input level of the pin until you get the required level (again, using the ioport API), then do the transfer.

  • Hi I am using R7FS7G27H2A01CBD custom board with E2 studio.

    below is some part of the code I am using to read the device in a thread at 1 time slice configuration

    void lc_clock1()
    {

    g_ioport.p_api->pinWrite(IOPORT_PORT_11_PIN_02, IOPORT_LEVEL_HIGH);
    R_BSP_SoftwareDelay(25,BSP_DELAY_UNITS_MICROSECONDS);
    g_ioport.p_api->pinWrite(IOPORT_PORT_11_PIN_02, IOPORT_LEVEL_LOW);
    R_BSP_SoftwareDelay(25,BSP_DELAY_UNITS_MICROSECONDS);
    }

    long int readadc1()
    {
    ioport_level_t lvl1=IOPORT_LEVEL_LOW;
    long int adcval1=0;
    uint8_t ct=0,bt=0;

    while(lvl1==IOPORT_LEVEL_LOW)
    {
    g_ioport.p_api->pinRead(IOPORT_PORT_00_PIN_14, &lvl1);

    }

    while(lvl1==IOPORT_LEVEL_HIGH)
    {
    g_ioport.p_api->pinRead(IOPORT_PORT_00_PIN_14, &lvl1);

    }

    for(ct=0;ct<20;ct++)
    {
    lc_clock1();
    g_ioport.p_api->pinRead(IOPORT_PORT_00_PIN_14, &lvl1);
    if(lvl1==IOPORT_LEVEL_LOW)
    {
    bt=0;
    }
    else
    bt=1;
    adcval1|=bt;
    adcval1<<=1;
    }

    return(adcval1);
    }

    this is the method  I am using to fetch the data from  the device, The device is slow as I get a sample every 10ms and the thread tick is also at 10ms so a lot of time is wasted to get the data due to polling and other threads stall due to this polling, Need to get rid of the hardware polling of input so that it does not block the other processes.

     

    Warm Regards

    Pranav 

  • In this sample code on media gallery, you can generate a i/o pin ISR via a non IRQ pin!, using ELC.

    Provided your current pin is from Port1,2,3,4. 

     (+) s5_pk_elc_ioport_1_3_2.zip - Synergy - Media Gallery - Renesas Synergy Platform - RenesasRulz

  • Hi Pranav, 

    Were you able to solve this one already? Check CS Yep's reply if you haven't yet.

    Herald
    RenesasRulz Forum Moderator

    https://renesasrulz.com/
    https://academy.renesas.com/
    en-us.knowledgebase.renesas.com/

Reply Children
No Data