How to set GPIO.5 as output ?


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Mar 2004
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    I knew I should have posted my code but I was on a different computer at the time. The first is the program I have tried, with it, GPIO.4 works properly but GPIO.5 remains HIGH always. There's no short btwn any pins, I'm using a clean breadboard.

    Code:
    POR
    ADCON0=0
    VRCON=0
    OPTION_REG.5=0
    OPTION_REG.7=1
    CMCON=7
    TRISIO=%00001000
    
    
    
    LED1 var GPIO.0
    LED2 VAR GPIO.1
    LED3 VAR GPIO.2
    LED4 VAR GPIO.4
    LED5 VAR GPIO.5
    
    PAUSE 50
    
      loop:                  'scroll test pattern
    
    high led1
    pause 75
    LOW LED1
    PAUSE 50
    
    high led2
    PAUSE 75
    LOW LED2
    PAUSE 50
    
    HIGH LED3
    PAUSE 75
    LOW LED3
    PAUSE 50
    
    high led4
    PAUSE 75
    LOW LED2
    PAUSE 50
    
    HIGH LED5
    PAUSE 75
    LOW LED3
    PAUSE 50
    
    
    goto loop



    The code below is based on your reply (which I appreciate) and it makes GPIO.4 and GPIO.5 remain HIGH at all times. I have tried compiling in both PM and mpasm. Also, I have the MCLR disabled in EPIC'c configuration. I'm not using an ext. osc.

    Code:
    TRISIO=%00000
    CMCON=%00000111
    ANSEL=%00000000
    
    
    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    @ DEVICE pic12F675, WDT_ON
    @ DEVICE pic12F675, PWRT_ON
    @ DEVICE pic12F675, MCLR_OFF
    @ DEVICE pic12F675, BOD_ON
    
    LED1 var GPIO.0
    LED2 VAR GPIO.1
    LED3 VAR GPIO.2
    LED4 VAR GPIO.4
    LED5 VAR GPIO.5
    
    PAUSE 50
    
      
    loop:                  'scroll test pattern
    
    high led1
    pause 75
    LOW LED1
    PAUSE 50
    
    high led2
    PAUSE 75
    LOW LED2
    PAUSE 50
    
    HIGH LED3
    PAUSE 75
    LOW LED3
    PAUSE 50
    
    high led4
    PAUSE 75
    LOW LED2
    PAUSE 50
    
    HIGH LED5
    PAUSE 75
    LOW LED3
    PAUSE 50
    
    
    goto loop
    So I must be doing something wrong or missing something ? If I remove ANSEL GPIO.4 works ???

    This is just a way for me to learn to use GPIO.4 and 5 and plan to use them in another program later.

    Thanks for the help !

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


    Did you find this post helpful? Yes | No

    Default

    I see
    HIGH LED5
    but I do not see
    LOW LED5

    Maybe I am missing something???
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Mar 2004
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I see
    HIGH LED5
    but I do not see
    LOW LED5

    Maybe I am missing something???
    No, you're not missing anything, that was it ! Good job on catching that, I can't believe how many times I looked at that and never saw it. I still had to remove ANSEL to get GPIO.4 to work but it's all good now.

    Thank you for pointing that simple (read STUPID) mistake out, and thanks Melanie and Gary,

    Sam

  4. #4
    Join Date
    Apr 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I see
    HIGH LED5
    but I do not see
    LOW LED5

    Maybe I am missing something???
    There is no LOW LED4 either.....................

    Andy

  5. #5
    Join Date
    Mar 2004
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Andy Wood View Post
    There is no LOW LED4 either.....................

    Andy
    Yeah, I fixed that too. I copied and pasted those last two sections then changed them and that's where I really started screwing up. I'll read my own stuff a LOT closer after this ordeal.

    I did learn how to properly initiate this PIC now though, thanks to Melanie's post.

Similar Threads

  1. Interruptus Frustratus
    By Byte_Butcher in forum General
    Replies: 16
    Last Post: - 17th April 2009, 21:36
  2. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 08:57
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 21:36
  4. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 04:46
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 15:31

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