Thanks Jerson....I'll study that later (it's 2.15am here in Lodnon!)
Actually, this looks like it might have some signs of doing what I want...
Code:
'Comparator1 Interrupt handler+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comp1_Int:
@ INT_DISABLE CMP1_INT
Comp1Time.Lowbyte = TMR1L 'puts the timer's low byte in MyTime's lower 8 bits
Comp1Time.Highbyte = TMR1H 'puts the timer's high byte in MyTime's upper 8 bits
TMR1H = 0 'Set the high part of the timer value to 0
TMR1L = 0 'Set the low part of the timer value to 0
@ INT_ENABLE CMP2_INT
'Comp1Time =Comp1Time +4
'dummy = b * c '5,000,000
'frequency = div32 Comp1time
'frequency =frequency/2
'HSEROUT ["mytime = ", dec mytime,9, dec frequency/10,".",dec frequency//10,"Hz",13, 10]
@ INT_RETURN
'Comparator2 Interrupt handler+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comp2_Int:
@ INT_DISABLE CMP2_INT
Comp2Time.Lowbyte = TMR1L 'puts the timer's low byte in MyTime's lower 8 bits
Comp2Time.Highbyte = TMR1H 'puts the timer's high byte in MyTime's upper 8 bits
TMR1H = 0 'Set the high part of the timer value to 0
TMR1L = 0 'Set the low part of the timer value to 0
@ INT_ENABLE CMP1_INT
@ INT_RETURN
What's getting me bogged down is something as simple as setting my config correct for a 20Mhz external resonator. (the first time I've used an external clock)
I'm putting a 1Khz test signal into comparator1 input pin- the handler it's registering 2500 timer1 'counts' between successive compartor1 interrupts - that doesn't seem correct for a 20Mhz external clock?
at 1Khz, the actual physical time between interrupts should be 1ms - & I'm seeiing a count of 2500 for comparator 1 interrupts.....
therefore 1ms divided by 2500 is 0.0000004 seconds ....or in frequency is 2500000Hz (2.5Mhz - that's not 20Mhz???).
here's my settings...
Code:
@ __CONFIG _FCMEN_OFF & _HS_OSC & _WDT_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _BOR_OFF & _PWRTE_OFF
DEFINE OSC 20 ' set Oscillator at 20Mhz.
OSCCON.0 = 0
what am I setting wrong? (I'm using MPASM assembler)
Bookmarks