View Single Post
  #8   Spotlight this post!  
Unread 25-02-2007, 22:58
Dave K.'s Avatar
Dave K. Dave K. is offline
Engineer/Mentor
FRC #0930
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2005
Location: WI
Posts: 91
Dave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to behold
Re: Real time clocks, out of the question?

Quote:
Originally Posted by evan_wilson View Post
Strangely enough, K&R is sitting right here on my bookshelf. Somehow I hadn't remembered "volatile". I'll go reread through the data types/variables stuff again.

Not to seem pestery... but I've once again confused myself in this code. I read through the PIC's datasheet (timer section) and studied up on the registers. On the good side, I now completely understand all the scalers, clocks, and flags, but I could not seem to understand how the high and low byte registers worked/were needed. I don't see how an integer could go past 65,535, so why does the high byte happen to be able to have a value over that?

I also could not find an equivalent for the PR2 register for Timer1. Is that simply not present and do I have to use conventional math to downscale further?

Thanks again for the help.

Timer's 2 & 4 are 8 bit wide timers and have the "PR" registers, the other timers are 16 bit.

Timer 1 is a bit special and can be used for a low power, real time clock function.

Without a specific reference, I'm not sure what you mean about the high byte having a value greater than 65535. My only guess would be that by setting a value to zero, you'll get an effective divide rate of 65536, but I don't immediately see that in the documentation.

The reason that the 16 bit counter is split into two 8 bit registers is that the CPU only operates on data 8 bits at a time. So a 16 bit read/write operation requires two data bus operations to manipulate the 16 bit value.

Does that help or did I miss one or more of the questions?
__________________
--Dave