pic18f87k40 Timer1 setting


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2021
    Posts
    3

    Default pic18f87k40 Timer1 setting

    Hello members

    PIC18F67K40

    i try to operate timer1 without gate control.
    seams it don't work.(timer0 work perfect).
    i use 48mhz internal osc

    i don't know what is wrong


    Code:
    PIE4.0=1 'TMR1 Overflow Interrupt Enable bit 
    INTCON.6=1 'Peripheral Interrupt Enable bit 
    
    
    TMR1CLK=%00000001   'Timer1 Clock Source Selection Register  Fosc/4
    'TMR1CLK=%00000011   'Timer1 Clock Source Selection Register   HFINTOSC
    
    ;TMR1GATE=
    T1GCON.7=0 'Timer Gate Enable bit
    T1CON=00110100  'Timer1 Prescale 8 , Do not synchronize external clock input & off 
    ;T1CON=00110000  'Timer1 Prescale 8 , Synchronize external clock input with system clock & off 
    
    PIR4.0=0 'CLEAR INT TIMER1
    
    
    '****** TEST TIMER1 *******
    T1CON.0=1 'TIMER 1 ON
    WAIT2:
    IF PIR4.0 THEN           'Timer1 INT
                 T1CON.0=0    'Timer1 Off
                 PIR4.0=0       'CLEAR INT  
                 PORTE.5=PORTE.5 ^ 1    'led on/off
                 TEMP=35536     '20MS /8  48MHZ
                 TMR1H=TEMP.BYTE1
                 TMR1L=TEMP.BYTE0      
                 T1CON.0=1 'TIMER 1 ON  
                 ENDIF
    
    
    GOTO WAIT2
    '************************
    Last edited by Ioannis; - 2nd June 2022 at 17:40.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: pic18f87k40 Timer1 setting

    Have you defined temp as word ?- you do not show in your code.

  3. #3
    Join Date
    Dec 2021
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: pic18f87k40 Timer1 setting

    Hi
    Thanks for your replay.

    i found the problem , i use wrong datasheet(PIC18 L_F26_27_45_46_47_55_56_57K40 ).
    have different at datasheet PIC18(L)F67K40DataSheet40001841D

    the Peripheral Interrupt iS PIR5.0 NO PIR4.0

    IF SOME ONE NEED, TIMER1 SETTING FOR PIC18F67K40 without gate control

    PIE5.0=1 'TMR1 Overflow Interrupt Enable bit
    INTCON.6=1 'Peripheral Interrupt Enable bit

    'internal osc 32mhz


    TMR1CLK=%00000001 'Timer1 Clock Source Selection Register Fosc/4
    T1GCON=0 'GATE CONTROL OFF
    T1CON=00110000 'Timer1 Prescale 8 , Synchronize external clock input with system clock & off
    PIR5.0=0 'CLEAR INT TIMER1


    '****** TEST TIMER1 *******
    T1CON.0=1 'TIMER 1 ON
    WAIT2:
    IF PIR5.0 THEN 'TIMER 1 INT
    T1CON.0=0 'TIMER 1 Off
    PIR5.0=0 'CLEAR INT
    PORTE.5=PORTE.5 ^ 1 ' LED ON/OFF
    TEMP=15536 '50ms /8 32MHZ
    TMR1H=TEMP.BYTE1
    TMR1L=TEMP.BYTE0
    T1CON.0=1 'TIMER 1 ON
    ENDIF
    GOTO WAIT2

Similar Threads

  1. How to read timer1 value?
    By Ferocactus in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th January 2011, 23:19
  2. timer1 help
    By robertpeach in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th September 2009, 09:05
  3. timer1 trouble
    By beginner10 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 19th August 2009, 17:30
  4. RPM With Timer1
    By mel4853 in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 29th June 2009, 21:50
  5. Reading Timer1 value
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th June 2006, 16:21

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts