12F683 Startup


Closed Thread
Results 1 to 5 of 5

Thread: 12F683 Startup

  1. #1
    GregK's Avatar
    GregK Guest

    Default 12F683 Startup

    Hi

    When powering up the Pic the outputs are high, when I set them as outputs and low. When I ground an input pin, the loop works fine. Please tell me what I am doing wrong.

    Set registers for all digital I/O:
    ANSEL = 0
    CMCONO =7
    ADCON0 = 7
    VRON = 0.

    TRISIO = %00111000 'Set all pins as outputs except 3.4.5

    'Inputs:
    ExtendIn var gpio.4
    RetractIn var gpio.5

    'Outputs:
    ExtendOut var gpio.0
    Low ExtendOut
    RetractOut var gpio.1
    Low RetractOut

    Loop:

    If ExtendIn = 0 then
    High ExtendOut
    Pause 2000
    Low ExtendOut
    Endif

    If RetractIn = 0 then
    High RetractOut
    Pause 2000
    Low RetractOut
    Endif

    Goto Loop


    My output's are just LED's with 1K ohm series resistors. The LED's are connected so a high pin lites the Led. I have read the data sheets and I'm still not sure about the register settings. I am using Pic Basic Pro 2.45.

    Any help or suggestions would be greatly appreciated.

    Thanks

    Greg

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Greg,

    looks like your program works as designed.

    If you leave the inputs floating they will be read HIGH, so your loop doesn't do anything else than looping.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  3. #3
    GregK's Avatar
    GregK Guest


    Did you find this post helpful? Yes | No

    Default 12F683 Startup

    Hi Ralph,

    Thanks for your reply.

    Let me explain a little more about the problem. The "Loop" is just to debug a problem I am having when I first power up the pic. The two input pins used in the program are pulled up through 10K resis. The third input pin (gpio.3) is always an input, and internally pulled up.

    The problem I don't understand is why both LED's are ON when I first power up the pic, with no input pins grounded. I set the outputs Low before the "Loop" and yet they are High when I power the Pic up. I have tried other 12F683's with the same results.

    Greg

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


    Did you find this post helpful? Yes | No

    Default

    See if this configuration works for you. Note - you won't need the external pull-ups.
    Code:
    @ device pic12f683, fcmen_off, ieso_off, intrc_osc, wdt_off
    @ device pic12f683, pwrt_on, mclr_off, protect_off 
    
    GPIO = %00000000 ' All outputs low
    CMCON0=7         ' Comparators off
    ANSEL=0          ' All digital
    TRISIO=%00111000 ' Setup ins & outs
    WPU=%00110000    ' Pull-ups on for GPIO.4 & 5 inputs
    OPTION_REG.7=0   ' Enable internal pull-ups
    The default PBP header file for this device doesn't call-out the power-up timer (PWRT), so it defaults to off. This can cause some odd things to happen if your power supply is slow rising.

    You don't need to configure ADCON0 or VRCON unless you're using A/D & comparators.
    Regards,

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

  5. #5
    GregK's Avatar
    GregK Guest


    Did you find this post helpful? Yes | No

    Default 12f683

    Hi Bruce,

    I tried your changes and it works like a charm!
    Now if I can get the rest of the program to work.

    Thanks for your help.

    Greg

Similar Threads

  1. 12F683 - Pin1 not working
    By ruijc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th February 2014, 18:38
  2. 12F683 Programmer
    By Red_Stafford in forum Schematics
    Replies: 9
    Last Post: - 2nd October 2008, 22:44
  3. 12F683 HPWM Usage
    By MARAD75 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th November 2007, 03:16
  4. 16f677a to 12f683
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th July 2007, 07:16
  5. 12f683 comparator and pwm
    By Automan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd May 2007, 19:05

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