i not have understanding timers, trying change timer0 make use prescaler of 1:64 in 16 bit mode? got timer code microchip , using 8 bit mode no prescaler. download files
this portion of code suspect has deal prescalers.
tmr_con = 0b00000000 | clock_divider_setting; tmr_ip = 1; tmr_if = 0; tmr_ie = 1; tmr_on = 1;
this info pic18f87j11 datasheet prescalers
t0ps2:t0ps0: timer0 prescaler select bits 111 = 1:256 prescale value 110 = 1:128 prescale value 101 = 1:64 prescale value 100 = 1:32 prescale value 011 = 1:16 prescale value 010 = 1:8 prescale value 001 = 1:4 prescale value 000 = 1:2 prescale value
i assuming use 1:64 prescalar, code must changed following, correct?
tmr_con = 0b00000101 | clock_divider_setting; tmr_ip = 1; tmr_if = 0; tmr_ie = 1; tmr_on = 1;
now, please tell me how change 8 bit mode 16 bit mode ? said beginner, please explain things level of understanding.
i appreciate in advance!
from microchip datasheet:
t0con: timer0 control register bit 7 tmr0on: timer0 on/off control bit 1 = enables timer0 0 = stops timer0 bit 6 t08bit: timer0 8-bit/16-bit control bit 1 = timer0 configured 8-bit timer/counter 0 = timer0 configured 16-bit timer/counter bit 5 t0cs: timer0 clock source select bit 1 = transition on t0cki pin input edge 0 = internal clock (fosc/4) bit 4 t0se: timer0 source edge select bit 1 = increments on high-to-low transition on t0cki pin 0 = increments on low-to-high transition on t0cki pin bit 3 psa: timer0 prescaler assignment bit 1 = timer0 prescaler not assigned; timer0 clock input bypasses prescaler 0 = timer0 prescaler assigned; timer0 clock input comes prescaler output bit 2-0 t0ps<2:0>: timer0 prescaler select bits 111 = 1:256 prescale value 110 = 1:128 prescale value 101 = 1:64 prescale value 100 = 1:32 prescale value 011 = 1:16 prescale value 010 = 1:8 prescale value 001 = 1:4 prescale value 000 = 1:2 prescale value
- clear t08bit bit select 16bit mode.
- clear t0cs bit if wont internal clock (fosc/4) timer0/prescaler input.
- clear psa bit select prescaler.
- set t0ps<2:0> select prescaler rate.
- set tmr0on 1 ro enable timer0.
this equal:
t0con =b'10000nnn' //where nnn prescaler value
if need interrupts on timer0 overflow enable timer0 interrupt bits (gie/gieh, peie/giel, tmr0ie, tmr0if).
Comments
Post a Comment