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?

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

  • Thank you for shedding some light. My concern was with the toggling of CS pin. I have to do an SPI transfer by manually making one of the CS pin low. Then initialise GPIOTE toggle for two CS pins, initialise timer PPI for SPI transfer (1ms). Timer EEP ->SPI TEP,SPI EEP -> GPIOTE TEP. Can I use a software interrupt flag to store sensor readings into respective arrays ?

    Yeah. It can be done simply by software app timer and I did that. But I need to reduce CPU intervention as little as possible. That is why I am planning to use both PPI and EasyDMA advantages. I am using both the features for the first time. Can you please help me with EasyDMA also? Like how can I configure EasyDMA for this application and what are the things to be considered while using EasyDMA? Is there an example code for PPI+EasyDMA available??

    Thanks & regards, Vishnu

  • I don't think SWI is needed, when using ArrayList feature with SPI. It may be useful though. You should just read datasheet - operating with SPIM and PPI at register level is easier than it seems to be. I wouldn't go with drivers etc here, just to simplify. nRF52 has lots of timers with lots of CC registers, so it is quite easy to synchronize everything with them. You are not able to send data via BLE with PPI only, but that should be acceptable though.

  • Sending data through BLE can be done using app_timer. I am finding some some difficulty in the PPI configuration here. I'll try and update.

  • Hi,

    There is a small change in my application. I have an AFE and an accelerometer, both SPI, connected to same SPI channel. My goal is to read SPI data every 100ms from both the sensors. One of the sensor reads 75 bytes of data and the other reads 5 bytes at this instant. Will it be possible by the above method as @Wojtek suggested? The data has to be read with EasyDMA and stores in an array. Then the collected data has to send every 'x' seconds(This amounts 800+ bytes).

Related