Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC18 TIMER1 AND IT'S INTERRUPTS

Status
Not open for further replies.

RandyB

Newbie level 2
Joined
Feb 15, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Iowa
Activity points
1,292
PIC18 TIMER1

I am using a PIC18F24K20 and would like to know how to set up Timer1 and the interrupts. Does someone have an example I can work from?
 

Hi,

In what language - Assembler, C ..?

Are you trying to make a RTC .. ?
 

I am working in C. I would like to use the to have an interrupt every ms.
 

Hi,

Afraid I only do Assembler - have sent you some info by PM that might help.
 

Hi RandyB,
This code is for mikroC(v8.2):
Code:
//mikroC v8.2
//Programmed by Tahmid
//Clock: 20MHz (HS)
//Using TMR1 for interrupt generation every 1ms

void interrupt(){
     PORTC.F0 = ~PORTC.F0; //Toggle RC0
     TMR1H = 0xEC; //Reload Timer
     TMR1L = 0x78;
     PIR1.F0 = 0; //Clear flag
}

void main(void){
     TRISC = 0; //Set PORTC for output
     PORTC = 0;
     INTCON = 0xC0; //Enable GIE and PIE
     PIE1.F0 = 1; //Enable TMR1 interrupt
     T1CON = 1; //Start TMR1
     while (1);
}

Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top