Hi guys ,

found few changes on how timer0 on this chip implements the 8bit mode and the values set in TMR0L and TMR0H from the K80, K22 series

apart from the changes in TMR0 registers and their use to setup on the 27k40 from the k22,k80 series , it appears that the 8bit mode implements different from K80,K22 series

this appears to effect the values that need to be placed into TMR0L, TMR0H in 8 bit mode
can you please check this

currently in 8 bit mode on the k40 the values set in TMR0L, TMR0H result in a 500us interupt

Where the same values 8bit mode on a k22 on TMR0 = 10ms interupt


I simply got around it by setting it to 16 bit mode , but like to know what values i should set in 8bit mode k40 to get a 10ms interupt

cheers

Sheldon

K22 SERIES
Name:  TMR0-8BIT MODE K22.JPG
Views: 472
Size:  56.6 KB

K40 SERIES
Name:  TMR0-8BIT MODE K40.JPG
Views: 420
Size:  92.4 KB



Code setup for k22 , with a 10ms interupt
Code:
 ' ---------- Timer 0 Register Setups ---------------- 
    INTCON2.2 = 1          ' TMR0IP  - TIMER 0 Overflow Interupt Priority - 1 = High Priorty , 0 = Low Priority 
    T0CON.7 = 1             ' Bit7 - TMR0 1= Enable 0 = Stop timer
    T0CON.6 = 0             ' Bit6 - TMR0 8/16bit control 1= 8bit 0=16bit, 
    T0CON.5 = 0             ' Bit5 - TMR0 Clock Source 1=clk on T0CKI pin input 0=Internal clcck (Fosc/4)
    T0CON.4 = 0             ' Bit4 - TMR0 Source Edge Select 1= H/L of TOCKI 0= L/H of TOCKI , 
    T0CON.3 = 0             ' Bit3 - TMR0 PSA select 1=TMR0 Bypass Prescaler 0= CLK Input from Prescaler output      
    T0CON.2 = 0             ' Bit2-0 - Timer0 prescaler Rate Select bits 2-0(set to 1:256)         
    T0CON.1 = 0             ' 000 = 1:2  , 001= 1:4  , 010 = 1:8   , 011 = 1:16      
    T0CON.0 = 0             ' 100 = 1:32 , 101 = 1:64, 110 = 1:128 , 111 = 1:256

    TMR0H = $63               ' preset Timer 0 to a 10ms timer
    TMR0L = $C0

timer 0 setup for k40 results in 500us timer
Code:
   
   ' ---------- Timer 0 Register Setups ---------------- 
   ' TOCON0 - POR = 0
   ' T0CON1 - POR = 0 
   ' Used for a 10ms timer 
   ' Set for 1:2 prescaler, 1:1 postscaler , use system clock (fosc/4) , preloaded in ISR with 25536  for 10ms 
   ' Note: Interupt Priority level set disable by default IPEN(INTCON.5= 0 )
   '       Timer0 Intertupt Priority = High by default - IPR0.5 = 1
   '       TMR0 Interupt enable bit  - PIE0.5 = 0 disabled  PIE0.5 = 1 Enabled - set/cleared  using DT-INTS-18  
           
    T0CON0.7 = 1             ' Bit7 - TMR0 1= Enable 0 = Stop timer
    T0CON0.6 = 0             ' Bit6 - TMR0 N/A  
    T0CON0.5 = 0             ' Bit5 - TMR0 Output bit ( read  only)                                                                                         
    T0CON0.4 = 0             ' Bit4 - TMR0 8/16bit control 0= 8bit 1=16bit                                                             
    T0CON0.3 = 0             ' Bit3-0 - Timer0 output Postscaler divider Selector bits 3-0      
    T0CON0.2 = 0             ' 0=1:1, 1=1:2, 2=1:3 , 3=1:4, 4=1:5, 5=1:6, 6=1:7          
    T0CON0.1 = 0             ' 7=1:8, 8=1:9, 9=1:10, 10=1:11, 11=1:12, 12=1:13      
    T0CON0.0 = 0             ' 13=1:14, 14=1:15, 15=1:16                        
 
    T0CON1.7 = 0             ' Bit7-5 TMR0 Clock Source Select bits - use Fosc/4  
    T0CON1.6 = 1             ' 000= Ext pin T0CKIPPS(Non Inv),001 = Ext pin T0CKIPPS(Inverted)
    T0CON1.5 = 0             ' 010= Fosc/4 , 011= HFINTOSC, 100= LFINTOSC, 101=SOSC,110-111 = Reserved                                                                                                                 
    T0CON1.4 = 0             ' Bit4 - TMR0 ASYNCH Enable Bit - 1= T0 Input NOT sync to system clock , 0 = T0 Input sync to Fosc/4
    T0CON1.3 = 0             ' Bit3-0 - Timer0 output Prescaler divider Selector bits 3-0      
    T0CON1.2 = 0             ' 0=1:1, 1=1:2, 2=1:4 , 3=1:8, 4=1:16, 5=1:32, 6=1:64          
    T0CON1.1 = 0             ' 7=1:128, 8=1:256, 9=1:512, 10=1:1024, 11=1:2048, 12=1:4096      
    T0CON1.0 = 1             ' 13=1:8192, 14=1:16384, 15=1:32768                        
    
     TMR0H = $63               ' preset Timer 0 to a 10ms timer
    TMR0L = $C0