Apin with the counter modules
I'm playing around with the counter module and there seems to be a discrepancy between the data sheet is telling me and what I am experiencing. Pretty much I can only set Apin to be zero or a multiple of four. If I try to set it to some other pin, that pin puts out no signal. What am I missing? I have tried doing this by specifying the apin in a long that I copy to ctra and also by using movs to get the pin into ctra but neither works. I have tried this on the Professional development board and also the Propeller demo board so it shouldn't be something with my processor.
Here is the code that I am using:
Here is the code that I am using:
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
var
long temp
pub start
cognew(@counterStart, 0)
repeat
temp := 0
dat
org
counterStart
mov dira,IOpins
mov ctra,ctraData
movs ctra,#8
mov frqa,frqaData
jPoint nop
jmp #jPoint
IOpins long $11111111 ' make all pins be outputs
' It seems like Apin can only be zero or a multiple of four.
' Set up the peripheral into NCO/PWM single-ended mode
ctraData long %00010000000000000000000000000000
frqaData long $40000000
fit 496

Comments
mov tempa,ctraData2 shl tempa, #23 mov tempb,#1 shl tempb,#9 add tempa,tempb add tempa,#0 ' this is the pin number mov ctra,tempa ... later in the program: ctraData2 long %00100000which should be the equivalent to the spin command:
With Spin I can set the pin to whatever I want but I would really rather not waste a whole cog on this. I would rather set up the counter at the beginning of another assembly language program and forget about it.
-Phil
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
·
And you can use constants from a CON section in PASM for the pin number.
Then your code will look like this:
CON _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 OutPin = 3 VAR long temp PUB start cognew(@counterStart, 0) repeat temp := 0 DAT org counterStart mov dira,PinMask mov ctra,ctraData mov frqa,frqaData jPoint jmp #jPoint PinMask long 1 << OutPin ctraData long %00100_000 << 23 + 1 << 9 + OutPin frqaData long $40000000But your versions will also work if you set the right pins as output(s).
Andy
-Jack
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
www.tdswieter.com
The ringing was shooting a good volt above and below my power rails.
-Phil
Here is how it looked before the series resistor:
And here it is afterwards;
It still isn't perfect but looks better to me. Probably both are really fine for my application but I am driving the clock to an A/D so I was worried about the over and under shoot adding noise to my data.
I should say that I am overclocking this propeller to 100MHz rather than 80MHz. I'm not sure if that really matters since I am only having the counter run at 25MHz so the output driver isn't being pushed faster than it is spec'd for. Also, looking at my own picture, I see that at least as I was measuring it there, it was only ringing about .75V above and about .6V below the rails but still....
-Jack
·http://forums.parallax.com/showthread.php?p=885691
Jim