Hi,
I'm trying to use the LDT timer to make my system sleep for a specific amount of time.
The following function configures my LDT:
// The counter must be disabled (~ENABLE) before reading its value and enabled again.
bool const counter_should_be_running = false;
status = FS65_LDT_RunCounter(counter_should_be_running);
if (status != fs65StatusOk) return -1;
// Long Duration Timer
// The timer is configurable by the SPI and can operate in normal mode and low-power mode
// The LDT as multiple functions
// Function 4: In low-power mode, count until the counter reaches the wake-up value and wakes up.
//
// NXP FS6500, Product data sheet rev7.0, 12.8.3 Timer operation
fs65_ldt_function_t const timer_is_our_alarm_clock = fs65LdtFunc4;
status = FS65_LDT_SetTimerOperation(timer_is_our_alarm_clock);
if (status != fs65StatusOk) return -1;
// When function 4 is selected and the counter reaches the wake-up value (EOT), the device wakes up and the counter
// is stopped.
//
// NXP FS6500, Product data sheet rev7.0, 12.8.3 Timer operation
uint32_t const wakeup_value = sleep_time_sec; //< The timer is configured at 1 Hz
status = FS65_LDT_SetWakeUpValue(wakeup_value);
if (status != fs65StatusOk) return -2;
bool const start_running = true;
status = FS65_LDT_RunCounter(start_running);
if (status != fs65StatusOk) return -3;
The first time I call this function it works great.
The problem occurs when I call this function a second time: the LDT timer refuses to be disabled.
More specifically, the FS65_LDT_RunCounter(false) function fails because LDT_ENABLE is still set to 1.

The proof of the LDT_ENABLE is still set.

What is the proper way to configure the timer so it can be used twice in a row?
Regards,
Gabriel