12F683, DT_INTs, and Lost pulses


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    229

    Default 12F683, DT_INTs, and Lost pulses

    Hi All,

    Been fighting with unpredictable behavior on a project and need some fresh eyes.
    Here is the minimal subset of the program that I'm fighting.
    Without any pulses on the input, I get a steady output on the Heartbeat LED (HI in this case). As soon as there is a pulse on the input (1Hz-250Hz+), I get the heartbeat, and the LED showing entry into the INT handler. As soon as the input pulse goes to 0 again, everything stops.
    Very puzzled...
    Code:
    '****************************************************************
    '                          12F683   default 4MHz, running 8MHz
    '                 ------------u-----------
    '                -|vdd (+)         vss(-) |-         
    '       LED out  -|gp5           p_a0/pgd |-  Pulse in       
    '                -|p4/a4         p_a1/pgc |-  LED2 out       
    '                -|p3/Vpp/MCLR  p_a2/ccp1 |-       
    '                 ------------------------    
    '****************************************************************
    #CONFIG
       __config _INTOSCIO & _WDT_ON & _MCLRE_OFF & _CP_OFF
    ;   __config _FOSC_INTOSCIO & _WDT_ON & _MCLRE_OFF & _CP_OFF
    #ENDCONFIG
    INCLUDE "DT_INTS-14.pbp"    ; Base Interrupt System. Ver 1.10
    INCLUDE "ReEnterPBP.pbp"    ; Include for DT_INTS.  ver 3.4
    '***************************************************************************
    define OSC 8            ' tell compiler that OSC is 8MHz
    IN          var GPIO.0  ' monitor Input pulse 
    LED2        var GPIO.1  ' INT function  LED
    LED         var GPIO.5  ' Heartbeat LED  
    Cnt         var word    ' word var for TMR1 high and low bytes
    PulseFlag   var byte    ' 
                            
    OSCCON = %01110000      ' 8MHz instead of 4MHz
    'INTCON = %11001000      ' GIE,PEIE:ON, T0IE,INTE:OFF, GPIE:ON, TOIF,INTF,GPIF:CLEAR
    IOC    = %00000001      ' Enable IOC on GPIO0 to capture pulse
    T1CON  = %00000001      ' TMR1 prescale=1:1 clock=Fosc/4, TMR1=on
    GPIO   = %00001001      ' Outputs (except 0&3) = 0 on bootup
    OPTION_REG = %00000110  ' ind pull-ups, int clk,Tmr0=1:(111=256, 110=128)
    TRISIO = %00001001      ' Pins output(except 0&3)                                  
    CMCON0 = %00001111      ' Comparator off. NEEDED to avoid RWM problem
    ANSEL  = %00000000      ' Set all digital 
    ;----[Interrupts]----------------------------------------
    ASM
    INT_LIST  macro    ; IntSource,   Label,   Type, ResetFlag?
            INT_Handler   GPC_INT,   _Capture,  PBP,  yes
        endm
        INT_CREATE              ; Creates the High Priority interrupt processor
        INT_ENABLE  GPC_INT     ; enable Capture interrupts
    ENDASM
    
    Main: 
      toggle LED            ' heartbeat
      pause 10   
      if PulseFlag then
        toggle LED2
        PulseFlag = 0
       endif 
    GOTO Main
    '---[IOC - interrupt handler]------------------------------------------
    Capture:  ' Enter here with Pulse (IOC) 
    PulseFlag = 1           ' Caught a pulse
    Cnt.highbyte = TMR1H    ' grab TMR1
    Cnt.lowbyte = TMR1L     ' Cnt stays the same until the next pulse.
        T1CON.0=0           ' Turn TMR1 off
        TMR1H = 0           ' clear TMR1 
        TMR1L = 0           ' 
        T1CON.0=1           ' Turn TMR1 on
        PIR1.0 = 0          ' Clear TMR1IF. 
    @ INT_RETURN
    
    END
    I hope the code is reasonably self explanatory.
    Thanks for any observations.
    bo

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

    Default Re: 12F683, DT_INTs, and Lost pulses

    you cannot clear the gpio change flag until you read the gpio port


    Code:
    Capture:  ' Enter here with Pulse (IOC) 
    PulseFlag = 1           ' Caught a pulse
    Cnt.highbyte = TMR1H    ' grab TMR1
    Cnt.lowbyte = TMR1L     ' Cnt stays the same until the next pulse.
        T1CON.0=0           ' Turn TMR1 off
        TMR1H = 0           ' clear TMR1 
        TMR1L = 0           ' 
        T1CON.0=1           ' Turn TMR1 on
        PIR1.0 = 0          ' Clear TMR1IF. 
        tmp=gpio.0
        
    @ INT_RETURN
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    229

    Default Re: 12F683, DT_INTs, and Lost pulses

    (beating head against wall) Thank you Richard. For the life of me, I couldn't see that. Saw your reply, and DUH, of course.
    I appreciate the help.

    bo

  4. #4
    Join Date
    Sep 2012
    Location
    Australia - Gold Coast
    Posts
    3

    Default Re: 12F683, DT_INTs, and Lost pulses

    Hello Bo,

    Were you able to get your 12F683 working? I am also using a 12F683 for a remote pressure sensor application but I am unable to compile the code as I get the interrupt error.
    Code:
    ERROR: Variable wsave2 position request 288 beyon RAM_END 191.
    I have edited the DT_INTS-14.bas and left the wsave $20 and wsave $A0 enable, but alas still no go.

    I know my setup is OK because if I grab an older code I was playing with years ago with DT Interrupts for 16F648A, it successfully compiles without any issues and I can program it to the PIC...

    Cheers
    Attila

  5. #5
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    229

    Default Re: 12F683, DT_INTs, and Lost pulses

    I have been working on the bigger chips for this project to get some other features. I'm going back to the 12F683 to use what I learned. If I get an answer, I'll let you know.

    Is it the INT on change that you are trying to use?

    bo

Similar Threads

  1. Replies: 22
    Last Post: - 23rd June 2011, 21:01
  2. Lost Communications?
    By fowardbias in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th February 2010, 18:25
  3. Have I lost touch ?
    By Bazz in forum Off Topic
    Replies: 7
    Last Post: - 7th September 2008, 09:45
  4. Lost your OSCCAL Value ???
    By Acetronics2 in forum Documentation
    Replies: 10
    Last Post: - 27th November 2007, 19:11
  5. Lost in finding a example
    By F1CHF in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th January 2007, 23:20

Tags for this Thread

Posting Permissions

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