CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

TMR1H doesn't increment!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
BlueTower



Joined: 23 Oct 2008
Posts: 29

View user's profile Send private message

TMR1H doesn't increment!
PostPosted: Sun Nov 30, 2008 3:01 pm     Reply with quote

I am using PIC18F65J90 and in my code I have:
Quote:

TMR1L = 0x00; // Used for 2 seond clock for RTC
TMR1H = 0x00; // External 32.768KHz crystal
T1CON = 0x4F;

while(!(TMR1H & 0x10)); // Wait a while for Timer 1 to start
// This is necessary due to bug in processor
// That can cause LCD not to start correctly
// if the timer isnt fully up and running


When pc goes in while condition TMR1L increments since I am using a clock stimulus. When TMR1L overflows there is no increment in TMR1H seen in Watch window. Am I missing something here?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 30, 2008 3:10 pm     Reply with quote

Go to the Timer1 section of the data sheet and read this section:
Quote:
Timer1 16-Bit Read/Write Mode
Ttelmah
Guest







PostPosted: Sun Nov 30, 2008 3:11 pm     Reply with quote

Haven't checked the data sheet for this chip, but it sounds like the 8/16 bit access behaviour. Basically if 16bit access is enabled, TMR1H, will _only_ update, when TMR1L is read. This is done to ensure that both accesses take place in one clock cycle. The debugger probably does not actually trigger the chip to perform a read.

Best Wishes
BlueTower



Joined: 23 Oct 2008
Posts: 29

View user's profile Send private message

PostPosted: Mon Dec 01, 2008 6:08 am     Reply with quote

Thanks my friend. The best way to do it in order debugging to work as well for Timer1 & Timer3 is enable 8 bit read/write and use the get_timer1(), get_timer3() function. This way all 16 bits will be updated!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group