Problem with ports help plz


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    Join Date
    May 2009
    Posts
    66

    Default Problem with ports help plz

    i donno where is the problem portb or a doesnt work to high many LEDs
    example:

    define osc 4
    Include "modedefs.bas"

    portb = 0
    trisa = 0

    main:
    portb = %0111111
    pause 100
    portb = %10001101

    goto main

    doesnt work it works just if u toggle led by led


    like:

    high portb.1 or portb.2


    need help please i tested it on many PICs th same problem????????????

  2. #2
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default PORT Problem

    I think you have a few errors in your code:

    1. If you want to flash the LEDs on PORTB, you must make PORTB an output:

    TRISB = 0

    2. The first pattern of LEDS only has 7 bit, make it eight:

    PORTB = %01111111

    3. At the end, just befor the loop ' GOTO Main' you need another PAUSE 100 of the LEDS will change too fast to see.

    So the Main bit of your code should look like:

    DEFINE OSC 4
    TRISB = 0
    PORTB = 0

    Main:
    PORTB = %10101010
    PAUSE 100
    PORTB = %01010101
    PAUSE 100
    GOTO Main

    END

  3. #3
    Join Date
    Jul 2006
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    Just FYI too:
    The reason it works for you when using the "High" command, is that "High" automatically sets that port an output...so it works. Explicitly setting the port register as you did requires you to define the port as an output as Bill described.

    Chris

  4. #4
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bill Legge View Post
    I think you have a few errors in your code:

    1. If you want to flash the LEDs on PORTB, you must make PORTB an output:

    TRISB = 0

    2. The first pattern of LEDS only has 7 bit, make it eight:

    PORTB = %01111111

    3. At the end, just befor the loop ' GOTO Main' you need another PAUSE 100 of the LEDS will change too fast to see.

    So the Main bit of your code should look like:

    DEFINE OSC 4
    TRISB = 0
    PORTB = 0

    Main:
    PORTB = %10101010
    PAUSE 100
    PORTB = %01010101
    PAUSE 100
    GOTO Main

    END
    THANK U FOR HELPING ME, IT WORKS GREAT I WAS WRITING SMALL LETTERS THATS WHY ,THIS MY CODE
    FOR LED MATRIX 5X9 AND 4017 IC IT SHOWS ": A A "
    DEFINE OSC 4
    TRISB = 0
    PORTB = 0
    J VAR PORTB.5
    Main:
    PORTB.6 = 1
    PORTB = %00100001 '
    PAUSE 1
    J =0
    PORTB = %00111010 '
    PAUSE 1
    J = 0
    PORTB = %00100001 ' LETTER A
    PAUSE 1
    J = 0
    PORTB = %00111111 'SPACE
    PAUSE 1
    J = 0
    PORTB = %00100001 '
    PAUSE 1
    J =0
    PORTB = %00111010 '
    PAUSE 1
    J = 0
    PORTB = %00100001 'LETTER A
    PAUSE 1
    J = 0
    PORTB = %00111111 ' SPACE
    PAUSE 1
    J = 0
    PORTB = %00110101 ' DOTS :
    PAUSE 1

    GOTO Main

    END

    JUST THINKING HOW I DO MY VARIABLES TO SCROLL TEXT AND SHOW MANY LETTERS ,THANK U BOTH AGAIN ,
    Last edited by Mus.me; - 26th July 2009 at 04:37.

  5. #5
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mus.me View Post
    THANK U FOR HELPING ME, IT WORKS GREAT I WAS WRITING SMALL LETTERS THATS WHY ,THIS MY CODE
    FOR LED MATRIX 5X9 AND 4017 IC IT SHOWS ": A A "
    DEFINE OSC 4
    TRISB = 0
    PORTB = 0
    J VAR PORTB.5
    Main:
    PORTB.6 = 1
    PORTB = %00100001 '
    PAUSE 1
    J =0
    PORTB = %00111010 '
    PAUSE 1
    J = 0
    PORTB = %00100001 ' LETTER A
    PAUSE 1
    J = 0
    PORTB = %00111111 'SPACE
    PAUSE 1
    J = 0
    PORTB = %00100001 '
    PAUSE 1
    J =0
    PORTB = %00111010 '
    PAUSE 1
    J = 0
    PORTB = %00100001 'LETTER A
    PAUSE 1
    J = 0
    PORTB = %00111111 ' SPACE
    PAUSE 1
    J = 0
    PORTB = %00110101 ' DOTS :
    PAUSE 1

    GOTO Main

    END

    JUST THINKING HOW I DO MY VARIABLES TO SCROLL TEXT AND SHOW MANY LETTERS ,THANK U BOTH AGAIN ,
    hope someone can help

  6. #6
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    i wrote this instead the code above but i have problem with portb.5 and .6 not working ???
    DEFINE OSC 4
    TRISB = 0
    PORTB = 0
    TXT VAR BYTE
    SR VAR WORD
    J VAR PORTB

    Main:
    LOOKUP SR,[1,%00100001,%0,%00111111,%0,%00110101,%0,%00101010 ,%0,%00100000,%0,%00111111,%0,%00110101_
    ,%0,%00101010,%0,%00100000,%0],TXT
    FOR TXT = 0 TO 18

    J = TXT
    PAUSE 100

    NEXT TXT
    GOTO Main

    END

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hello Mus.me,
    Please tell us which PIC you are using, as each is a little different, so WE may look into it's data sheet. Your code looks like it will work BUT the unknown is if your PIC has analog stuff on portB, which you have not disabled.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. sleep problem help plz >>>.
    By Mus.me in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 16th November 2009, 08:21
  2. Replies: 6
    Last Post: - 10th January 2008, 10:38
  3. ESC problem plz help
    By al000y in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 21st January 2007, 10:21
  4. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 16:46
  5. Problem with intensity.. plz help
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th October 2004, 17: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