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?

Parents
  • Yes, it is possible. may be something like:

    1. Setup spi, transmission buffers, timers etc
    2. Start 1st SPI transmission (either by timer PPI or manually by software - every 1ms)
    3. When transmission end, toggle CS pins by gpiote (triggered by spi end ppi), start timer
    4. when timer end, start second spi transmission (buffer pointer automatically incremented by array list).
    5. Data may be moved somewhere else, or just long arraylist may be used.
    6. goto 2?

    I may have skipped something, but in general, that should be doable. It also can be achieved quite easily completely without using ppi, timers etc - just by software app_timer, as 1ms is not that high freq.

    About sending it by BLE every 50ms... I would just use app_timer too for that.

  • 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.

Reply
  • 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.

Children
No Data
Related