Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5973

General • Re: Issue with Always-On Timer on the RP2350

$
0
0
Here is my current Always-On Timer initialization code, with some commented-out code removed:

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    ;
Here is how it was originally, commented-out code removed:

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!    ;
In these cases:
  • 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
I saw nothing in the reference manual that indicated that setting POWMAN_TUNER_RUN or any of these other fields resets POWMAN_READ_TIME_UPPER and POWMAN_READ_TIME_LOWER to the original time written into the lower 16 bits of POWMAN_SET_TIME_63TO48, POWMAN_SET_TIME_47TO32, POWMAN_SET_TIME_31TO16, and POWMAN_SET_TIME_15TO0 (i.e. ignoring the $5AFE written into the upper 16 bits thereof).

Rather, the datasheet indicates:
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
There is nothing mentioned in the errata in the datasheet for this.

Statistics: Posted by tabemann — Sat Aug 31, 2024 11:13 pm



Viewing all articles
Browse latest Browse all 5973

Trending Articles