Hi,
I'm trying to get a circuit I have to save on battery power by sleeping for most of the time. Having read through as much as my head would take of interrupts, timers, sleep modes etc I'm starting to cloud over. I did have timer0 running earlier, creating an interrupt and pulsing a blue LED. I'm now trying to get timer1 to do the same thing, although just getting it to say 'interrupt' on the serial port within the interrupt routine. However, I can't get it to enable. I've even looked at TMR1L/H and they are not incrementing at all!
Going nuts here!!! Can anyone PLEASE take a look at my code (have removed the majority of crap to simplify it for anyone who has the time/inclination...
My eventual aim is to incorporate this code into my already working code for writing I2C sensor data to SD card to allow data capture over several days/weeks from a single battery - note the commented out PMD variables where I was attempting to disable as many peripherals as possible.
Any clues/hints greatly appreciated.
Best regards all, and happy guy fawkes!
Jimbo
Code:define OSC 16 DEFINE HSER_BAUD 19200 DEFINE HSER_CLROERR 1 ' Auto clear over-run errors DEFINE HSER_RCSTA 90h DEFINE HSER_TXSTA 20h blue_LED var portb.5 trisa = %00000000 trisd = %00000000 trisc = %00000000 trisb = %00001000 adcon0.0 = 0 ANSELA = 0 ANSELB = 0 ANSELC = 0 ANSELD = 0 ANSELE = 0 ADCON1 = 15 tmp1 var byte tmp2 var byte p1 var byte p2 var byte p3 var byte seconds var byte pausetime var byte OSCCON = OSCCON | %11110000 ' set internal clock to 16 MHz incase of switchover On Interrupt Goto myint 'PMD0 = %11111110 'PMD1 = %11111111 'PMD2 = %11111111 pause 4000 IPR1.0 = 1 INTCON = %11000000 ' global int enable, T1CON.7 = 1 ' timer 1 clock source is oscillator (external xtal) YES T1CON.6 = 0 ' """""""""""""""""""""""""""""""""""""""""""""""""" YES T1CON.5 = 0 ' prescale value set to 1:1 YES T1CON.4 = 0 ' """"""""""""""""""""""""" YES TMR1H = $ff TMR1L = 0 T1CON.2 = 1 ' do not synchronise external clock input with system clock YES T1CON.1 = 0 ' 8 bit timer? T1CON.0 = 1 ' enable timer 1 T1CON.3 = 1 ' secondary (external) oscillator enable bit YES TMR1H = 0 ' Clear time counts before Timer1 re-start TMR1L = 0 ' Clear time counts before Timer1 re-start PIR1.0 = 0 ' Clear over-flow flag before enable PIE3.0 = 1 PIE1.0 = 1 ' timer 1 enable interrupt lp3: high blue_LED p2 = TMR1L hserout[$d,$a,#p2] pause 50 low blue_LED pause 50 goto lp3 Disable myint: high blue_LED pause 50 low blue_led hserout[$d,$a,"Interrupt!"] PIR1.0 = 0 Resume Enable




Bookmarks