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

Where is the I2S interrupt handler registered in nRFX drivers?

I'm trying to use the I2S peripheral on the nRF5340DK.  It looks like the zephyr drivers don't currently support this board, so I need to use the nRFx drivers.  I've ported over an I2S example from the nRF5 SDK, but when I run it, I get stuck in a reboot loop.  As near as I can tell, the I2S interrupt service routine is not getting updated in the ISR table, and it's instead calling the default spurious interrupt handler, triggering the software reset.  There's four functions documented in the nRFx I2S driver section of the documentation, and I've stepped through them making sure I understand what happens.  At no point do I see the ISR table being updated, either with my data handler function, nor with the nrfx_i2s_irq_handler function in nrfx_i2s.c.  Deep in the CMSIS codebase, I found __NVIC_SetVector, but it doesn't seem to be getting called at any point, either.  What is preventing me from getting these interrupts working?

Parents Reply
  • Yep.  I realized I was missing the macro this morning.  Things are working properly now.  Given that nrfx_i2s_start enables the interrupt, I would have expected there would be something in nrfx_i2s_init to register the interrupt, especially considering I supply a function handle to be called from nrfx_i2s_irq_handler.  What use-case is supported by keeping this separate?

Children
  • Hi 

    Sorry for the slow response.

    The nrfx drivers are not designed for Zephyr exclusively, but are in essence RTOS agnostic (they are also used for the nRF5 SDK). As such, they can't really be designed to handle interrupts in the Zephyr way. 

    For a more streamlined experience in Zephyr it is better to use the native Zephyr API's, when possible, and nrfx will be used under the hood. In this case no manual IRQ CONNECT is needed. 

    Best regards
    Torbjørn

  • Thanks for the response, Torbjørn.

    I had tried using the Zephyr I2S API, but wasn't having much success.  When I dug deep into zephyr\boards\arm\nrf5340dk_nrf5340\doc, I saw that I2S wasn't listed as a supported feature.  I had assumed that meant that Zephyr didn't support this peripheral on the nRF5340, prompting me to use the nrfx drivers directly.  It sounds like I may have come away from this with the wrong impression.  It should be possible, then, to use the native Zephyr API to access the I2S peripheral on the nRF5340?

  • Hi 

    I was able to build the Zephyr I2S example for both the nRF52840DK and the nRF5340DK after reducing the size of the I2S buffers, so it seems that these boards are supported, but I didn't have time to test the examples properly. 

    Which problems did you encounter when you tried this?

    Best regards
    Torbjørn

  • Unfortunately, I no longer remember exactly.  I think I had been having trouble configuring the devicetree overlay, and possibly with triggering using I2S_DIR_BOTH.  I went looking for the board's dts file and found the document I mentioned earlier that didn't include I2S on the list of supported peripherals.  I thought that meant that Zephyr didn't support I2S on the nRF5340, so I stopped using the Zephyr API and switched to using the nrfx drivers.

    I was, and still am, new to Zephyr and NCS.  With the gift of one month's hindsight, I can see a couple places where I had probably implemented or configured something incorrectly.  At the time, though, that document had me convinced that I2S wasn't supported and the only way was to use the nrfx drivers.

  • Hi

    No worries. There is nothing wrong with using nrfx drivers, at least not as long as the project only needs to support Nordic devices. 

    Using the Zephyr drivers means you can easily port code between parts from different vendors, but in some cases you lose a bit of functionality since the Zephyr drivers are designed to be general and not specific to Nordic hardware only.

    Certain peripherals, like the PPI controller, are so Nordic specific that no Zephyr driver exists. In this case using nrfx (or hardware registers directly) is the only option.  

    Best regards
    Torbjørn

Related