Available Timers on Nano 33 BLE

I'm using an Arduino Nano 33 BLE. I'd like to use three of the nRF52840 32 bit timers to control stepper motor velocities. I've found several references that say Timer0 and Timer2 are used by the "system". I have to admit I'm a little foggy on what the "system" is, assuming its some combination of Arduino libraries and/or mbedOS. Assuming Timer0 and Timer2 are off limits, that should leave Timer1, Timer3, and Timer4 available for application usage.

However, when I check timer registers, I see Timer1 in use, and Timer0 and Timer2 not in use. I realize that Timer0 and Timer2 can still be reserved for "system" usage, even though they are not in use at the moment. It's Timer1's status that surprises me. Timer1 seems to be set to go off every 0x70000010 micro seconds (about 30 minutes).

So here is my question: What timers am I safe to use without stepping on the "system"?
Thanks,
BB61

p.s. Here is the timer status and code used to check timer status.

10:29:21.984 -> Press Any Key to Begin
10:29:22.392 -> OK - Begin
10:29:22.392 -> TIMER0 Mode:0 ENSET Bits: 0 0 0 0   CC Regs(0x): 0 0 0 0  
10:29:22.392 -> TIMER1 Mode:0 ENSET Bits: 1 0 0 0   CC Regs(0x): 70000010 28 0 0  
10:29:22.392 -> TIMER2 Mode:0 ENSET Bits: 0 0 0 0   CC Regs(0x): 0 0 0 0  
10:29:22.392 -> TIMER3 Mode:0 ENSET Bits: 0 0 0 0 0 0   CC Regs(0x): 0 0 0 0 0 0  
10:29:22.392 -> TIMER4 Mode:0 ENSET Bits: 0 0 0 0 0 0   CC Regs(0x): 0 0 0 0 0 0  
#include <nrf_timer.h>

// Serial.print one line of status for given timer.  
void showTimerStatus(NRF_TIMER_Type* timer_address, int num_cc_regs){

	Serial.print("Mode:");
	Serial.print((int)nrf_timer_mode_get(timer_address));

	Serial.print(" ENSET Bits: ");
	for (int i = 0; i < num_cc_regs; i++)
	{
		bool enset = nrf_timer_int_enable_check(timer_address, (nrf_timer_cc_channel_t)1<<(16+i));
		Serial.print(enset ? 1 : 0);
		Serial.print(" ");
	}

	Serial.print("  CC Regs(0x): ");
	for (int i = 0; i < num_cc_regs; i++)
	{
		uint32_t cc = nrf_timer_cc_read(timer_address, (nrf_timer_cc_channel_t)i);
		Serial.print(cc,16);
		Serial.print(" ");
	}
	Serial.println(" ");
}

void setup() {
	Serial.begin(9600);
	unsigned int start_milli = millis();
	while (Serial.available() == 0){ // wait for char from terminal
		unsigned int elapsed = millis() - start_milli;
		if (elapsed > 1000) {
		Serial.println("Press Any Key to Begin");
		start_milli = millis();
		}
	}
	while (Serial.read() != -1);     // clear buffer
	Serial.println("OK - Begin");

  // See what timers are currently in use
	Serial.print("TIMER0 ");
	showTimerStatus(NRF_TIMER0, 4);
	Serial.print("TIMER1 ");
	showTimerStatus(NRF_TIMER1, 4);
	Serial.print("TIMER2 ");
	showTimerStatus(NRF_TIMER2, 4);
	Serial.print("TIMER3 ");
	showTimerStatus(NRF_TIMER3, 6);
	Serial.print("TIMER4 ");
	showTimerStatus(NRF_TIMER4, 6);
}

void loop() {

}

If You access direct the registers of the CPU You may get conflicts with the "system", which is the mbedOS running on the Nano BLE 33.
I detected, that the behavior of the OS depends very much on the libraries you use. Unfortunately there is no documentation, which timers (and other resources) are used by mbedOS (may be there is, but I could not find any).

I do not use libraries running on mbedOS (TWI/Wire, ArduinoBLE,...) and I have written my own libraries with direct access to the nRF52840.
I tested timers Timer 1 to Timer 4 with my own interrupt handlers and there was no disturbance, the timers worked perfectly (look here).

It is a good idea to check the timer registers, I did not have that in my mind. The timers I only used to check the interrupt handling. I am currently dealing with the peripheries "radio" and "twi".

Specific Update (30.12.2021)

Meanwhile I could verify that Timer 1 is used by MbedOS (at least for Arduino-micros(), which is my basic time function).
And Timer 0 is important for the BLE protocol at all, because there are programmable event-task-shortcuts for the nRF52840 linking Timer 0 tasks/events with Radio tasks/events. It is described in the product specification in chapter PPI - Programmable peripheral interconnect for the pre-programmed channels 20 to 31.

I agree with your observation that "the behavior of the OS depends very much on the libraries in use." I have also had no luck finding mbedOS documentation, but the nRF52840 documentation is very good and helpful.

Thank you for the link to your previous discussion. Before posting my question, I had searched through the forums a bit, and had already seen and bookmarked your response.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.