Shop OBEX P1 Docs P2 Docs Learn Events
Frequency — Parallax Forums

Frequency

CenlasoftCenlasoft Posts: 265
edited 2008-11-25 19:15 in General Discussion
Hello,
I was told that I cannot produce a 1 mhz square wave on a BSII. I have the sx28 kit and I was wondering if I could produce a 1 mhz square wave with it using a 50 mhz resonator? Would I used PWM? Any samples would help (circuit and code).
Thanks,
Curtis

Comments

  • BeanBean Posts: 8,129
    edited 2008-11-25 16:12
    Assuming you want a continuous 1MHz output use this (you can use any pin I just used RA.0):

    DEVICE SX28,OSCHS2,TURBO,OPTIONX,STACKX
    FREQ 50_000_000, 34_000_000
     
    OutPin  PIN RA.0 OUTPUT
     
    INTERRUPT NOCODE 2_000_000
      OutPin = ~OutPin
    RETURNINT
     
    PROGRAM Start
     
    Start:
    END
    
    

    Just make the interrupt rate twice the desired frequency.

    Note that since this is done in the interrupt, you can have other code running at the same time.

    Bean

    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    "The welfare of the people in particular has always been the alibi of tyrants." ~ Camus
    www.iElectronicDesigns.com



    Post Edited (Bean (Hitt Consulting)) : 11/25/2008 6:30:09 PM GMT
  • CenlasoftCenlasoft Posts: 265
    edited 2008-11-25 19:15
    Thanks,
    It looks easy.
    Curtis
Sign In or Register to comment.