PIC18F45K80 Timer 0

Status
Not open for further replies.
Hi,

T_max = fixed_prescaler x max_selectable_prescaler x 2^counter_bit_width / fosc

Klaus
 
Hi,

T_max = fixed_prescaler x max_selectable_prescaler x 2^counter_bit_width / fosc

Klaus
Fixed prescaler _ five bit
2^counter_bit_width / fosc =2^8/20 MHz

What would be max_selectable_prescaler?

Is the input frequency 20MHz for Timer 0?
 

Hi,

What would be max_selectable_prescaler?

Is the input frequency 20MHz for Timer 0?
If I needed to know this .. have have to read the datasheet.
But you don´t want me to read the datasheet for you?

Klaus
 

hello,


look at the mikroE tool for Timer

18F timer0 16bits -> maxima is 3355mS with prescaler 1/256
or with an excel sheet
with prescaler 1/8 -> divide by 32
 

Attachments

  • max_timer0_at20MHz_18F.jpg
    56.2 KB · Views: 106
  • Capture.JPG
    128.9 KB · Views: 102

    Djsarkar

    Points: 2
    Helpful Answer Positive Rating
Hi,

T_max = fixed_prescaler x max_selectable_prescaler x 2^counter_bit_width / fosc

Klaus
I don't understand your formula

lets assume Timer 0 with 8 bit prescale , fosc = 2 Mhz

fixed_prescaler = 1 : 32
max_selectable_prescaler = 1:256


2^counter_bit_width/ fosc = 2^8/ 2000 000 = 256/ 2000 000 = 0.000128


T_max = 1/32 * 1/256 * 0.000128 = 0.03125 * 0.00390625 * 0.000128 = 0.000000015625
 

Hi,

I did not verify your values..I just use them:

What I meant is:
T_max = 32 * 256 * 0.000128s = 1.048s
 

Hi,

I did not verify your values..I just use them:

What I meant is:
T_max = 32 * 256 * 0.000128s = 1.048s
I want to verify time

Fosc/4 with an 8MHz clock, that is 2MHz.

I have attached page From datasheet max_selectable_prescaler = 1:256

and I am setting fixed_prescaler = 1 : 32
 

Attachments

  • IMG_20200928_183558.jpg
    399.5 KB · Views: 163
Last edited:

Hi,

A fixed prescaler is fixed, thus and can´t be "set". Some microcontroller have, some don´t. I´m not familiar with your microcontroller. Read the datasheet.

You may set the "selectable" prescaler to 1:256.

Klaus
 

Hi,

A fixed prescaler is fixed, thus and can´t be "set". Some microcontroller have, some don´t. I´m not familiar with your microcontroller. Read the datasheet.

Klaus
Thanks K, I have looked datasheet I don't think there is fixed prescaler option available
 

Hi,

I did not verify your values..I just use them:

What I meant is:
T_max = 32 * 256 * 0.000128s = 1.048s
8 bit Timer with 1:256 Prescale value

T_max = 256 * 0.000128s = 0.0032768s

We need to load value into the TMR0 registers (low 8 bits into TMR0L and high 8 bits into TMR0H).

What would be timer register value for 0.0032768s ?
 

Hi,

I can´t answer without reading the datasheet.
I tried, but now I recognize that in the headline you talk about PIC18F45k80, but the uploaded page is from PIC18F66K80.

So I opened PIC18F66K80 datasheet...and Fig. 13-1 and Fig. 13-2 clearly shows "Fosc/4" as clock input. Which is a fixed 1:4 divider.
Fosc never - undivided - comes to the counter.

Klaus
 

hello,

see post#7 !

What would be timer register value for 0.0032768s ?
=> 3 276,8 µS

Code:
//Timer0  16bits !
//Prescaler 1:1; TMR0 Preload = 49151; Actual Interrupt Time : 3.277 ms
void InitTimer0(){
  T0CON     = 0x88;
  TMR0H     = 0xBF;   //191
  TMR0L     = 0xFF;   /255
  GIE_bit     = 1;
  TMR0IE_bit     = 1;
}

i did not see any Postscaler for Tirmer0 ...so

20MHz --> 4/20= 0.2µS per cycle
TMR0 value= (0xBF<<8) +255 = 48896 + 255 = 49151
(65536-49151) *0.2 = 3276.8µS
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…