Shop OBEX P1 Docs P2 Docs Learn Events
Changing Clock Frequencies on the fly... — Parallax Forums

Changing Clock Frequencies on the fly...

Sniper KingSniper King Posts: 221
edited 2008-08-27 21:53 in Propeller 1
Changing Clock Frequencies on the fly...

{{
PIR UDA Sensor.spin, v1.1,Michael King
┌──────────────────────────────────────────┐
│ Copyright (c) 2008 Michael S. King       │               
│ See end of file for terms of use.        │      
└──────────────────────────────────────────┘

 
}}
CON
 

VAR
 
OBJ
        Clock : "Clock"
        Send : "FullDuplexSerial"
        
PUB main
Clock.init(5_000_000)
clock.setclock(RCSLOW)
dira[noparse][[/noparse]16]:=1
repeat
  waitpeq(%0100, %0100, 0)   'Wait port Port 3 to go high
   
  clock.setclock(XTAL1 + PLL16X) 'Set clock to really fast
  waitcnt(1000000+cnt)
  outa[noparse][[/noparse]16]:=1  'PIN High of PWR to switch XTEND module on    
 
  
  
  send.start(31,30,0,9600)  ' start FullDuplexSerial
  clock.pauseMsec(500)   'Wait a bit for the XTEND to be ready
  send.str(string("<*00000001*S*>")) 'Send activation of sensor Message
  clock.pauseMsec(500)   ' Wait for message to be sent
  outa[noparse][[/noparse]16]:=0
  
 
 
 

I set the clock to RCSLOW in the beginning of the program then When the pin 3 goes high it allows the program to continue.· The first thing it does is to set the clock speed to XTAL + PLL16x.· Program execution stops here. Don't Work

<subject line added by Moderator>

Post Edited By Moderator (Paul Baker (Parallax)) : 8/27/2008 8:58:28 PM GMT

Comments

  • cgraceycgracey Posts: 14,133
    edited 2008-08-27 20:12
    You can switch to RCSLOW or RCFAST anytime, but when you switch to an XTAL(+PLL) mode, you need to first turn on the crystal oscillator (and the PLL, if you're going to use it), give·the crystal·10ms to settle (the PLL takes only about 10us), THEN switch over to it. This assumes that the crystal (and PLL) were already off. Otherwise, if the crystal (and PLL) are enabled, you can just switch between any PLL division, OSC input, RCSLOW, or RCFAST mode. Of course, you'll want to turn off the XTAL(+PLL) if you want to save power while in RCFAST or RCSLOW mode. RCSLOW mode takes about 8uA (with BOE on), plus 1.5uA per cog, as the chips runs at ~20KHz. When you want to speed back up, turn on the XTAL (and PLL), wait 10ms, then switch over to them.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • ColeyColey Posts: 1,110
    edited 2008-08-27 20:13
    Michael,

    without seeing your clock object it is difficult to see what could be happening.

    Look at the attached object that shows how to change the clock spped on the fly, I wrote it for autonatically detecting between different gaming platforms.

    Regards,

    Coley

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PropGFX Forums - The home of the Hybrid Development System and PropGFX Lite
  • Sniper KingSniper King Posts: 221
    edited 2008-08-27 21:44
    What is BOE?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·- Ouch, thats not suppose to be hot!··


    Michael King
    Application Engineer
    R&D
    Digital Technology Group
  • cgraceycgracey Posts: 14,133
    edited 2008-08-27 21:51
    Sniper King said...
    What is BOE?

    BOE is Brown-Out Enable. This is 'on' when the BOEn pin = VSS. It keeps the brown-out detector on at a cost of about 4.5uA. If you made BOEn = VDD ('off'), then you could save that much current, but the chip wouldn't reset itself due to a low-voltage condition.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-08-27 21:53
    BOE is Brown Out Enabled. Should be grounded to enable it. I believee shuts down the chip if the voltage gets too low.
Sign In or Register to comment.