Here is my current Always-On Timer initialization code, with some commented-out code removed:
Here is how it was originally, commented-out code removed:
In these cases:
Rather, the datasheet indicates:
Code:
\ Initialize the AON timer : init-aon-timer ( -- ) POWMAN_TIMER_NONSEC_WRITE POWMAN_TIMER passwd-bis! POWMAN_TIMER_RUN POWMAN_TIMER bit@ not if POWMAN_TIMER_ALARM POWMAN_TIMER passwd-bis! POWMAN_TIMER_ALARM_ENAB POWMAN_TIMER passwd-bic! $20 POWMAN_LPOSC_FREQ_KHZ_INT passwd! \ 32 $C49C POWMAN_LPOSC_FREQ_KHZ_FRAC passwd! \ 0.768 $2EE0 POWMAN_XOSC_FREQ_KHZ_INT passwd! \ 12000 $0 POWMAN_XOSC_FREQ_KHZ_FRAC passwd! \ 0 POWMAN_TIMER_USE_XOSC POWMAN_TIMER passwd-bis! POWMAN_TIMER_RUN POWMAN_TIMER passwd-bis! then ;
Code:
\ Initialize the AON timer : init-aon-timer ( -- ) POWMAN_TIMER_NONSEC_WRITE POWMAN_TIMER passwd-bis! POWMAN_TIMER_RUN POWMAN_TIMER passwd-bic! POWMAN_TIMER_ALARM POWMAN_TIMER passwd-bis! POWMAN_TIMER_ALARM_ENAB POWMAN_TIMER passwd-bic! $20 POWMAN_LPOSC_FREQ_KHZ_INT passwd! \ 32 $C49C POWMAN_LPOSC_FREQ_KHZ_FRAC passwd! \ 0.768 $2EE0 POWMAN_XOSC_FREQ_KHZ_INT passwd! \ 12000 $0 POWMAN_XOSC_FREQ_KHZ_FRAC passwd! \ 0 POWMAN_TIMER_USE_XOSC POWMAN_TIMER passwd-bis! POWMAN_TIMER_RUN POWMAN_TIMER passwd-bis! ;
- BIT@ ( bits addr -- set? ) tests bits on a specified address, i.e. reads a specified address, ands it with the bits, and tests whether the value is non-zero
- PASSWD! ( x addr -- ) takes a value, ands it with $FFFF, ors it with $5AFE0000, and writes it to the specified address
- PASSWD-BIS! ( x addr -- ) reads a specified address, ands it with $FFFF, takes a value, ors it with the anded value of the address, ands it with $FFFF, ors it with $5AFE0000, and writes it to the specified address
- PASSWD-BIC! ( x addr -- ) reads a specified address, ands it with $FFFF, takes a value, clears its bits (i.e. ands the value by its one's complement) in the anded value of the address, ands it with $FFFF, ors it with $5AFE0000, and writes it to the specified address
Rather, the datasheet indicates:
There is nothing mentioned in the errata in the datasheet for this.RUN: Timer enable. Setting this bit causes the timer to begin counting up from
its current value. Clearing this bit stops the timer from counting.
Before enabling the timer, set the POWMAN_LPOSC_FREQ* and
POWMAN_XOSC_FREQ* registers to configure the count rate, and initialise the
current time by writing to SET_TIME_63TO48 through SET_TIME_15TO0. You
must not write to the SET_TIME_x registers when the timer is running.
Once configured, start the timer by setting POWMAN_TIMER_RUN=1. This will
start the timer running from the LPOSC. When the XOSC is available switch the
reference clock to XOSC then select it as the timer clock by setting
POWMAN_TIMER_USE_XOSC=1
Statistics: Posted by tabemann — Sat Aug 31, 2024 11:13 pm