Using CTRA and CTRB
In Spin, CTRx can be read/written just like any other register or pre-defined variable. As soon as this register is written, the new operating mode goes into effect for the counter. For example:
CTRA := %00100 << 26
The above code sets CTRA's CTRMODE field to the NCO mode (%00100) and all other bits to zero.
Counter Modes (CTRMODE Field Values)
CTRMODE | Description | Accumulate | APIN | BPIN |
%00000 | Counter disabled (off) | 0 (never) | 0 (none) | 0 (none) |
%00001 | PLL internal (video mode) | 1 (always) | 0 | 0 |
%00100 | NCO single-ended | 1 | PHSx[31] | 0 |
%00110 | DUTY single-ended | 1 | PHSx-Carry | 0 |
%01000 | POS detector | A1 | 0 | 0 |
%01100 | NEG detector | !A1 | 0 | 0 |
%10000 | LOGIC never | 0 | 0 | 0 |
*Must set corresponding DIR bit to affect pin
A1 = APIN input delayed by 1 clock
A2 = APIN input delayed by 2 clocks
B1 = BPIN input delayed by 1 clock|
Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.