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

DMA for SPI master

I'm reading AD-converter data usin nRF51822 SPI-Master. BLE-stack is active so I can't use interrupts with SPI. I get data every 2 ms. Sometimes Events are delayed so long that I get erroneous data from AD.

Is there some way to implement DMA for the SPI-Master, maybe using SPI-slave some way?

Juha Okkonen

  • No problem. Regarding the missing interrupt, as you say it should be skewed when a lower stack interrupt occurs. How much processing are you doing in the GPIOTE interrupt handler? There is a chance that a lower stack interrupt happens while in the GPIOTE IRQHandler. If you haven't cleared the EVENT register at this time and a new GPIOTE interrupt occurs, that new interrupt will be discarded once the EVENT register is cleared. If you aren't already, try clearing the NRF_GPIOTE->EVENTS_x register as the very first thing you do in the IRQHandler.

  • Hi Audun,

    I'm not doing much in the GPIOTE interrupt handler, just toggling the debug pin. See the other thread linked below for code snippet.

    I'm using app_gpiote and by looking at its implementation, clearing the EVENTS register is the first few things it does.

    void GPIOTE_IRQHandler(void) { uint8_t i; uint32_t pins_state = NRF_GPIO->IN;

    // Clear event.
    NRF_GPIOTE->EVENTS_PORT = 0;
    

    ... ...

    I opened another thread for the GPIOTE interrupt issue so I don't hijack this post. devzone.nordicsemi.com/.../radio-activity-causes-gpiote-interrupt-missing

    Thanks, Bruce

  • I have been trying to make implementation using two timers and spi slave device to handle data transfer every two milliseconds. One timer generates correct SCK for the SPI slave by toggling output pin. Second timer counts pulses and stops first timer. For some reason I can get correct output only if I run code in debugger by stepping source lines. If I just run without breakpoints nothing happens. And usually when stepping and things seem to work correctly otherwise ( I see correct pulse train on logicanalyzer ) debugging freezes immediately after starting both timers. Any ideas what's going on???

    Another question; how are functions wired into pins. Can I connect SPI:s SCK to same I/O-pin that timer is toggling. Or is only one function connected at a time. I have seen comments that behaviour is not specified if two different outputs are connected to same PIN, which would seem to implicate that what I want to do is possible. I also need to connect SPI:s CS to a pin thats configured for output.

Related