nRF52840 SPIS semaphore acquire and release

Hi All,

I am using the nRF52840, with SDK140 v15.0. I have configured the nRF52840 to be a SPI slave to a NXP processor. When I connect the logic analyzer I see signals on the SCK line and MOSI lines as well as the CS line going low. I also see the expected data on the MOSI line which the NXP SPI Master is sending, but the MISO line is always set to the DEF character which is 255 or HIGH. After reading the other posts and debugging my code I find that the issue is related to semaphore Aquire/ release. In my code the nRF52840 always gets stuck at the nrfx_spis_buffers_set function call. After putting in printfs for debugging I am able to trace the code all the way down to  nrf_spis_task_trigger(p_spis, NRF_SPIS_TASK_ACQUIRE); The code gets stuck at nrf_spis_task_trigger.

I have made sure that there are no hardware issues here at all.

Can anyone please explain what is happening here? Why is the SPI slave unable to acquire the semaphore at all?

 

Parents
  • I know this is a long shot, but I'm experiencing the exact same issue, and it appears that a lot of people have also encountered this. Does anyone know of the solution?

    I've gone through and confirmed that SPIS has been successfully configured before the CS line is being pulled low. However it appears that I'm unable to ACQUIRE the semaphore. 

Reply
  • I know this is a long shot, but I'm experiencing the exact same issue, and it appears that a lot of people have also encountered this. Does anyone know of the solution?

    I've gone through and confirmed that SPIS has been successfully configured before the CS line is being pulled low. However it appears that I'm unable to ACQUIRE the semaphore. 

Children
  • Hi,

    It is not easy to see if this is the same issue as you are seeing or not. I suggest you create a new question where you explain the issue you are seeing in more detail in order to look at that specifically. (There you could refer to this thread.)

  • I've managed to solve my issue with the ACQUIRE event, so I'll post some information here in case it helps someone else in the future.

    Background
    I was working on implementing SPIS functionality for the NRF52832 within Mbed OS. This involved working through the  targets/.../TARGET_MCU_NRF52832/spi_api.c file within Mbed and trying to add SPIS functionality around the existing SPI/SPIM functionality.


    Problem

    The program would hang whenever I ran nrfx_spis_buffers_set(). Digging further down, I found that the program would trigger the task to acquire the semaphore, nrf_spis_task_trigger(p_spis, NRF_SPIS_TASK_ACQUIRE), however the spis_irq_handler() would never be called.

    Solution

    After too many days of investigation, I found that I had not registered the interrupt handlers in the driver with the NVIC.

    Simply put, I should have called:

    NVIC_SetVector(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn, (uint32_t) SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler)

    Before calling:
    nrfx_spis_buffers_set()



    I appreciate that this may be more of an Mbed OS issue, however there seems to have been a number of people that have experienced this issue, so I wanted to leave it here anyway, just in case others find it useful.

Related