STC8A8K64D4 Series Manual
-
P5M1 = 0x00;
P0M0 = 0x00; //Set P0.0 ~ P0.7 as bidirectional port mode
P0M1 = 0x00;
P00 = 1; //P0.0 output high level
P00 = 0; //P0.0 output low level
P00 = 1; //Enable the internal weak pull-up resistor before reading the port
_nop_(); //Wait for two clocks
_nop_(); //
CY = P00; //Read port status
while (1);
}
Assembly code
;Operating frequency for test is 11.0592MHz
P0M0 DATA 094H
P0M1 DATA 093H
P0M1 DATA 093H
P0M0 DATA 094H
P1M1 DATA 091H
P1M0 DATA 092H
P2M1 DATA 095H
P2M0 DATA 096H
P3M1 DATA 0B1H
P3M0 DATA 0B2H
P4M1 DATA 0B3H
P4M0 DATA 0B4H
P5M1 DATA 0C9H
P5M0 DATA 0CAH
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:
MOV SP, #5FH
MOV P0M0, #00H
MOV P0M1, #00H
MOV P1M0, #00H
MOV P1M1, #00H
MOV P2M0, #00H
MOV P2M1, #00H
MOV P3M0, #00H
MOV P3M1, #00H
MOV P4M0, #00H
MOV P4M1, #00H
MOV P5M0, #00H
MOV P5M1, #00H
MOV P0M0,#00H ;Set P0.0 ~ P0.7 as bidirectional port mode
MOV P0M1,#00H
SETB P0.0 ;P0.0 output high level
CLR P0.0 ;P0.0 output low level
SETB P0.0 ;Enable the internal weak pull-up resistor before reading the port