Alright, I give up (for now).
I thought I had timers ALL figured out, but I brought the scope home from work, and it turns out I've got NO idea what I'm doing.
I'm using the following code:
Code:
@ device pic16F648A, intrc_osc_clkout, mclr_off, protect_off, lvp_off, wdt_off
DEFINE OSC 4
TRISB = 0 ' Outputs on
CMCON = 7 ' Turn all comparators to fully digital (needed??)
OPTION_REG = %00000011 'Set prescale to 1:16
TMR0 = 2
INTCON = %10100000 '$A0 enable TMRO interrupt
on interrupt goto clkreset
start:
goto start
clkreset:
disable
PORTB.7=1
PORTB.7=0
TMR0 = 2 'correct timer for missed cycles?
INTCON = %00100000 '$20 Reset interrupt set T0IE, clear T0IF
enable
resume
When I run this code on my PIC 16F648A, I get a frequency of 72Khz on B.7, when my math says that I should be getting ~244Hz. AND to make matters more confusing, when I change the line OPTION_REG = %00000011" to another prescaler value, I don't get any change in the output frequency.
I'm obviously missing something very basic here (like last time where I mixed up TRISB and PORTB commands).
Could someone please save what's left of my hair?
Thanks!
Bookmarks