can any one plz tell me how to expand ports in pic18f452. there are 5 ports in pic18f452. i used all ports. i want 8 more pins(0ne port) . for that i planned to interface with 8255 to increase the ports. so plz help me how to interface 8255 to pic18f452 to increase the ports
but i want to send different values to two ports. i have one port(8 bits) is free. but i want to send RTC values and also adc values. so i want to 2 eight bit ports. so how to increse two 8 bit ports from one 8 bit port.
Let's assume you want to expand PORTB to 16 bits. You've got two 74 chips.
You need one more pin (PORTE.0 for example). You connect PORTE.0 to the 'clock' input of one 74 chip and through an inverter to the clock input of the other 74 chip.
You connect all 8 pins of PORTB to the inputs of both 74 chips.
Then, when you put PORTE.0 low, value of PORTB will be 'latched' in one of the chips, and when you put PORTE.0 to high, it'll be on the other.
Remember, though - this will slow down the speed of the port. It will take 3-4 instructions to 'fill' both 74 chips with data.
Code:
BCF PORTE,0 ;low to high
MOVLW %01010101 ; first 74 chip
MOVWF PORTB
NOP
MOVLW %10101010 ; second 74 chip
MOVWF PORTB
BSF PORTE,0 ;high to low (when inverted - low to high)
THANK U. BUT IN PROJECT BOTH DATA WANT TO RUN AT A TIME. THAT IS rtc DATA I WANT TO DISPAY AND AT THE SAME TIME I WANT TO SEND ADC VALUE. I HAV port A AND portE AND portB IS FREE. SO I WILL SEND ADC VALUE TO portB. THEN I WANT TO DISPLAY RTC VALUE 8 BITS. BUT PORTA I HAV 6 PINS AND PORT E I HAV 3 PINS. "SO HOW TO SEND 8 BITS TO PORTA AND PORTE." THE 8 BITS ARE RTC SECOND VALUE WITH IS IN BCD FORMAT. THAT DATA I HAV TO SEND AND DISPLAY IN BCD 7 SEGMENT DISPLY.
It's physically impossible to "run it at a time" - it's a single MCU with a single processor, and a sequential code running on it. Only one thing can happen at a time.
Splitting data across two ports (A and E) would actually be slower than using latches.
The 8255 is an option. Just write to it's registers and you are fine.
It is only going to give you 24 IO and address decoding is needed. I guess you could use a uC spare IO pin and just toggle it when needed.
The nice thing about the MCP is that there are only 4 interface lines. You can then daisy chain up to 8 of them (128 IO total). Not bad for 4 pins.