Shop OBEX P1 Docs P2 Docs Learn Events
Timers and clocks - help for the hard of thinking. — Parallax Forums

Timers and clocks - help for the hard of thinking.

HughHugh Posts: 362
edited 2015-01-08 12:58 in Propeller 1
I'm afraid this is one of these posts where I think I am thick!

Using the code:
[B]CON[/B]

'  [B]_clkmode = xtal1 + pll16x[/B]                             ' use crystal x 16
'  [B]_xinfreq [/B]= 5_000_000                                  ' 5 MHz crystal (sys clock = 80 MHz)
          
[B]PUB [/B]Blink

[B]dira[/B][16]~~
[B]outa[/B][16]~
[B]repeat[/B]
  ![B]outa[/B][16]  
  [B]waitcnt[/B]([B]cnt[/B]+80_000_000)

an LED on pin 16 blinks on and off like a lighthouse - one second on, one second off, etc, If I uncomment the statements in the CON block it doesn't work at all. Does this mean my crystal is suspect?
[B]PUB [/B]Blink

[B]dira[/B][16]~~
[B]outa[/B][16]~
[B]repeat[/B]
  ![B]outa[/B][16]  
  [B]waitcnt[/B]([B]cnt[/B]+1000)

seems to give a frequency of about 5 kHz ('scoped at 4 divisions at 50 µs per division) which seems very slow.

Do I carry on with this board or consider it suspect and get hold of a new one?

Thanks
Hugh

Comments

  • PublisonPublison Posts: 12,366
    edited 2015-01-08 08:21
    Which board are you using?

    The code should work.

    Sounds like the PLL is not working?

    Works fine on a QuickStart.
  • HughHugh Posts: 362
    edited 2015-01-08 08:41
    Its a non-USB protoboard. Maybe I need to get another...
  • PublisonPublison Posts: 12,366
    edited 2015-01-08 08:44
    Hugh wrote: »
    Its a non-USB protoboard. Maybe I need to get another...

    The Xtal is swap-able. Do you have another Xtal you can try?
  • HughHugh Posts: 362
    edited 2015-01-08 10:21
    Good call.

    A new xtal hasn't changed things... :-(
  • StefanL38StefanL38 Posts: 2,292
    edited 2015-01-08 12:22
    WaitCnt(cnt + 80_000_000 means wait until 80 Million ticks are counted.

    with
    _clkmode = xtal1 + pll16x ' use crystal x 16
    _xinfreq = 5_000_000

    80 Mio ticks are counted up in one second

    without

    _clkmode = xtal1 + pll16x ' use crystal x 16
    _xinfreq = 5_000_000

    the propellerchip runs on a lower frequency.
    I haven't tested this yet but coding NO clkmode and no xinfreq may leave the prop undefined

    did you try any other clkmodes like rcslow rcfast?

    best regards

    Stefan
  • HughHugh Posts: 362
    edited 2015-01-08 12:52
    Hi,

    Using rcfast (which should be the default(?)) with a waitcnt of 12_000_000 gives the expected one second delay.

    All a bit odd. I needed an excuse to get a new board...

    Hugh
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-01-08 12:58
    Keep in mind that RC modes can have some drift. On downloading (which happens in RC mode), the Propeller actually measures an incoming bit to calibrate itself for the speed it's running; this is necessary for clean serial coms.
Sign In or Register to comment.