16F88 and TMR0 Interrupt - where's the fish?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938

    Default 16F88 and TMR0 Interrupt - where's the fish?

    Hello,

    I just sublimized my two last 16F690 and had to replace and adapt the code to my old 16F88... ones...

    Since I did so, I can't make the INTerrupt routine work anymore.

    I compared with former programs I made and can't find the difference.

    Why isn't it working; where's the fish?
    Code:
    ' Fuses
    @ DEVICE HS_OSC
    @ DEVICE PROTECT_OFF
    @ DEVICE WDT_ON
    @ DEVICE PWRT_ON
    @ DEVICE MCLR_OFF
    @ DEVICE BOD_OFF
    @ DEVICE LVP_OFF
    @ DEVICE CPD_OFF
    @ DEVICE DEBUG_OFF
    @ DEVICE CCPMX_OFF
    
    '-------------------------------------------------------------------------------
    ' Registers   76543210
    OPTION_REG = %10000000 'PORTB Pull-Ups disabled
    OSCCON     = %00000000 'Internal RC set External Xtal
    ANSEL      = %00000000 'Disable analog inputs
    ADCON0     = %00000000 'A/D Module is OFF
    CMCON      = %00000111 'Comparator Module is OFF
    INTCON     = %10100000 'Set Interrupts
    TRISA      = %00000000 'Set Input/Output
    PORTA      = %00000000 'Ports High/Low
    TRISB      = %00000000 'Set Input/Output
    PORTB      = %00000000 'Ports High/Low
    
    '-------------------------------------------------------------------------------
    ' Variables
    Ticks   var byte
    Second  var byte
    Minute  var byte
    Hour    var byte
    LED1    var PORTB.5
    LED2    VAR PORTB.4
    
    '-------------------------------------------------------------------------------
    ' Program
    clear
    On Interrupt Goto tick_int
    
    TEST:
        if second = 2 then
            second = 0
            toggle led1
            goto test
        endif        
        end
    
    '-------------------------------------------------------------------------------
    disable
    TICK_INT:
        Ticks = Ticks + 1
        If Ticks < 61 Then TICK_INT_RESET
        Ticks = 0
        Second = Second + 1
        If Second >= 60 Then    
            Second = 0
            minute = minute + 1
            If minute >= 60 Then
                minute = 0
                Hour = Hour + 1
            Endif
        Endif
        toggle led2 'control LED - blink every second
        
        TICK_INT_RESET:
            INTCON.2 = 0
    
        Resume
        enable
    Roger

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Roger,

    You have an END there so it's putting the PIC to sleep unless second = 2

    Replace the END with GOTO TEST.

    Also you have no DEFINE OSC so it's using the default speed of 4MHz.

    It works fine if I add DEFINE OSC 20 and GOTO TEST VS END.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default

    That was so obvious!!! Where are my glasses...

    Thanks a lot, Bruce, I pasted this GOTO TEST one line to early

    By the way, any idea why my PIC seems to be running much faster than 4MHz?

    I use a 4MHz Xtal.

    As you mentionned, there is no DEFINE OSC in my code. So my PIC should run at the Xtal's speed, no?
    Roger

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Try XT_OSC. May be over-driving your 4MHz crystal and producing some odd harmonics?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default

    First thing I tried when I noticed...

    No change. Just strange.

    I even removed the Xtal and set the internal oscillator to 4MHz... Still running appearently very fast.

    Have to check.
    Roger

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Why it appears to be running faster I can't say. What are you placing in OSCCON?
    Last edited by Bruce; - 4th November 2007 at 22:28.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. DT inst. interrupt & Timer0 with pic 16F88
    By aratti in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th December 2009, 21:23
  3. Problem with 16f88 steep motor control
    By ken_23 in forum Off Topic
    Replies: 0
    Last Post: - 4th July 2008, 12:25
  4. Ping Darrel Taylor - Timer0 Instant Interrupt
    By JEC in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th January 2007, 11:20

Members who have read this thread : 0

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