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

nrf52 PPI+EasyDMA using timer and SPI

Hi,

I am using nrf52832 for my application. The application share same SPI module for two sensors(with sensors are selected using two chip select pins). Is it possible to implement PPI channel between a timer and this SPI module so that I can collect data from both the sensors every 1ms? I would like to collect the SPI data using EasyDMA and send these data through BLE every 50ms. how can it be achieved with the help of PPI and EasyDMA?

  • I think this cannot be achieved using PPI only, as you have different lengths of data. It will be needed to change MAXCNT value after the long 75 byte transfer to transfer only 5 bytes from the second sensor. But that would be short interrupt.

  • Forget EasyDMA part as of now.I got confused because of this different data length. Can it be achieved with PPI? When 100ms is elapsed, one of the sensor has to be read and store the value in an array , then toggle the CS pins using GPIOTE, read the data from the second sensor and store in another array or same array. is it possible? Once if I could get control over PPI, I will try to do the rest.

  • Ok, I'll try to exaplain it differently:

    EasyDma gives You possibility to transfer data, ex. 20 bytes without using interrupts between them. You just start transmission, and it goes 20bytes.

    PPI can be used to ex. set hardware timer, it triggers PPI periodically, PPI triggers SPI START task.

    When SPI START is triggered, 20bytes (MAXCNT) are transmitted (thanks to EasyDMA) without using interrupts.

    The problem is, you want something like: SPI start -> transmit 75 bytes -> toggle pins etc -> transmit 5 bytes. It is not possible to change from 75 to 5 bytes without CPU intervention (ppis can only trigger transmission starts, toggling pins etc), that is why You need one interrupt there anyway.

  • Thanks for the detailed explanation. Now I understand the difficulty. Still couldn't get complete hold on PPI. I am trying to do a simple PPI between timer and SPI now.

  • I don't have access to any IDE right now, but it will be something like this (may not be 100% correct):

    NRF_PPI->CH[PPI_CHANNEL].EEP = NRF_TIMER3->EVENTS_COMPARE[0];
    NRF_PPI->CH[PPI_CHANNEL].TEP = NRF_SPIM0->TASKS_START;
    NRF_PPI->CHENSET = (1 << PPI_CHANNEL);
    

    So, when TIMER3 CC0 event occurs, SPIM0 START task will be triggered. You have to configure SPIM0 before that ofc. You may want to use PPI driver from Nordic SDK, but I don't like it very much myself - but You know what to set now.

Related