This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problems of using GPIOTE and BLE together.

Hello.

I try to BLE and GPIOTE.

The reason for using GPIOTE is to read data from the temperature sensor.

And I want to sending data of temperature sensor by BLE.

When BLE and GPIOTE are used together, even BLE scan does not work.

I am not sure if this is a Priority problem or another problem.

Could you please help?

  • Hi 

    When using the BLE SoftDevice it is critical not to have any interrupts in the application running at priority 0, 1, 3 or 4. What priority is your GPIOTE interrupt running at?

    Are you using one of the SDK drivers for the GPIOTE, or are you interfacing directly to the hardware?

    Best regards
    Torbjørn

  • Hi, First, Thank you for reply.

    I am using the priority of 2. And it was setting via the PPI.

    My approximate code is below.

    And I modified the priority to 6, 7, and 3. but I had the same problem.

    Where should I modify it?

    //Main part ----------------------------------------------------------------------------
    int main(void)
    {
      NRF_UICR -> NFCPINS = 0xFFFFFFFE;  //NFC pin disable
      gpioteInit(); //GPIOTE initialization
      uartInit(); //UART initialization
      twiInit();  //TWI initialization
      BLE.Init(); //BLE initialization
    
      NRF_GPIO -> DIRSET = PIN25; //PIN OUT mode
      NRF_GPIO -> OUTCLR = PIN25; //Turn on the Sensor part
      NRF_GPIO -> PIN_CNF[9] = 0x0C; //PIN INPUT PULL UP => For temperature sensor
    
      writeData(Accel_address,CTRL_REG1,0xC0);  //active acceleration sensor
      writeData(Accel_address,CTRL_REG2,0x03);  //Output Data Rate 100Hz(=10ms)
    
      char ch[50];
    
      println(">>> start BLE UART Example");
    
      timer2Init(10); //Timer Interrupt initialization, period 10ms
      timer4Init(5); //Timer Interrupt initialization, period 5us
    
      while (1)
      {
    
      }
    
      return 0;
    }
    
    
    
    
    //GPIOTE Initialization ----------------------------------------------------------------------------
    //PIN9, Falling edge, Channel 0, Interrupt 0
    
    void gpioteInit()
    {
      //Interrupt Set
      NRF_GPIOTE -> INTENSET = 0x80000001;  //IN[0] Set, Enable => Write '1' to Enable interrupt for IN[0] event
      NRF_GPIOTE -> CONFIG[0] =  0x00020901;  //configuration of IN[0], Mode = Event, Pin 11, Falling edge
      NRF_GPIOTE -> TASKS_OUT[0] = 0x01;  //TASKS 0 set
    
      //PPI Set
      NRF_PPI -> TASKS_CHG[0].EN; //Enable channel group
      NRF_PPI -> CHEN = 1;  //CH0 Enable
      NRF_PPI -> CHENSET = 1; //CH0 Enable and Set
      NRF_PPI -> CH[0].EEP = NRF_GPIOTE -> EVENTS_IN[0]; //EVENTS_IN[0]; 0x001,
      NRF_PPI -> CH[0].TEP = NRF_GPIOTE -> TASKS_SET[0]; //0x000
      NRF_PPI -> FORK[0].TEP = NRF_GPIOTE -> TASKS_SET[0]; //0x000
    
      NVIC_SetPriority(GPIOTE_IRQn, 2);
      NVIC_EnableIRQ(GPIOTE_IRQn);
    
    }
    
    //GPIOTE Handler-------------------------------------------------------
    void GPIOTE_IRQHandler(void)
    {
      NRF_GPIOTE -> EVENTS_IN[0] = 0; //removed Events bit
      SensorCount++;  //temperature sensor data pulse count, Falling edge
      TimeCheck = 0;  //when falling edge, TimeCheck reset
    }
    

    Thank you. 

    Best regards.

  • Hi 

    One potential problem is that you are accessing the PPI peripheral directly when using the SoftDevice. 

    The PPI is one of the peripherals that is controlled by the SoftDevice when it is enabled, and you have to access it through the sd_ppi functions rather than accessing the hardware directly. 

    You can find the documentation for these functions here.

    Best regards
    Torbjørn

  • Hi,

    First, Thank you for reply.

    I will try it. Thank you for your help.

    Thank you.

    Regards.

  • Hi 

    I'm happy to help. 

    Just let me know if you have more questions Slight smile

    Best regards
    Torbjørn

Related