How to set a pin high an keep it there?


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Posts
    20

    Default How to set a pin high an keep it there?

    Utter newbie here... I have three different LEDs on a PIC16F688. Here is my code:
    Code:
    symbol  GREEN = PORTA.1
    symbol  ORANGE = PORTA.0
    symbol  BLUE = PORTA.2
    
    porta = %00000000
    trisa = %00000000
    
    main:
    high orange
    pause 1000
    high green
    pause 1000
    high blue
    pause 1000
    
    end
    This code obviously lights the LEDs in sequence. However each LED turns off before the next one is set high. How do light one, then two, and then all three? Thanks!

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Try this:
    Code:
    main:
    
    PORTA = %00000001
    pause 1000
    PORTA = %00000011
    pause 1000
    PORTA = %00000111
    PAUSE 1000
    
    end
    It looks like you are experiencing a read-modify-write problem. You can search for more info on this forum.
    Charles Linquist

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Code:
    INCLUDE "AllDigital.pbp"
    
    symbol  GREEN = PORTA.1
    symbol  ORANGE = PORTA.0
    symbol  BLUE = PORTA.2
    
    porta = %00000000
    trisa = %00000000
    
    main:
    high orange
    pause 1000
    high green
    pause 1000
    high blue
    pause 1000
    
    end
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Code:
    ANSEL=%00000000
    CMCON0=%00000111
    Will do the same as Darrel's suggestion and this
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    plus the data sheet will actually help you learn why.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    ...
    Will do the same as Darrel's suggestion and this
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    plus the data sheet will actually help you learn why.
    Sure,
    But if you run ALLDIGITAL first, then you know where to look in the datasheets, because it's already told you what settings you need to use.
    If you want to learn, look them up.

    People never find the analog registers they need to set by looking in the datasheet first.
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Sure,
    But if you run ALLDIGITAL first, then you know where to look in the datasheets, because it's already told you what settings you need to use.
    If you want to learn, look them up.

    People never find the analog registers they need to set by looking in the datasheet first.
    If you keep going with all of your add ons (includes) you will have any PIC as easy as a STAMP.

    What is the maximum amount of includes you have used in a program?
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Exclamation

    I hope not ... Stamp's don't bring back any memories of "Easy" for me.
    What is the maximum amount of includes you have used in a program?
    Probably 12-15, but I've never really counted.

    90% of my programs only have 2 includes.
    care to guess which ones?
    <br>
    DT

Similar Threads

  1. SERIN MIDI out of Synch?
    By jncortes in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th June 2009, 20:08
  2. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14: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