PIC keeps resetting when executing subroutine


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Dec 2003
    Location
    WI
    Posts
    13

    Default PIC keeps resetting when executing subroutine

    All,

    I am having problems with the below code when the subroutine warning is executed. PortA.0 is pulled high with a 1k. When the bin is full the limit switch pulls PortA.0 low. The buzzer and light will blink 2 times then the PIC will reset. I have used 2 different PIC's. - F84A and F819. Both PIC's do the same thing. 5V is solid and I have plenty of decoupling and bulk capacitance sprinkled throught the circuit. For the warning lamp and buzzer driver I use 1k to the base of a 2N4401 transistor's to drive the light and buzzer. I tried Tris statements and ADCON setup with the F819 with no help. I have tried HC and XT osc drive settings. Both parts are rated for 20MHz operation. I set power up timer to off and brownout off. All I want is the buzzer and light wo toggle 5 times then if the switch is still low at PORTA.0 then just have the binlight on until PORTA.0 hoes high. I'm about to smash this with a hammer soon as something this simple should not cause this much trouble.

    Any help here is appreciated.


    Code:
    '****************************************************************
    '*  Name    : Combine.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 8/15/09                                           *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    
    define OSC 20
    
    'ADCON0 = %11000001
    'ADCON1 = %10001110
    
    'trisa = %00001110
    'trisb = %11110111
    
    binlight    var     porta.1
    buzzer      var     portb.2
    backup      var     porta.2
    alarm       var     byte
    
    define LCD_DREG PORTB
    DEFINE LCD_DBIT 4  
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 1
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 0
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
     
    low buzzer
    low binlight
    low backup
    
    PAUSE 500
    alarm = 0
    high buzzer
    high binlight
    high backup
    pause 500
    toggle buzzer
    toggle binlight
    toggle backup
    
    LCDOUT $FE,1
    LCDOUT $FE,$80, "TattleTale X"
    LCDOUT $FE,$C0, "   Monitor"
    pause 5000
    LCDOUT $FE,1
    
    monitor:
    
    LCDOUT $FE,$80, "  No Alarms"
    LCDOUT $FE,$C0, " "
    if alarm = 1 then
    goto light
    endif
    if PORTA.0 = 0 thEN
    alarm = 1
    GOsub warning
    ELSE 
    GOto monitor
    endif
    
    
    warning:
    LCDOUT $FE,1
    LCDOUT $FE,$80, " BIN FULL!!!"
    LCDOUT $FE,$C0, " "
    high binlight
    high buzzer
    pause 200
    toggle binlight
    toggle buzzer
    pause 200
    toggle binlight
    toggle buzzer
    pause 200
    toggle binlight
    toggle buzzer
    'pause 200
    'high binlight
    'high buzzer
    'pause 200
    'low buzzer
    'low binlight
    RETURN
    
    
    light:
    
    if PORTA.0 = 0 then
    high binlight
    else
    alarm = 0 
    GOTO monitor
    endif

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    monitor:
    LCDOUT $FE,$80, " No Alarms"
    LCDOUT $FE,$C0, " "
    if alarm = 1 then
    goto light
    endif

    if PORTA.0 = 0 thEN
    alarm = 1
    GOsub warning
    endif
    GOto monitor


    This might be better.

  3. #3
    Join Date
    Dec 2003
    Location
    WI
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    It still resets when the warning subroutine is run. I am going to try another computer to compile and generate the hex code. I am currently useing an ancient laptop with 98SE.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Just for fun, replace the tranistor driveres, buzzers, lamps with LEDs.
    Could still be a hardware problem and this will tell.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Dec 2003
    Location
    WI
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    I can remove the buzzer and lamps by unplugging a connector and the PIC still resets as I can see what's going on with the LCD screen. I tried a different computer and the result is the same.....

  6. #6
    Join Date
    Dec 2003
    Location
    WI
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Maybe you are browning out due to inadequate power supply
    I checked that also with my scope. Power is solid.

    I am using a 2A DC/DC converter PT6212E-5 on my circuit board with plenty of bulk capacitance. I have used these parts on many of my other PIC projects without problems. I am using a 3S1P Lipoly battery pack that can supply 30A cont current for my 12V input until it can be installed. I am using PBP V2.46 with the patch installed and the latest beta programming software with my epic programmer. The epic software on CD V3.30 gives the same reset problem...

    Jason

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jbirnsch View Post
    I am currently using an ancient laptop with 98SE.
    All I use is win98se. Maybe you are browning out due to inadequate power supply.
    Last edited by Archangel; - 26th August 2009 at 04:56.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  3. PIC chip resetting. Very weird
    By The Master in forum Off Topic
    Replies: 0
    Last Post: - 28th October 2007, 17:07
  4. Pic resetting
    By malc-c in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 1st January 2007, 21:00
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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