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

Problem with Event and Interrupt in NRF52 !

Hi Forum! I have to understand NRF52 chip for my job! I used to work with STM32 before. It has "Interrupt" (e.g when I receive one byte via SPI, It generates one "SPI_Rx_Interrupt". I can implement my code in the callback function(read this byte, toggle led....) ) .But with NRF52 chip. I can't read anything similar. NRF52 has "Event". This is a new concept with me!

  • I don't know what is "Event".
  • Do have any relation between "Event" and "Interrupt"? ( I think "Yes" ).
  • How is NRF52 chip can detect when the event occurs? ( If I receive one byte via SPI, how is nrf52 detect it?)
  • How can I creat "My_Event" myself?

I hope devTeam can help me in all my question because NRF52 code example is very hard to learn. Thanks all!

Parents
  • Of course there are interrupts under the hood! It's ARM Cortex-M, no magic, so of course HW is giving interrupt calls to execute certain parts of SW if such interrupt happens and there is some interrupt handler configured.

    However most of these low-level interrupts are consumed by the stack (Nordic Soft Device or other if you choose) or by drivers which are using HAL. Therefore all typical SW constructions in example FW projects on nRF5x platform you will see "event handlers" registered in various init functions and then implementing handling of these events as they come asynchronously from lower layers. Under this live interrupts but that's very similar to STM32 HAL and SDK modules, isn't it?

    Finally to how hard is it to understand e.g. SPI Master functionality on nRF52 chip:

    • You can open examples\peripheral\spi\main.c and use nrf_drv_spi driver module as per example. it has one event handler and then few events and function calls which do everything what you ask for: starting transfer, callback when transfer is over. What more you would need?
    • Alternatively if you don't like Nordic SPI Master driver then go to chip specification and see what registers and interrupts are available to build your own flow on lower level. In the end you will read that these "events" are just interrupts which get enabled/disabled/cleared as usually. You can also see how Nordic do it in their driver in components\drivers_nrf\spi_master\nrf_drv_spi.c file.

    And you can go on for all the HW peripherals like SPI/TWI/I2C/RADIO/UART/I2S/PWM/PDM...

    With this knowledge could you give us feedback if there is still something unclear about similarities between nRF5 and STM32 chip designs and SDKs or if it's OK now?

  • And one more specific of nRF5x platform is this "Task and Event" mechanism where you can use different events of different feature blocks (basically interrupts) and link some tasks to any other part of the system once these events happen. You cannot really invent your own because these are more or less HW related but you can through register program some flow (e.g. when SPIM ENDTX happens you can lounch some completely unrelated tasks e.g. PWM or RTC or TIMER start). This might be unique to nRF5 platform but not so much difficult to understand.

Reply
  • And one more specific of nRF5x platform is this "Task and Event" mechanism where you can use different events of different feature blocks (basically interrupts) and link some tasks to any other part of the system once these events happen. You cannot really invent your own because these are more or less HW related but you can through register program some flow (e.g. when SPIM ENDTX happens you can lounch some completely unrelated tasks e.g. PWM or RTC or TIMER start). This might be unique to nRF5 platform but not so much difficult to understand.

Children
No Data
Related