PDA

View Full Version : Question on IO ports



studysession
- 16th February 2009, 01:35
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



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

Charles Linquis
- 16th February 2009, 06:28
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.

Jerson
- 16th February 2009, 07:56
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.

studysession
- 16th February 2009, 12:01
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

studysession
- 16th February 2009, 18:10
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