EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Reading and Writing Operation of Bidirection Port

Default Icon
901 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
STC8A8K64D4 Series Manual
-
- 173 -
P7M1 DATA 0E1H
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:
MOV SP, #5FH
MOV P0M0,#00H ;Set P0.0 ~ P0.7 as bidirectional port mode
MOV P0M1,#00H
MOV P1M0,#0FFH ;Set P1.0 ~ P1.7 as push-pull output mode
MOV P1M1,#00H
MOV P2M0,#00H ;Set P2.0 ~ P2.7 as high impedance input mode
MOV P2M1,#0FFH
MOV P3M0,#0FFH ;Set P3.0 ~ P3.7 as open-drain mode
MOV P3M1,#0FFH
JMP $
END
9.4.2 Reading and Writing Operation of Bidirection Port
C language code
//Operating frequency for test is 11.0592MHz
#include "reg51.h"
#include "intrins.h"
sfr P0M0 = 0x94;
sfr P0M1 = 0x93;
sfr P0M1 = 0x93;
sfr P0M0 = 0x94;
sfr P1M1 = 0x91;
sfr P1M0 = 0x92;
sfr P2M1 = 0x95;
sfr P2M0 = 0x96;
sfr P3M1 = 0xb1;
sfr P3M0 = 0xb2;
sfr P4M1 = 0xb3;
sfr P4M0 = 0xb4;
sfr P5M1 = 0xc9;
sfr P5M0 = 0xca;
sbit P00 = P0^0;
void main()
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;

Table of Contents

Related product manuals