Question on IO ports


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Posts
    14

    Default Question on IO ports

    I received the book "PIC Microcontroller Project Book for PICBasic and PICBasic Pro Compilers"

    The book uses the 16F84A PIC in most of it's examples. In chapter 12 it shows an example using the 16F84A along with a 74LS164 to add 8 more IO ports incase you ever need more ports and the PIC you are using does not have enough.

    Question -
    Below is the sample source code along with my schematic drawing. This works great for turning on and off the LED's but I want to know what I need to do in order to send text to my 2x16 LCD using one of these ports.

    Would appreciate some help please.
    Thanks

    Code:
    include "MODEDEFS.BAS"
    
    lcd1 var porta.0
    led1 var porta.1
    led2 var portb.2
    
    B0 var byte
    TRISB.0 = 0
    
    pause 1000
                       
    main
    
    high led1
    pause 100
    low led1
    pause 100
    high led2
    pause 100
    low led2
    pause 100
    
    B0 = 128
    gosub serial
    pause 1000
    B0 = 64
    gosub serial
    pause 1000
    B0 = 32
    gosub serial
    pause 1000
    B0 = 16
    gosub serial
    pause 1000
    B0 = 8
    gosub serial
    pause 1000
    B0 = 4
    gosub serial
    pause 1000
    B0 = 2
    gosub serial
    pause 1000
    B0 = 1
    gosub serial
    pause 1000
    B0 = 255
    gosub serial
    pause 1000
    B0 = 0
    gosub serial
    pause 1000
    
    goto main
    
    serial:
    portb.0 = B0.7
    pulsout 1,1
    portb.0 = B0.6
    pulsout 1,1
    portb.0 = B0.5
    pulsout 1,1
    portb.0 = B0.4
    pulsout 1,1
    portb.0 = B0.3
    pulsout 1,1
    portb.0 = B0.2
    pulsout 1,1
    portb.0 = B0.1
    pulsout 1,1
    portb.0 = B0.0
    pulsout 1,1
    portb.1 = 0
    return
    Attached Images Attached Images  
    Last edited by studysession; - 16th February 2009 at 01:37.

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


    Did you find this post helpful? Yes | No

    Default

    Why don't you just start with a PIC with more pins? You could have the I/O ports *AND* drive the LCD with the LCDOUT command - without any external parts.
    Charles Linquist

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    If you're planning on using one of those expanded ports (74LS164) to write to the LCD, its a long shot. If you want to write to the LCD as shown in your diagram using RA0, you could look at either SEROUT (RS232) or SHIFTOUT (Parallel - Serial) commands in the manual. Which one to use depends on what your LCD understands. I've never used a serial LCD, so I cannot say.

  4. #4
    Join Date
    Jan 2009
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Jerson View Post
    If you're planning on using one of those expanded ports (74LS164) to write to the LCD, its a long shot. If you want to write to the LCD as shown in your diagram using RA0, you could look at either SEROUT (RS232) or SHIFTOUT (Parallel - Serial) commands in the manual. Which one to use depends on what your LCD understands. I've never used a serial LCD, so I cannot say.
    Thanks -
    I am just trying to do something other than the example in the book. I just randomly chose the LCD. From your statement I now understand. I just want to make sure I can do something else than just turn on or off LED's. Trying to figure out how - like maybe read a value from a pin or something else maybe.

    I did the lab in the book which was turning on and off the LED's. I have a good handle on that but not using it for anything else.

    Thanks

  5. #5
    Join Date
    Jan 2009
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    OK - I am having some issues here. I am trying so hard to understand using this 74LS164 chip.

    How would I modify my code above if on one of the lines within the serial routine, that I wanted to read a value if a button was pressed and pass it back to the main program?

    Thanks

Similar Threads

  1. Simple question regarding ports
    By rngd in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd February 2008, 16:37
  2. Replies: 1
    Last Post: - 29th September 2007, 18:05
  3. SHIFT command QUestion
    By k2nneth in forum General
    Replies: 0
    Last Post: - 14th March 2007, 16:32
  4. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 06:49
  5. 16f872. config ports and serin question.
    By kitcat in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th July 2005, 03:03

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