program crashes: is it my code or the chip?


Results 1 to 16 of 16

Threaded View

  1. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Re: program crashes: is it my code or the chip?

    and What about this one, using the Button command ?

    Code:
    '*******************************************************************************
    ' Name : BUTTONTEST2.pbp
    ' Compiler : PICBASIC PRO Compiler 3.0
    ' Assembler : PM
    ' Target PIC : 8-pin PIC12F675 or similar type
    ' Hardware : Kee
    ' Oscillator : 4MHz internal
    ' Keywords : HIGH, LOW
    ' Description : use a push button to toggle two LEDs. THere are two push buttons.
    'each push button toggles a separate set of LEDs. Program also debounces
    '*******************************************************************************
    #config 
        __CONFIG _CP_OFF & _WDT_ON & _BODEN_ON & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _CPD_OFF
    #endconfig
    
    DEFINE OSCCAL_1K 1 ' PIC12F675, Calibrate internal oscillatordefine MCLRE_OFF
    DEFINE BUTTON_PAUSE 255
    Delay    VAR Byte
    Button1 VAR GPIO.2
    Button2 VAR GPIO.3
    LED1    VAR GPIO.0 'Alias GPIO.0 to LED
    LED2    VAR GPIO.1 'Alias GPIO.1 to LED2
    LED3    VAR GPIO.4 'Alias GPIO.4 to LED3
    LED4    VAR GPIO.5 'Alias GPIO.5 to LED4
    CMCON = 7
    ANSEL = 0
    ADCON0 = 0
    GPIO    = %00001100
    TRISIO  = %00001100
    CLEAR
    '*******************************************************************************
    Main:
    '*******************************************************************************
    WHILE 1
    FIRST:' let's check Button1 ...
        Delay = 0
        button Button1, 0, 255, 0, Delay, 1,yes1
            no1:
            Pause 20 ; pace the scanning ... not compulsory
            goto Second
            yes1:
            toggle LED1    
            ' Stop until Button1 released
            WHILE !Button1 
            WEND
         
    SECOND:' let's check Button2
        Delay = 0
        button Button2, 0, 255, 0, Delay, 1,yes2
            no2:
            Pause 20 ; pace the scanning ... not compulsory
            goto Update
            yes2:
            toggle LED3
            'Stop until Button2 released
            WHILE !Button2
            WEND
    Update:        
    led2 = ! LED1 : LED4 = !LED3
    WEND
    END
    Alain
    Last edited by Acetronics2; - 25th March 2014 at 21:20.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. PICKit2 just crashes
    By johnbond in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 26th June 2011, 07:40
  2. Replies: 1
    Last Post: - 22nd May 2011, 19:37
  3. 16f690 crashes
    By Lincoln S. in forum Serial
    Replies: 8
    Last Post: - 26th November 2008, 08:32
  4. Program Code and Program Memory
    By DenFrod in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th February 2007, 14:51
  5. problems reading code from chip
    By leland in forum General
    Replies: 4
    Last Post: - 17th October 2004, 10:42

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