| ??? 02/11/01 12:25 Read: times |
#9207 - RE: P2 as general output |
aka j wrote:
------------------------------- >If so, P1 and P2 will be used to present an address when accessing that memory block Sorry, Jay, it must be P0 and P2. Jason, >How does Port 2 differ in construction from lets say, Port 1 or 3? Nothing in your case. But don't forget that the undisturbed contents of the port 2 SFR reappear in the next cycle. It is possible to use the upper two bits from Port 2 as general outputs. It is easy enough. There is a little program trick here. Let's reserve an image of your external address before putting it into DPTR and look at some cases. 1) Suppose you want to set p2.7 bit of port 2. You have to write next code ORL HI_IMAGE,#1000000B MOV P2,HI_IMAGE 2) Suppose you want to clear p2.7 bit of port 2. You have to write next code ANL HI_IMAGE,#01111111B MOV P2,HI_IMAGE 3) Suppose you want to get any byte from external memory. You concatenated the 7 or/and 6 bits with desired high byte address before, so you have to write next code MOV DPH,HI_IMAGE MOV DPL,LO_IMAGE MOVX A,@DPTR The similar trick you can use if you have external code ROM of 16 KB. Suppose you want to set p2.7 bit of port 2. You have to write next code MOV DPTR,#NXTADDR XCH A,DPH SETB ACC.7 ;or bit 6 or both XCH A,DPH JMP @DPTR NXTADR: ........... Hope this examples are enough to understand the main idea. George |
| Topic | Author | Date |
| P2 as general output | 01/01/70 00:00 | |
| RE: P2 as general output | 01/01/70 00:00 | |
| RE: P2 as general output | 01/01/70 00:00 | |
| RE: P2 as general output | 01/01/70 00:00 | |
| RE: P2 as general output | 01/01/70 00:00 | |
| RE: P2 as general output | 01/01/70 00:00 | |
| RE: P2 as general output | 01/01/70 00:00 | |
| RE: P2 as general output | 01/01/70 00:00 | |
RE: P2 as general output | 01/01/70 00:00 |



