hey sorry need some help on this... been working with timer1 to make leds blink from someone code example in the past. unforunately im a bit stuck
unfortunately the blinks are far too fast.... about 8 to 10x too fast.Code:define OSC 20 TRISA = 0 TRISB = 0 PORTA = 0 PORTB = 0 T1CON = %00110001 ' 0.524ms TMR1IF VAR PIR1.0 ' Overflow bit of Timer1. Output1 VAR PORTB.1 ' Blink 6secs. Output2 VAR PORTB.0 ' Blink 0.5secs. PreLoad VAR WORD TimeCount VAR BYTE TimetoBlink VAR BYTE PreLoad = 0 ' to get 500ms. TMR1H = PreLoad.HighByte TimeCount = 0 TimetoBlink = 12 '12 = 6secs. PAUSE 50 ' OSC to Settle. Start: IF TMR1IF THEN Blink GOTO Start Blink: 'Each int is 0.500 sec. TMR1L = PreLoad.LowByte ' Load the timer with preload value. TMR1H = PreLoad.HighByte TimeCount = TimeCount + 1 ' Count interrupts. Output2 = Output2 ^ 1 ' Toggle fast blinking output. IF TimeCount = TimetoBlink THEN '6Secs ON, 6secs OFF. TimeCount = 0 Output1 = Output1 ^ 1 ENDIF TMR1IF = 0 ' Clear TMR1 int. flag. GOTO Start END
my pic is oscillating at 20mhz so i thought id just use that internal oscialltion. when u choose that oscillator it does Fosc/4 so its at 5mhz. with a word size timer1 i can measure up to 65536 ticks; with a 1:8 prescaler on that only takes about 0.7 seconds or something to complete. how do i get it so it will be 6 seconds? cant change prescaler anymore... and preloader wont make a difference since it only speeds up the cycle. i think anyway
any help on this? thanks




Bookmarks