PDA

View Full Version : Help! AVR help


david_dewit
May 01, 2008, 02:20 AM
My IR rx project does not work, maybe it has something to do with oscillator calibration? If someone can make sense of the following comment could you please help. Using Tiny45 avr.

TIA

Dave

.ORG $0030
RESET:
in Dummy1, OscCal ; Change the OscCal value to make int-osc
inc Dummy1 ; run at 1Mhz. This will be removed once
inc Dummy1 ; the new self callibrating RX routine is
Out OscCal, Dummy1 ; done. For now you have to measure OSC
; at 3.6 volts and work out a value for it
; manually

ldi Dummy1, Low(RAMEND) ; Set up the Stack Pointer
out SPL, Dummy1
ldi Dummy1, High(RAMEND)
out SPH, Dummy1

rcall MAIN_INIT ; call main initilaise routine to set up
; all input/output pins timers, interrupts
; ect.

jeffs555
May 01, 2008, 03:31 AM
Don't know what accuracy you need, but without calibration the oscillator is only +/-10%. The comments imply that 10% is not close enough so you would have to measure the clock frequency and change the vaue written to OscCal to adjust the frequency.

To do that you would have to either change the fuse to output the clock on the CLKO pin or else write test code to output a pin at a fixed frequency. Then you would need equipment to measure the frequency to the desired accuracy.

Another option is to feed a fixed frequency into an input pin and write a routine to time that input and adjust OscCal until the input timer gets the right value. That is what a self-calibrating routine would do. It would take some known time in the IR input waveform and calibrate to that.