Can Timer0 be used instead of Timer1 in DT Blinky?


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,656


    Did you find this post helpful? Yes | No

    Default Re: Can Timer0 be used instead of Timer1 in DT Blinky?

    works for me pic18f45k20

    Code:
    ,****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2015 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 4/14/2015                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
     #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  PWRT = OFF
      CONFIG  BOREN = SBORDIS
      CONFIG  BORV = 18
      CONFIG  WDTEN = ON
      CONFIG  WDTPS = 512
      CONFIG  CCP2MX = PORTC
      CONFIG  PBADEN = OFF
      CONFIG  LPT1OSC = OFF
      CONFIG  HFOFST = ON
      CONFIG  MCLRE = ON
      CONFIG  STVREN = ON
      CONFIG  LVP = OFF
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CP0 = OFF
      CONFIG  CP1 = OFF
      CONFIG  CP2 = OFF
      CONFIG  CP3 = OFF
      CONFIG  CPB = OFF
      CONFIG  CPD = OFF
      CONFIG  WRT0 = OFF
      CONFIG  WRT1 = OFF
      CONFIG  WRT2 = OFF
      CONFIG  WRT3 = OFF
      CONFIG  WRTC = OFF
      CONFIG  WRTB = OFF
      CONFIG  WRTD = OFF
      CONFIG  EBTR0 = OFF
      CONFIG  EBTR1 = OFF
      CONFIG  EBTR2 = OFF
      CONFIG  EBTR3 = OFF
      CONFIG  EBTRB = OFF
    #ENDCONFIG
    
    
      define OSC 64
     osccon=$70   '64 mhz
     OSCTUNE.6=1
     
     
     
     pause 2000
     
    Serout2 PORTb.7,84,["ready",13,10] 
     
     
     '    T0CON = %10000000                   ; Prescaler = 2
    '    T0CON = %10000001                   ; Prescaler = 4
     '   T0CON = %10000010                   ; Prescaler = 8
     '   T0CON = %10000011                   ; Prescaler = 16
     '   T0CON = %10000100                   ; Prescaler = 32
      T0CON = %10000101                   ; Prescaler = 64
    '    T0CON = %10000110                   ; Prescaler = 128
    '    T0CON = %10000111                   ; Prescaler = 256
    '      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 is configured as an 8-bit timer/counter
    '              0 = Timer0 is configured as a 16-bit timer/counter
    '      bit 5 T0CS: Timer0 Clock Source Select bit
    '              1 = Transition on T0CKI pin
    '              0 = Internal instruction cycle clock (CLKO)
    '      bit 4 T0SE: Timer0 Source Edge Select bit
    '              1 = Increment on high-to-low transition on T0CKI pin
    '              0 = Increment on low-to-high transition on T0CKI pin
    '      bit 3 PSA: Timer0 Prescaler Assignment bit
    '              1 = TImer0 prescaler is NOT assigned. Timer0 clock input bypasses prescaler.
    '              0 = Timer0 prescaler is assigned. Timer0 clock input comes from prescaler output.
    '      bit 2-0 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
    
    INCLUDE "DT_INTS-18.bas"            ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"         ' Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR0_INT,  _ToggleLED,   PBP,  yes
        endm
        INT_CREATE                      ; Creates the interrupt processor
    ENDASM
    
    
        TRISA = %00000000
        TRISB = %00000000
        TRISC = %00000000
        TRISD = %00000000
        TRISE = %00000000
    
    LED1  VAR  PORTD.0
    LED2  VAR  PORTD.1
    
    @ INT_ENABLE  TMR0_INT              ; enable Timer 0 interrupts
    
        PAUSE 1500                      ' wait for PIC and LCD to stabilize
        LCDOUT  $FE,1,"Timer test Lab X1"
    
    Main:
        TOGGLE LED2
        PAUSE 500
    GOTO Main
    
    ToggleLED:
         TOGGLE LED1
    @ INT_RETURN
    END

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Can Timer0 be used instead of Timer1 in DT Blinky?

    Thanks Richard, it works now?

    The only thing I've done is awaken the PC from sleep, but I don't see how that could have changed something.

    Sincerely,
    Confused in Montreal

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,656


    Did you find this post helpful? Yes | No

    Default Re: Can Timer0 be used instead of Timer1 in DT Blinky?

    I do most of my programing with a pickit2 , I reckon every now and then (when I'm not alert) the hex file does not refresh after compiling , and then I keep blowing the same old code into the chip. this causes paranoia to set in

Similar Threads

  1. Counting Timer0 and Timer1 overflows without any interrupt handler
    By dw_picbasic in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 16th March 2015, 21:33
  2. MIBAM blinky on 16f628
    By ShoKre in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th December 2013, 08:58
  3. Synchronising Timer0 and Timer1
    By manxman in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th April 2008, 23:12
  4. My first Blinky!
    By nomad in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 25th September 2007, 17:29
  5. 16F690 TIMER0 and TIMER1
    By nickdaprick in forum mel PIC BASIC
    Replies: 2
    Last Post: - 18th April 2007, 14:49

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