50 MHz Resonator\SX/B
Rsadeika
Posts: 3,837
DEVICE········· SX28, OSCXT2, TURBO, STACKX, OPTIONX
FREQ··········· 4_000_000
LED1 var RC.7
PROGRAM Start
Start:
·low LED1
·pause 4000
·high LED1
end
When the above listing is run with the sx key installed, I get a pause of 4 seconds. When I remove the sx key and run it with the 50MHz resonator, the pause is just a flash, less than a second.
Do I have to be resonator specific, meaning if I use 'freq 4_000_000' in the program, then I have to use a 4 MHz resonator to have the correct time lapse?
Soon, the questions will stop.
FREQ··········· 4_000_000
LED1 var RC.7
PROGRAM Start
Start:
·low LED1
·pause 4000
·high LED1
end
When the above listing is run with the sx key installed, I get a pause of 4 seconds. When I remove the sx key and run it with the 50MHz resonator, the pause is just a flash, less than a second.
Do I have to be resonator specific, meaning if I use 'freq 4_000_000' in the program, then I have to use a 4 MHz resonator to have the correct time lapse?
Soon, the questions will stop.
Comments
If you then put in a 50 Mhz oscillator, then PAUSE has set the delay WAY too short -- as you saw.
The SX doesn't really care what size oscillator you put in. However, the Basic keywords do, if you are going to get accurate timing. I believe you also have to tell the SX-Key what frequency you want IT to give the SX you are programming.
Conclusion: If you want accurate timing, make sure all three settings agree -- your resonator, the FREQ line, and the SX-Key setting. And the above poster is correct -- the SX has an 'internal' 4 Mhz oscillator that doesn't require external components.
If this is true, then changing to FREQ 50_000_000 should make everything work; SX Key or resonator.
Another $0.02.
Bean.
a resonator is always factory-calibrated to the frequency it is specified for, i.e. what is printed on the resonator's body.
When you connect a resonator to the OSC1/OSC2 pins of an SX, the SX-internal oscillator driver supplys the SX functional sections with the clock frequency impacted by the resonator currently hooked up erxternally.
The SK-Key, on the other hand, has a variable clock generator integrated, capable of driving the SX with many different clock frequencies through the OSC1 pin.
In SX Assembly language, the FREQ directive defines the frequency, SX-Key shall generate and feed into the SX under test. By no means, can this directive "tell" the SX which clock frequency it shall use when running stand-alone. IOW, always make sure that the FREQ directive specifies the same frequency (i.e. the resonator's frequency) you will be using in a stand-alone system.
In SX/B-generated programs, this becomes even more important as SX/B takes the information specified by the FREQ directive (in the SX/B program) to calculate the loop counts required for various time-sensitive incstructions, where PAUSE is just one of them. In an Assembly program, you would have to make all these time calculations manually which SX/B nicely does for you. As you will notice, the Assembly output generated by SX/B also conatains the same FREQU directive it has found in the SX/B program in order to set the SX-Key clock generator to the desired frequency.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G