Shop OBEX P1 Docs P2 Docs Learn Events
Internal RC — Parallax Forums

Internal RC

KenMKenM Posts: 657
edited 2004-07-27 08:08 in General Discussion
Hello Group,

I am using the internal RC oscillator for my SX28 project. I realize and understand that the actual frequency will vary due to variables such as temperature and the actual internal RC values.

Two SX's running the same program have significantly different current consumption. One IC is the Ubicom guy, the other is Scenix.

Some time ago I think Guenther had a method to see what the actual frequency was....something about an interupt with a known amount of clock cycles controlling an output pin and measuring the pin with a o-scope.

Any thoughts? Not looking for actual code (although that would be nice) but the concept of how to check the internal RC frequency.

The osc frequency is set to 32 KHZ.

Thank you.

Comments

  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2004-07-25 21:28
    Ken,

    while searching the archived threads, I was successful. Here is the code I had suggested:

    In order to check the clock frequency,·adde the following ISR code:

    · org $000
    isr
    · mov w, ra
    · xor w, #1
    · mov ra, w
    · mov w, #-100
    · retiw

    This simply toggles the RA.0 pin (provided that you configure it as output in the startup section) every 100 clock cycles. When you hook up a scope to RA.0, you can either measure the duration of the port high or low state to figure out the time 100 clock cycles take.

    Let's assume, the clock is 1 MHz, then one clock period is 1µs, so the high or low state should be 100µs, provided that the clock is exactly @ 1 MHz, and vice versa, you can calculate the clock frequency from the duration "d" of the high or low state with f = 100/d.

    Greetings,

    Guenther
  • KenMKenM Posts: 657
    edited 2004-07-25 22:51
    Thank you Guenther......

    Looks like "Legstrong" did it again!

    Ken Mathis
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2004-07-27 08:08
    Another method is a short main loop, also to feed a 'scope or a counter:
    main
    mov !ra,#%0000
    mov w,#%1111
    quick
    xor ra,w
    jmp quick

    In turbo mode, a 4mhz clock will give 2 microsecond period on the ra pins (8 clock periods total, 3 each for the jmp and 1 each for the xor) I f the clock frequency is the unknown, then in turbo mode, clock frequency = portA frequency * 8.

    In standard mode, a 4 mhz clock will give a 6 microsecond period (8 clock periods for each jmp and 4 for each xor). clock frequency = portA frequency * 24.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.