Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18F452 8Bit Timers.

Status
Not open for further replies.

lord loh.

Member
I would like to use timer3 in the PIC 18F452 as an 8bit timer. I cleared the RD16 of the T3CON register.

The datasheet says
datasheet said:
bit 7 RD16: 16-bit Read/Write Mode Enable bit
1 = Enables register Read/Write of Timer3 in one 16-bit operation
0 = Enables register Read/Write of Timer3 in two 8-bit operations

So it looks like I cannot assume that clearing this bit will let me work with this timer as an 8 bit timer such that an interrupt is generated when the 8th bit overflows. Am I correct? How do I use the timer 3 as an 8 bit timer? Is it possible at all?

Please help
 
lord loh. said:
So it looks like I cannot assume that clearing this bit will let me work with this timer as an 8 bit timer such that an interrupt is generated when the 8th bit overflows. Am I correct? How do I use the timer 3 as an 8 bit timer? Is it possible at all?
No, not at all. You configure it as an 8 bit tmr you get interrupts when the count reaches 255 plus one. RD16 will not configure it as an 8-bit tmr. TMR3 cannot be configured as an 8-bit timer at all. Only TMR0 can be reconfigured as an 8-bit or 16-bit timer.

RD16 is in regards to reading or writing the counter with code, which is an odd thing to do but still legitimate. If the timer is running and for some odd reason you want to read the reg as it's counting, you might be in 16 bit mode and read the lower byte first at 254, store it somewhere, then read the upper byte but the timer's counted up enough to roll over the lower byte so you get 0x01 FE instead of 0x00FE or 0x0100. RD16 is a solution for that problem alone.
 
Last edited:
lord loh. said:
So is this feature planted there for some compatability or what?

Why would anyone use 2 8bit operations?:rolleyes:

If RD16=1 then you can't read TIMER3 high byte directly. You have to read TIMER3L to latch TIMER3 high byte to TIMER3H. Then you read TIMER3H.

RD16=0 is used when your program needs to read only the high byte of TIMER3. It's like having an 8-bit timer with a 1:256 prescale.

Anyway, going back to your question. I assume you need an 8-bit timer is because you need the timer to overflow at a faster rate than 16-bits.

Using timer1 or timer3 like timer0 is a throwback to the days when timer0 was the only timer on PIC16C5X. Microchip added timer1 and later timer3 with the intention of providing a better timer.

The proper way to use timer1 or timer3 is to use it with the CCPx modules. Setup the CCPx module as "trigger special event" mode. If you need an 8-bit timer, initialize CCPRxH with 0 and the 8-bit value to CCPRxL.

 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top