Shop OBEX P1 Docs P2 Docs Learn Events
SX Runtime Freq Change — Parallax Forums

SX Runtime Freq Change

william chanwilliam chan Posts: 1,326
edited 2004-09-02 20:40 in General Discussion
Anybody,

Is there a way to change SX oscillation frequencies during runtime without re-downloading?
Let's say the SX is running at 4Mhz to save current consumption, then to perform so difficult tasks,
make itself run at 50Mhz for a short while?

I think it's never been done before...

Thanks.

Comments

  • PJMontyPJMonty Posts: 983
    edited 2004-08-06 17:42
    William,

    The SX has an internal RC oscillator that runs at a nominal 4 MHz. Anything other than that clock is provided by an external oscillator. There is no way to change the SX's clock speed because it has a fixed frequency clock.

    The FREQ directive is there to tell the SX key what speed clock to generate. The idea is that while you are debugging, the SX-Key provides the clock, and it needs to be whatever frequency you will need in the final project. Later, when you are running the SX chip standalone, you provide an external oscillator that runs at whatever speed you had told the SX-Key to run at.

    If you want to do what you are thinking of, you'll need to design a clock circuit that can switch between different speeds. However, that is entirely up to you and your hardware design, and has noting to do with the SX chip itself.

    Thanks,
    PeterM
  • Andrew G. MillerAndrew G. Miller Posts: 14
    edited 2004-08-06 19:05
    Microchip has an App Note which describes using a port/pin to alter the R value of an external R/C oscillator.

    I've never tried this, but you may be able to do something similar on the SX, if you are using an external R/C oscillator circuit.
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2004-08-07 05:31
    Would it be possible to take short SLEEPs to conserve power?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Paul BakerPaul Baker Posts: 6,351
    edited 2004-08-07 18:41
    Yes it is possible, just set yourself to wake up from a watchdog timer, external clock (any digital timing source would work, even a 555 timer would do) coupled to a port B pin configured for MIWU, or cycle the /MCLR pin.

    But the device will behave as though it was just turned on when it wakes up, so youll need to set a bit before sleeping and test it upon waking up to determine if you are turning on or waking up (this method is used to start in the same place each time you wake up), or if you need to reenter where you left off (when you slept or any arbitrary point) you can store the PC of your reentry point and "pop" it when you wake up (SX doesnt give you direct access to the stack, so you'll have to mimic it by writing the stored reentry point into the PC (and page if nessesary), upon startup you have nothing in the stack so doing this will not interfere with expected operation of the stack).

    Andrew's method would work too, just put an EEPOT (AKA Digital Potentiometer) in place of the resistor, but this solution would kill the SX's determinism since it would take some time to scale up or down the frequency (for EEPOTS which only have WIPEUP and WIPEDOWN controls, serial interfaces usually have a SET R=Val command but even here there will be considerable jitter as the SX adjusts to the new frequency). This means if you are doing realtime IO control where you must be able to compare two time events which exist at different frequencies, you will need to add a realtime clock since using SX cycle timing methods will not be accurate.

    This also means that the timing of anything connected to the SX may no-longer work (SPI, I2C, uWire, etc) since the times of the RTCC timer overflows will occur at different rates. There are work arrounds possible by knowing the EEPOT value and calculating the RC time constant and SX cycle time on the fly, but this will complicate the writing of any isr. Or use an external source for your RTCC. If you combined both methods you could generate the wakeup signal using a divide by 2^n circuit of the RTCC clock.

    -Paul

    Post Edited (Coriolis) : 8/7/2004 6:58:39 PM GMT
  • StephenStephen Posts: 53
    edited 2004-08-26 05:29
    It is possible with an external clock circuit. The key point is to ensure that there is no phase shift. I have seen applications using USB node controllers where the clock output from an USBN9603 node controller is used as the CPU clock source. It defaults to 4MHz, but can be configured to other clocks. It maintains it's phase continuity so there is no problem. The SX will attempt to clock from any edge so if there is some phase shift, a is very short clock period could result, much faster than the SX may support, causing lockup or unexpected behaviour.

    In fact, the SX-Key can be used as the runtime clock source. The tools used to provide (maybe they still do, I haven't checked for a while) a slider to adjust the clock at will. It worked but only by maintaining the clock phase continuity.
  • KenMKenM Posts: 657
    edited 2004-08-26 14:31
    Guenthers book describes how to change osc frequency. I think using a PLL. I am getting ready for work now and cannot look it up now. I will post it tonight. Or you could of course buy his book.
    A good value in my opinion
    Stephen said...
    It is possible with an external clock circuit. The key point is to ensure that there is no phase shift. I have seen applications using USB node controllers where the clock output from an USBN9603 node controller is used as the CPU clock source. It defaults to 4MHz, but can be configured to other clocks. It maintains it's phase continuity so there is no problem. The SX will attempt to clock from any edge so if there is some phase shift, a is very short clock period could result, much faster than the SX may support, causing lockup or unexpected behaviour.

    In fact, the SX-Key can be used as the runtime clock source. The tools used to provide (maybe they still do, I haven't checked for a while) a slider to adjust the clock at will. It worked but only by maintaining the clock phase continuity.
  • kevikevtmckevikevtmc Posts: 1
    edited 2004-09-02 20:40
    Try using the I2C DS1077L from www.maxim-ic.com
    You can adjust the clock output to many different frequencies via the I2C bus.
    The trick is to remember what you set the frequency to [noparse];)[/noparse]
Sign In or Register to comment.