Why would this simple code hang after 10 cycles:


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Mar 2023
    Location
    Cape Town, South Africa
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Why would this simple code hang after 10 cycles:

    I am sure the pin is wired correct and I can measure it going from 0 to 4.8V . Let me look some more . . . . . . .

  2. #2
    Join Date
    Mar 2023
    Location
    Cape Town, South Africa
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Why would this simple code hang after 10 cycles:

    ' Name : Henrik.pbp
    ' Compiler : PICBASIC PRO Compiler 3.1.6.2
    ' Assembler : PM or MPASM
    ' Target PIC : 12F types
    ' Hardware : Non specific
    ' Oscillator : internal



    #CONFIG
    __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    #ENDCONFIG


    DEFINE OSC 4


    RECPB var GPIO.4 ' Assign name "RECPB" to GPIO 4 OUTPUT
    CYCLE var GPIO.0 ' Assign name "CYCLE" to GPIO 0 INPUT


    TRISIO.4 = 0 ' GPIO.4 as output
    ANSEL = 0
    CMCON0 = 7


    OPTION_REG.7 = 0 ' Enable individual pullups
    WPU.0 = 1 ' Enable weak pullup on GPIO.0


    Mainloop:


    IF Cycle = 1 THEN ' do the 3/57 record cycle
    RECPB = 0 ' Low Rec PB to start recording
    Pause 500 ' start recording for 3 seconds
    RECPB = 1 ' High Rec PB after recording start
    PAUSE 3000
    RECPB = 0 ' Low Rec PB to stop recording
    Pause 500 ' Stop recording after 3 seconds
    RECPB = 1 ' High Rec PB after recording Stop
    PAUSE 10000
    ENDIF


    GOTO Mainloop


    End

  3. #3
    Join Date
    Mar 2023
    Location
    Cape Town, South Africa
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Why would this simple code hang after 10 cycles:

    Changed the WPU command and in the Mainloop said IF Cycle = 0 instead of 1 (grounding pin7 / GP0) must start the cycle. Ready to go to the next challenge . . . . . .

    #CONFIG
    __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    #ENDCONFIG


    DEFINE OSC 4


    RECPB var GPIO.4 ' Assign name "RECPB" to GPIO 4 OUTPUT
    CYCLE var GPIO.0 ' Assign name "CYCLE" to GPIO 0 INPUT


    TRISIO.4 = 0 ' GPIO.4 as output
    ANSEL = 0
    CMCON0 = 7
    OPTION_REG.7 = 0 ' Enable individual pullups
    WPU=0101 ' Enable weak pullups on GPIO.0 & GPIO.2


    Mainloop:


    IF Cycle = 0 THEN ' do the 3/57 record cycle
    RECPB = 0 ' Low Rec PB to start recording
    Pause 500 ' start recording for 3 seconds
    RECPB = 1 ' High Rec PB after recording start
    PAUSE 3000
    RECPB = 0 ' Low Rec PB to stop recording
    Pause 500 ' Stop recording after 3 seconds
    RECPB = 1 ' High Rec PB after recording Stop
    PAUSE 10000
    ENDIF


    GOTO Mainloop


    End

Similar Threads

  1. 18LF4680 HSERIN and SEROUT hang my PIC!
    By temp19 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 19th May 2011, 02:02
  2. what's wrong 16F877A simple code?
    By Macgman2000 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th October 2009, 01:11
  3. Replies: 1
    Last Post: - 15th December 2008, 05:34
  4. Variant of Serin2/Timeout Hang Problem
    By Jimbo in forum Serial
    Replies: 3
    Last Post: - 2nd October 2007, 19:33
  5. hopefully simple code
    By hoyles in forum General
    Replies: 3
    Last Post: - 8th September 2005, 23:24

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