Shop OBEX P1 Docs P2 Docs Learn Events
Square wave generation — Parallax Forums

Square wave generation

ElkinElkin Posts: 58
edited 2011-10-11 00:27 in Propeller 1
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!

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2011-10-11 00:20
    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 := [COLOR="orange"]512k[/COLOR]*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.
  • ElkinElkin Posts: 58
    edited 2011-10-11 00:27
    That looks good, I figured it was something easy like that. Thanks for your help!
Sign In or Register to comment.