Powering and Resetting Timers
So far programs in this project have been aimed at a specific timer and purpose. At this point I want to shift to a more generalized approach.
To clarify powering a timer consists of turning on the clock to the timer using a bit in either the APB1ENR or APB2ENR registers.
Resetting a timer consist of setting and resetting a bit in the APB1RSTR or APB2RSTR
The attached program TimOnOff.js implements these functions.
If a timer is off and attempts to write to the timer registers, they return zero values when read back. The program loops thru timers 1 to 14 and reports if the timer is on, it then turns on the timer and resets it. It reports if the timer is enabled and then disables the timer.
It write a unique value to the timer’s CNT counter register and reads it back.
If the program is run after a fresh power up of the board reports timers 1 thru 8 as off and is able to write and read the CNT register. A subsequent run of the program without a hard reset reports timers 1 thru 8 as on.
Timers 9, 10, and 11 have been omitted from the disable, write CNT as doing so crashes the Espruino board. The CNT read produces non-zero values. These timers do not report a power on. Additionally if the isTimerEnabled function uses a peek16 command the value returned in bit 0 is different than when a peek32 command is used.
Timers 12, 13, and 14 do not seem to be present on the Espruino board.
One of the difficulties is that the RM0008 Reference manual is written to cover a range of ARM chips with different sets of capabilities.
From the experimental evidence confining future progress should be aimed at timers 1 through 8.
Output of TimOnOff.js
Timer 0 out of bounds 1..14
Timer 0 out of bounds 1..14
Timer 0 out of bounds 1..14
Timer 0 out of bounds 1..14
Timer 0 out of bounds 1..14
Timer 0 out of bounds 1..14
Timer 0 out of bounds 1..14
0
Timer 0 out of bounds 1..14
1 is off
Timer 1 Disabled
ff01
1 is on
2 is off
Timer 2 Disabled
ff02
2 is on
3 is off
Timer 3 Disabled
ff03
3 is on
4 is off
Timer 4 Disabled
ff04
4 is on
5 is off
Timer 5 Disabled
ff05
5 is on
6 is off
Timer 6 Disabled
ff06
6 is on
7 is off
Timer 7 Disabled
ff07
7 is on
8 is off
Timer 8 Disabled
ff08
8 is on
9 is off
Timer 9 Enabled
14c2409
9 is off
10 is off
Timer 10 Enabled
1502409
10 is off
11 is off
Timer 11 Enabled
1542409
11 is off
12 is off
Timer 12 Disabled
0
12 is off
13 is off
Timer 13 Disabled
0
13 is off
14 is off
Timer 14 Disabled
0
14 is off
Timer 15 out of bounds 1..14
Timer 15 out of bounds 1..14
Timer 15 out of bounds 1..14
Timer 15 out of bounds 1..14
Timer 15 out of bounds 1..14
Timer 15 out of bounds 1..14
Timer 15 out of bounds 1..14
0
Timer 15 out of bounds 1..14
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Powering and Resetting Timers
So far programs in this project have been aimed at a specific timer and purpose. At this point I want to shift to a more generalized approach.
To clarify powering a timer consists of turning on the clock to the timer using a bit in either the APB1ENR or APB2ENR registers.
Resetting a timer consist of setting and resetting a bit in the APB1RSTR or APB2RSTR
The attached program TimOnOff.js implements these functions.
If a timer is off and attempts to write to the timer registers, they return zero values when read back. The program loops thru timers 1 to 14 and reports if the timer is on, it then turns on the timer and resets it. It reports if the timer is enabled and then disables the timer.
It write a unique value to the timer’s CNT counter register and reads it back.
If the program is run after a fresh power up of the board reports timers 1 thru 8 as off and is able to write and read the CNT register. A subsequent run of the program without a hard reset reports timers 1 thru 8 as on.
Timers 9, 10, and 11 have been omitted from the disable, write CNT as doing so crashes the Espruino board. The CNT read produces non-zero values. These timers do not report a power on. Additionally if the isTimerEnabled function uses a peek16 command the value returned in bit 0 is different than when a peek32 command is used.
Timers 12, 13, and 14 do not seem to be present on the Espruino board.
One of the difficulties is that the RM0008 Reference manual is written to cover a range of ARM chips with different sets of capabilities.
From the experimental evidence confining future progress should be aimed at timers 1 through 8.
Output of TimOnOff.js
1 Attachment