| ??? 04/07/03 08:26 Read: times |
#43003 - RE: Bit Addresable Port 1 problem...URGENT Responding to: ???'s previous message |
Alberto:
Here is code for a pair of nice subroutines that will give the functionality you want to achieve. I.E. setting and clearing bits in Port 1. This code will work for the 8051 type ports because the P1 is a bit addressable SFR. If you wanted to do this for the some other SFR that was not directly bit addressable then change the code in the tables to look like this at each entry... mov A,non_bit_SFR setb ACC.x mov non_bit_SFR,A ret ....and change the index spacing from 3 to 7 bytes per entry. Here is the code sample.... org 00h jmp 100h org 100h main: mov A,#5 acall set_p1_bit mov A,#5 acall clr_p1_bit nop nop sjmp main ; ;routine to set a bit in P1 port. ;entry A register is the bit number 0->7 to set ; set_p1_bit: anl A,#07H ;mask to 3 bits mov DPL,A add A,DPL add A,DPL ;table entries are 3 bytes mov DPTR,#set_p1_table jmp @A+DPTR set_p1_table: setb P1.0 ret setb P1.1 ret setb P1.2 ret setb P1.3 ret setb P1.4 ret setb P1.5 ret setb P1.6 ret setb P1.7 ret ; ;routine to clr a bit in P1 port. ;entry A register is the bit number 0->7 to clr ; clr_p1_bit: anl A,#07H ;mask to 3 bits mov DPL,A add A,DPL add A,DPL ;table entries are 3 bytes mov DPTR,#clr_p1_table jmp @A+DPTR clr_p1_table: clr P1.0 ret clr P1.1 ret clr P1.2 ret clr P1.3 ret clr P1.4 ret clr P1.5 ret clr P1.6 ret clr P1.7 ret end Good Luck Michael Karas |
| Topic | Author | Date |
| Bit Addresable Port 1 problem...URGENT | 01/01/70 00:00 | |
| RE: Bit Addresable Port 1 problem...URGENT | 01/01/70 00:00 | |
| RE: Bit Addresable Port 1 problem...URGENT | 01/01/70 00:00 | |
| RE: Bit Addresable Port 1 problem...URGENT | 01/01/70 00:00 | |
| RE: Bit Addresable Port 1 problem...URGENT | 01/01/70 00:00 | |
| RE: Bit Addresable Port 1 problem...URGENT | 01/01/70 00:00 | |
RE: Bit Addresable Port 1 problem...URGENT | 01/01/70 00:00 |



