12F683 - Pin1 not working


Closed Thread
Results 1 to 4 of 4
  1. #1

    Default 12F683 - Pin1 not working

    Hi there,

    i was planning on hacking a small static toy car from my son and place inside a pic and some leds to give it some life.

    I have a couple of 12f683 pics around so i decided to use them for this.

    I started with a simple combination of lights to check the effects and go from there but something stopped me.

    I can explain why but GPIO.1 does not respond to commands.
    I can put any of the pins to work except pin 1 ( turnsign ).

    I tried both pics and both have the same behavior.

    Maybe some wrong define or something i'm not seeing but it's killing my brain's out.

    Here is the code:
    Code:
    'PINS
    
    speaker 	 var GPIO.5 
    stops 	     var GPIO.4 
    BUT 	     var GPIO.3 
    bottom       var GPIO.2 
    turnsign     var GPIO.1 
    headlights   var GPIO.0 
    
    '*****************************************************************************
    
    OSCTUNE=%00000000 ' calibrated frequency
    DEFINE OSC 8
    
    '*****************************************************************************
    
    @ DEVICE pic12F683, INTRC_OSC_NOCLKOUT
    @ DEVICE pic12F683, WDT_OFF
    @ DEVICE pic12F683, PWRT_OFF
    @ DEVICE pic12F683, MCLR_OFF
    @ DEVICE pic12F683, BOD_ON
          
    '*****************************************************************************
    'HPWM
    DEFINE CCP1_REG GPIO
    DEFINE CCP1_BIT 2
    
    '*****************************************************************************
    
    ADCON0=0
    ANSEL=0
    CMCON0=7   'only for 12F683 - comparator off
    OPTION_REG.7=1      ;disable Pull-Ups
    TRISIO=%001000    ;set GPIO3 as input
    OSCCON=%01110111    ' 8mHz clock define
    CCP1CON=0           ' 12F683 ccpm module off
    INTCON=0     'interrupt control register
    'WPU=0
    'PIE1=0
    'PIR1=0
    'T1CON=0
    'T2CON=0
    GPIO=0
    
    '*****************************************************************************
    
    va      var byte
    va2     var byte
    km      var word
    mem1    var byte
    
    value   var word
    steps   VAR WORD
    
    eep1    con $10
    
    
    '*****************************************************************************
    
    sense:
    if but=1 then
    mem1=1
    write eep1,mem1
    goto all
    endif
    
    
    init:
    
    
    high turnsign 
    sound gpio.5,[50,10]
    pause 100
    low turnsign 
    pause  150
    high turnsign 
    sound gpio.5,[50,10]
    pause 100
    low turnsign 
    pause 500
    
    inp:
    if but=1 then
    mem1=mem1+1
    endif
    if mem1>12 then
    mem1=1
    endif
    write eep1,mem1
    return
    
    all:
    high headlights
    high stops
    low turnsign 
    low bottom
    sound gpio.5,[50,10]
    pause 500
    low headlights
    low stops
    high turnsign 
    high bottom
    sound gpio.5,[50,10]
    pause 500
    goto all
    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    Code:
    inp:
    if but=1 then
    mem1=mem1+1
    endif
    if mem1>12 then
    mem1=1
    endif
    write eep1,mem1
    return <<--- return to where? Maybe GOTO Init?
    RETURN should only be used when you GOSUB to get there.

    Also this;
    Code:
    high stops
    low turnsign 
    low bottom
    May also lead to trouble. It can cause read-modify-write. Sometime it's best to write to the whole port at once instead of multiple high low statements together.

    What happens if you place a PAUSE 500 after each line where you try to set or clear turnsign?

    Sometimes there may be a little more capacitance on one output than others, and setting of clearing port bits one-after-another will cause read-modify-write. The value you expect on an output may not be what you expect since the 2nd bsf or bcf operation causes the previous pin to be read back (before it has changed) and written back to the pin.
    Regards,

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

  3. #3
    Join Date
    Jan 2007
    Posts
    78


    Did you find this post helpful? Yes | No

    Default Re: 12F683 - Pin1 not working

    Just one thought ruijc
    Since your trying to troubleshoot the functionality of a pin to a particular device (perhaps an LED) , why not consider reducing down to the lowest level?
    Create a program to control that one device and nothing more.
    You can swap the code and wiring from gpio.0 to gpio.1 to see if the device is acting differently. That would allow you to verify if the issue is hardware vs code.
    In some cases, I have had to sink a device rather than source it due to current limitations on the PIC. Hope that helps. :-]

  4. #4
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: 12F683 - Pin1 not working

    The original post is dated more than 5 years ago. I suspect his son is old enough to help figure out what is wrong by now.

Similar Threads

  1. 16F877A with 20MHz XTAL not working?
    By ustredna in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 19th August 2011, 16:04
  2. Blink.Bas on 18f45k20 Newbie seeks working example.
    By DiscoEd in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th December 2009, 04:36
  3. New project help rapidfire on 12f683
    By thm ov3rkill in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 27th December 2008, 20:59
  4. 16f677a to 12f683
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th July 2007, 07:16
  5. Hserin not working...
    By robert0 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 22nd August 2005, 13:25

Members who have read this thread : 1

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