khoih-prog / NRF52_MBED_TimerInterrupt

This library enables you to use Interrupt from Hardware Timers on an NRF52-based board using mbed-RTOS such as Nano-33-BLE. These nRF52 Hardware Timers, using Interrupt, still work even if other functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software timers using millis() or micros(). That's mandatory if you need to measure some data requiring better accuracy. It now supports 16 ISR-based Timers, while consuming only 1 Hardware Timer. Timers' interval is very long (ulong millisecs). The most important feature is they're ISR-based Timers. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks.
MIT License
15 stars 2 forks source link

analogRead #2

Closed Hamajo closed 3 years ago

Hamajo commented 3 years ago

I tried using the Argument_None Example that you have on Ardiuno Nano 33 Sense and it worked perfectly fine. The issue is whenever I add a analogRead within any of the Interrupt Service Routines the program will freeze after the first printResult function. To even upload a new sketch the Ardiuno Nano 33 Sense has to be but into bootloader mode.

khoih-prog commented 3 years ago

There are many commands you can't use inside ISR.

For Nano-33-BLE / Sense, analogRead/analogWrite are commands not to be used in ISRs.

You can just set a flag, then call analogRead inside a timer's loop.