Shop OBEX P1 Docs P2 Docs Learn Events
Sx/b interrupt — Parallax Forums

Sx/b interrupt

SpillerSpiller Posts: 52
edited 2009-12-09 18:15 in General Discussion
Hi All,

I would like to know what is the value range for SX/B INTERUPT Rate?

I know it depends on the frequency on which the SX works.

If the SX works at 4MHz and the rate is 100, the Interrupt will run at every 10ms.
If the SX works at 50MHz and the the rate is 1000, the Interrupt will run at every 1ms.

If like to speed up the Interrupt and write 10000 for rate I got compile error. So what is the value range for rate?

Best Regards

Spiller





·

Comments

  • ZootZoot Posts: 2,227
    edited 2009-11-25 07:13
    The range is very very high... > 1mhz. But it depends on clock frequency. At 20MHZ you can easily do an interrupt rate of 10000.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • SpillerSpiller Posts: 52
    edited 2009-11-25 09:06
    Thanks Zoot,

    I think my probles was that I use old version of SX-Key Editor at home. I have tried it at my office with SX-Key Editor v3.2.92h BETA and I could set ISR rate up to 25_000_000 @ 50_000_000 Hz clock. (Not more due to the RTCC 1:2 prescaler)

    By

    Spiller
  • JonnyMacJonnyMac Posts: 9,211
    edited 2009-11-25 17:28
    Really? 25_000_000? While I did verify that it will compile, you can't do anything practical at that rate -- you'd be tripping the ISR every other clock cycle and it takes 3 clock cycles just to get into the ISR.

    The highest practical ISR rate I've ever used in a program (SX at 50MHz) was 750_000 -- did this to create a receive UART and 8-channel dimmer for a DMX512 project. Of course, you can go higher than that, but you're limited to how much you can accomplish within the ISR. Remember, you have to get in and out and that takes a few cycles on each end.
  • SpillerSpiller Posts: 52
    edited 2009-11-26 09:39
    Hi Jonnymac,

    You are right. We can do anything in this ISR rate, it is the theoretical highest limit. I use rate 100_000 @ 50MHz now.

    Thanks

    Spiller
  • ACE227ACE227 Posts: 15
    edited 2009-12-09 17:22
    I have a question on the interupt.

    I have a clocking project that calls fo a 4MHz crystal with a 1000 interupt rate, but I only have a 50MHz crystal. So how would I change the interupt so the clock will keep time correct?

    Thanks

    Ace227
  • ZootZoot Posts: 2,227
    edited 2009-12-09 17:24
    You don't. Just set the interrupt rate where you want and change the FREQ directive to match your clock/resonator/crystal. The compiler will adjust interrupt values accordingly to get your interrupt rate as close as possible using the given clock freq.

    If the desired interrupt rate is unachievable given the chosen clock freq., the compiler will issue a warning.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • ACE227ACE227 Posts: 15
    edited 2009-12-09 17:48
    Zoot,

    When you say to change the FREQ directive do you mean to put:
    FREQ 50_000_000, 4_000_000

    or do I put:
    FREQ 4_000_000
  • BeanBean Posts: 8,129
    edited 2009-12-09 17:55
    If you are changing from a 4MHz to a 50MHz crystal, you would change "FREQ 4_000_000" to "FREQ 50_000_000".

    You will also have to change the crystal drive on the device line to OSCHS2 or something.

    Also, if you specify INTERRUPT 1000 with a 50MHz clock the interrupt rate will be about 1001.6 since that is what you get with the value allowed.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    1st rule of finance...Don't lose money.
    Never be ashamed of making an honest·profit.
    Live within your means...Make do, or do without.
    ·
  • ZootZoot Posts: 2,227
    edited 2009-12-09 18:04
    What Bean said smile.gif Read the help file under directives -- it explains this very clearly. The SX documentation itself has suggested OSC settings and parallel resistor values for most available resonator, crystal and ttl clock values.

    Reading over the directive documentation (fuse settings) is a must. The fuse bits determine how your SX is actually setup and running (clock freq, brownout, oscillator settings, etc) , and are arguably the most important settings on the device -- the rest is all code and can be changed at runtime.

    Thanks Bean for mentioning the OSC setting, which I neglected.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • ACE227ACE227 Posts: 15
    edited 2009-12-09 18:15
    Thank you Zoot and Bean for your help.
Sign In or Register to comment.