Welcome to the Parallax Discussion Forums, sign-up to participate.

Shifting registers

Posts: 21
I'm trying to understand the register shifting used in counter examples.
```''Demonstration of NCO counter mode (%00100)
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
PUB NCO_single_ended_mode
' mode PLL BPIN APIN
ctra := %00100_000 << 23 + 1 << 9 + 0 'Establish mode and APIN (BPIN is ignored)
frqa := \$8000_0000 'Set FRQA so PHSA[31] toggles every clock
dira[0] := 1 'Set APIN to output
repeat 'infinite loop, so counter continues to run
```

What is the
<< 9 + 0
about? If there is any more sifting of the registrar then the CTRMODE would not line up.
If I wanted to designate PIN 5 as APIN, and PIN 12 as BPIN, what would the shift command look like?

Side note. I wish the preview for this discussion would work so that knew how it will look before submitting.

• Posts: 21
I did spend some time reading the Prop manual and looking at examples, but I'm still not comprehending.
If someone could point to some reading material I would much appreciate it.
Thanks.
• Posts: 10,965
Welcome to the forums! Here is some reading for the counters.

Infernal Machine
• Posts: 10,965
https://www.parallax.com/product/32305
Infernal Machine
• Posts: 1,981
```ctra := %00100_000 << 23 + 1 << 9 + 0
```

There are 3 components being combined together,
%00100_000 << 23 ' counter mode and plldiv
1 << 9 ' Bpin is 1
0 ' Apin is 0

+ is being used to combine them (ORing is more normal, but the effect is the same as the
bitfields do not overlap so no carrying can happen).
• Posts: 21
Thanks, Mark.

• Posts: 21
Thanks, Publison.
• Posts: 21
Using the same counter mode %00100.
If I wanted to designate PIN 5 (on the Propeller chip) as APIN, and PIN 12 (on the Propeller chip) as BPIN, what would the shift command look like?
• Posts: 1,981
```CON
Apin = 5
Bpin = 12

...
...

ctra := %00100_000 << 23 + Bpin << 9 +Apin
```
• Posts: 21
Thanks. This helps a lot.