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

How to use PPI on same pin for two different task?

Hi,

I am trying to use PPI for generating a output of lo to hi when NRF_RADIO->EVENTS_READY occurs.I want to generate on the same pin hi to lo when NRF_RADIO->EVENTS_END occurs.

I am not able to assign ppi channels for same pin and different task?

Can anyone help with that?

Thanks,

Hitesh

Parents
  • Hi

    The biggest problem with this might be that only one GPIOTE task can be associated with each pin. I.e. you can't have two tasks control the same pin. Hence you can't have EVENTS_READY trigger a HiToLo task and EVENTS_END trigger a LoToHi task on one and the same pin. However, you can have two events triggering the same task. So that means you can have one Toggle-task and have EVENTS_READY and EVENTS_END toggle the same pin. But then you might have troubles with deciding which event caused the toggle. I did a quick test and made this logic trace:

    image description

    As you can see, which event is toggling when can be difficult to follow. And this is only advertising. I would imagine it would even harder to follow in connections with lots of traffic.

    EDIT: Below is the code I used for testing. I simply added this code to the ble_app_template found in the SDK.

    #define TASK_RDY_AND_END_TGL 0
    #define TASK_ON_END_TGL 1
    
    void ppi_setup(void)
    {
        /** Task to toggle LED 3 on both EVENTS_READY and EVENTS_END **/
        NRF_GPIOTE->CONFIG[TASK_RDY_AND_END_TGL] = 
                                ( (GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos) |
                                (LED_3 << GPIOTE_CONFIG_PSEL_Pos) |
                                (GPIOTE_CONFIG_POLARITY_Toggle << GPIOTE_CONFIG_POLARITY_Pos) |
                                (GPIOTE_CONFIG_OUTINIT_High << GPIOTE_CONFIG_OUTINIT_Pos)); 
        
        /** Task to toggle LED 4 on EVENTS_END only**/
        NRF_GPIOTE->CONFIG[TASK_ON_END_TGL] = ( (GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos) |
                                (LED_4 << GPIOTE_CONFIG_PSEL_Pos) |
                                (GPIOTE_CONFIG_POLARITY_Toggle << GPIOTE_CONFIG_POLARITY_Pos) |
                                (GPIOTE_CONFIG_OUTINIT_High << GPIOTE_CONFIG_OUTINIT_Pos));  
        
        /** Two PPI channels conncting EVENTS_READY and EVENTS_END and first pin toggle task **/
        NRF_PPI->CH[0].EEP = (uint32_t)&NRF_RADIO->EVENTS_READY;
        NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[TASK_RDY_AND_END_TGL];
        NRF_PPI->CHEN = (PPI_CHEN_CH0_Enabled << PPI_CHEN_CH0_Pos);
        
        NRF_PPI->CH[1].EEP = (uint32_t)&NRF_RADIO->EVENTS_END;
        NRF_PPI->CH[1].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[TASK_RDY_AND_END_TGL];
        NRF_PPI->CHEN |= (PPI_CHEN_CH1_Enabled << PPI_CHEN_CH1_Pos);
        
        /** One PPI channel conncting EVENTS_END and second pin toggle task **/
        NRF_PPI->CH[2].EEP = (uint32_t)&NRF_RADIO->EVENTS_END;
        NRF_PPI->CH[2].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[TASK_ON_END_TGL];
        NRF_PPI->CHEN |= (PPI_CHEN_CH2_Enabled << PPI_CHEN_CH2_Pos);
    }
    
  • Thanks Martin. We didn't realize about that.

    Your solution might work for us, but it is not the ideal solution as we want to receive the event when its only transmitting and it seems from your solution that I will get an event on both receive and transmit.

    Is there any workaround that we can do using VDD_PA pin? Just to let you know VDD_PA pin in our design is already hooked up to some other pin and we cannot change the design. Can VDD_PA pin use as a crossbar functionality?

Reply
  • Thanks Martin. We didn't realize about that.

    Your solution might work for us, but it is not the ideal solution as we want to receive the event when its only transmitting and it seems from your solution that I will get an event on both receive and transmit.

    Is there any workaround that we can do using VDD_PA pin? Just to let you know VDD_PA pin in our design is already hooked up to some other pin and we cannot change the design. Can VDD_PA pin use as a crossbar functionality?

Children
No Data
Related