chimera786
Member level 2
- Joined
- Jun 16, 2011
- Messages
- 42
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Activity points
- 1,710
Hey there!
This is my first time messing with the 18F series. This uC is definitely powerful.. in fact an overkill for the applications that I have been/am developing.
So, I decided to baby step this uC just because the datasheet is long and had way too many jam packed features.
I have been trying to get the TMRO to work with a simple PORTB toggle. But it doesn't seem to be working. I have looked high and low thru the datasheet but it doesn't look like im missing anything
I am probing the output of PORTB with a o-scope but the thing is that I am getting a constant square wave of 490Hz.
Basically, the timer0 is expiring at the wrong interval, rather than expiring at the freq i want it to
Please take a look at it guys-- its so simple that i cant find it..maybe Ive overlooked something.. maybe im not configuring some registers correctly..
This is my first time messing with the 18F series. This uC is definitely powerful.. in fact an overkill for the applications that I have been/am developing.
So, I decided to baby step this uC just because the datasheet is long and had way too many jam packed features.
I have been trying to get the TMRO to work with a simple PORTB toggle. But it doesn't seem to be working. I have looked high and low thru the datasheet but it doesn't look like im missing anything
I am probing the output of PORTB with a o-scope but the thing is that I am getting a constant square wave of 490Hz.
Basically, the timer0 is expiring at the wrong interval, rather than expiring at the freq i want it to
Please take a look at it guys-- its so simple that i cant find it..maybe Ive overlooked something.. maybe im not configuring some registers correctly..
Code:
void main() {
OSCTUNE=0x00;
OSCCON=0xCE;// oscillator at 1Mhz
ADCON1=0xFF;// Make sure pins are IOs
INTCON=0xA0;// Global + TMR0 interrupt ON
T0CON=0xC8;// Configure TMR0 as 8bit no prescale
TMR0L=100;
TRISB=0x00;// PORTB as OUTPUT
PORTB=0;
}
void interrupt (void) {
if (INTCON.B2){
INTCON.B2=0;
PORTB=~PORTB;
}
}
Last edited: