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

SPIM list easydma hardfault issue

Hello DevZone,

PCA10040 SDK 15.0.0 SD132

I written my own SPIM driver which uses the list function to read in a few bytes. I've set up my list as the example in the datasheet but modified the size of the list and the number of bytes to read.

#define BUFFER_SIZE  20
  
typedef struct ArrayList
{
    uint8_t buffer[BUFFER_SIZE];
} ArrayList_type;

ArrayList_type MyArrayList[50];

//replace 'Channel' below by the specific data channel you want to use,
//         for instance 'NRF_SPIM->RXD', 'NRF_TWIM->RXD', etc.
Channel.MAXCNT = BUFFER_SIZE;
Channel.PTR = &MyArrayList;

I have a timer's compare linked with PPI to start the SPI read.

In the SPI interrupt (at level 2) I increment a static variable and check if it's 40, if so reset the read pointer to the beginning of the arraylist.

void SPIHandler(void)
{
    static uint8_t Cnt = 0;
    if (nrf_spim_event_check(NRF_SPIM0, NRF_SPIM_EVENT_END))
    {
        nrf_spim_event_clear(NRF_SPIM0, NRF_SPIM_EVENT_END);
        Cnt++;
        
        if(Cnt == 40)
        {
            Cnt = 0;
            NRF_SPIM0->RXD.PTR = (uint32_t)&MyArrayList;
        }
    }
}

Because my timer is running quite fast and there is a possibility of BLE interrupting resetting the readpointer I've added 10 blocks of overhead so the readpointer isn't writing outside of its bounds.

It seems to happen that this still occurs, even if I create this overhead in the order of 50 blocks. 

I do not know how to stop my processor from failing and resetting the read pointer in time.

Is there no automatic function to make sure my read pointer is set to the correct address every time and on time?

Parents Reply Children
No Data
Related