PDA

View Full Version : Square wave generation



Elkin
10-11-2011, 07:02 AM
I am pretty sure this is possible but I just cant seem to figure out how to do it.

I am trying to generate a 512 kHz square wave signal. My prop is running at 80 MHz and I have read appnote001 that I also attached here, but I cant seem to get any output from any pin on the propeller. I am trying to run a transistor which is driving a PAL system clock.

My guess is that it has something to do with this PLLDIV and the cog counters but I am just not sure how to put this together.

Thanks!

kuroneko
10-11-2011, 07:20 AM
Let's settle for an NCO. See if this works for you.

CON
_clkmode = XTAL1|PLL16X
_xinfreq = 5_000_000

CON
pin = 16

PUB null

dira[pin]~~
ctra := constant(%0_00100_000 << 23 | pin) ' NCO
frqa := $01A36E2E

' frqx := 512k*2^32/clkfreq

waitpne(0, 0, 0)

DAT
Note that this doesn't quite generate 512kHz but it looks close enough to me (511999.987Hz). Using frqa := $01A36E2F would give you 512000.005Hz.

Elkin
10-11-2011, 07:27 AM
That looks good, I figured it was something easy like that. Thanks for your help!