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

SX Frequency selection

Alex41Alex41 Posts: 112
edited 2007-07-17 22:08 in General Discussion
I did purchase the SX Tech kit and have been playing with it a bit.
I am confused a bit on how to set the frequency of the chip itself. I understand about setting it at the beginning of the program such as

FREQ···· 4_000_000

I understand this sets the operation of the SX at 4 Mhz.

Can I set it at 3_000_000 if I wanted to?

I'm running SX/B and would like to stay with that for now.

I do know I need the external oscillators to get higher frequencies. My understanding is that the external oscillators are more accurate than the oscillator on the SX chip itself. Can I install an external one and still run the chip at 4Mhz as an example?

I need to run the SX as I need to output a stable frequency and the Stamp is not too well suited for this. I would like it to be as accurate as possible, but don't need to go overboard. At this point I believe 4Mhz would be accurate enough, faster would work too, but be more involved as the Pause commands would need to be much longer - above the range of the word variables. I know this is all doable, just like to keep it as simple as possible.

I've·looked in·the books on the SX, but to me it is not too clear about all this as the books focus on Assembly language with the exception being the SX/B help file. I hear a new book on SX/B is coming out soon.

I have the Basic Stamp Homework board also and have gone through that book and most of the experiments.

Thanks for any help,
Alex

Comments

  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-07-16 18:06
    The FREQ command tells the SX/B compiler what frequency to use for its timing calculations. It does not actually set the timing of the SX clock. If you have a very fast interrupt occurring at such a high rate that 1/4 of all your clock cycles were spent in the ISR, then it might be appropriate to set the FREQ to 3_000_000 while running with a 4MHz clock.

    In general you will want FREQ to match you clock rate or, as in the interrupt case above, your effective clock rate. However, it does not set it.
    Alex41 said...
    My understanding is that the external oscillators are more accurate than the oscillator on the SX chip itself.
    Correct.
    Alex41 said...
    Can I install an external one and still run the chip at 4Mhz as an example?
    Yes. You can run it at other frequencies, even odd ones, as determined by the clock source you connect to it.

    The SX48 has two internal timers that are great for generating stable frequencies. At only $10 for an SX48 protoboard you should definitely consider one!

    - Sparks
  • Alex41Alex41 Posts: 112
    edited 2007-07-16 19:17
    Sparks,

    Thanks for the info.

    Right now 4Mhz seems to be fast enough for what I am doing. I'm making a pretty slow frequency - around 200 Hz. The internal clock of the SX has an error of +/- 8%. I'd like to reduce that if I can. It works out to be about·+/- 16 hz at 200Hz. Closer than that would be better.

    The two oscillators that come with the SX are set at their own speeds? If I plug one in, can I still set the Freq command at 4Mhz? Or must the chip run at their speeds? Or am I confusing chip and clock speeds?

    I'm asking before I try so I don't smoke something.

    Good idea on the SX48 board. I'll try a couple of options on the SX28 first, if those don't work I'll look into the SX48 board.

    Alex

    ·
  • RsadeikaRsadeika Posts: 3,847
    edited 2007-07-16 19:55
    The two oscillators that came with the kit are a 4MHz and a 50MHz. So, when you plug in the 4MHz, you set your program for freq 4_000_000, and so on. These are not variable oscillators, meaning you can not plug in the 50MHz and set your freq 4_000_000, and expect the program to run, it would have to be set at freq 50_000_000.
  • Alex41Alex41 Posts: 112
    edited 2007-07-16 20:13
    Without the oscillators installed the chip itself is doing the timing correct? Or is there an oscillator on the SX Key?
    Right now I'm running the SX with the SX Key plugged in to use the DEBUG feature to read my variables.

    Any problems running the SX with an oscillator and the SX Key connected at the same time?

    I assume the 4Mhz external oscillator would be much more accurate than·the SX chips internal clock?

    Thanks for the help,
    Alex
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-07-16 20:19
    You can have a crystal in circuit with the SX-Key/Blitz plugged in, but you cannot·skull.gif have·one of those·external oscillators in circuit at the same time.

    The "internal osc" is basically, I believe, an R-C arrangement and hence the variation/inaccuracy.

    The Key provides the timing in Debug mode.
  • RsadeikaRsadeika Posts: 3,847
    edited 2007-07-16 20:24
    I believe that if you leave the external oscillator plugged in, you will have a problem with the debug function. In order for debug to work properly you have to remove the oscillator. I guess it is good practice to remove the oscillator when you are using the SX-key.
  • Alex41Alex41 Posts: 112
    edited 2007-07-16 20:45
    OK, thanks for the info, but I'm confused at the same time.

    PJ,

    What sort of oscillator came with the SX? is it a crystal or an external oscillator?·I assume its an external oscillator?

    You say I can't use one of them with the SX Key in debug mode?

    So can I program the SX with the oscillator installed?



    Alex
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-07-16 21:01
    You can program a chip, but you can't use DEBUG with the resonator installed

    Post Edited (Capt. Quirk) : 7/16/2007 9:06:36 PM GMT
  • Alex41Alex41 Posts: 112
    edited 2007-07-16 21:02
    Or should I call the ones that came with the SX resonators?
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-07-16 22:00
    Some external clock sources can cause damage if installed while programming. If in doubt, take them out!

    The little blue items with three pins are resonators. You may leave them installed when you program the SX. However, when they are in place they prevent the DEBUG feature from being able to control the program execution since they provide a clock signal. When an external clock source is connected, the SX runs at that clock speed. For you this will be 4MHz or 50MHz depending on the resonator you select.

    The SX-Key has internal clock driver circuitry that can drive your SX at whatever (within reason) frequency you desire. I believe it is about as accurate as the resonators themselves.

    I sounds like you should do your programming with the SX-Key in place using a 4MHz clock. Use OSCXT2 instead of OSC4MHZ and set your FREQ to 4_000_000.

    When you are happy with the functionality of your SX design, you can program (CTRL-P) the SX and then replace the SX-Key with the 4MHz resonator. If all goes well your circuit should then run on its own without a computer connection!

    - Sparks
  • Alex41Alex41 Posts: 112
    edited 2007-07-17 22:08
    Sparks,

    Thanks for the help. This will get me pointed in the right direction. I wanted to get some advice before I accidently blow something up.

    Alex
Sign In or Register to comment.