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.

pic18f4431 timer1 problem

Status
Not open for further replies.

gehan_s

Member level 3
Joined
Aug 31, 2012
Messages
62
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
Sri Lanka
Activity points
1,799
Hi all,

I want to use the timer1 of the PIC18f4431 to increment every instruction cycle. I wrote a function to do this and simulated using pic18 simulator IDE but I am not seeing the TMRL register increment. Please take a look at my code and correct me.

Code:
void timer1_init(){

     T1CON.RD16    = 0;          // enable register read/write of TIMER1 in two 8-bit operations
     T1CON.T1RUN   = 0;          // system clock is derived from another source
     T1CON.T1CKPS1 = 0;          // ##increments with 1:1 prescale value
     T1CON.T1CKPS0 = 0;          // ##
     T1CON.T1OSCEN = 0;          // TIMER1 oscillator is shut-off
     T1CON.TMR1CS  = 0;          // enable TIMER1
     T1CON.TMR1ON  = 1;          // TIMER1 uses internal clock (FOSC/4)
     TMR1L         = 0;          // clear TIMER1 lower register

}

Regards
 
Last edited:

ur Timer Initialize correctly. Check other register such as Crystal freq. etc. r u using interrupt if no then use to check for Timer1 operation. If work then it must go to ISR location.
 

Hi Golden Electronics and thank you for your reply !!!!!!!!!!!

If I do not initalize the interrupts and the only bit of code that I have is this function, then won't the TMR1 register increment ? I am refering to something like this,

Code:
void main(){

T1CON.RD16    = 0;          
     T1CON.T1RUN   = 0;          
     T1CON.T1CKPS1 = 0;          
     T1CON.T1CKPS0 = 0;          
     T1CON.T1OSCEN = 0;         
     T1CON.TMR1CS  = 0;          
     T1CON.TMR1ON  = 1;         
     TMR1L         = 0;        


while(1){

}
}
 

Start timer after assignning values to timer related registers.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top