Clocking mystery

Putting together a circuit using the PropStickUSB it suddenly started behaving very strange. The code that ran and executed fine yesterday, does not execute today. To see if the P was still operational, I added code (from Examples to be sure) to switch on P0 powering a LED. Did not light up - but if I load the naked blinker code only, it blinks. After some more variant tests it appears that the code works only when there is no 5 MHz parameterization.

Does not work:
CON

          _clkmode = xtal1 + pll16x
          _xinfreq = 5_000_000                                      'use 5MHz crystal
        
          clk_freq = (_clkmode >> 6) * _xinfreq                     'system freq as a constant
          mSec     = clk_freq / 1_000                               'ticks in 1ms
          uSec     = clk_freq / 1_000_000                           'ticks in 1us     (80 ticks)

PUB Toggle
  dira[0]~~
  repeat
    !outa[0]
    waitcnt(3_000_000 + cnt)

Does work:
PUB Toggle
  dira[0]~~
  repeat
    !outa[0]
    waitcnt(3_000_000 + cnt)

Beats me. Have I burned the crystal maybe? I seem to be in a blue smoke period.
Is there a 'examine yourself and report' piece of code somewhere?

Erlend
21st century - when everything changes
"Better with a DAT and a COG than with a CAT and a DOG"

Comments

Sign In or Register to comment.