📄 io.c
字号:
#include <c8051f020.h> // SFR declarations
//------------------------------------------------------------------------------------
// Global CONSTANTS
//------------------------------------------------------------------------------------
#define SYSCLK 2000000 // approximate SYSCLK frequency in Hz
unsigned long x;
//------------------------------------------------------------------------------------
// Function PROTOTYPES
//------------------------------------------------------------------------------------
void PORT_Init (void);
//------------------------------------------------------------------------------------
// MAIN Routine
//------------------------------------------------------------------------------------
void main (void) {
WDTCN = 0xde;
WDTCN = 0xad; //关闭看门狗
//没有配置时钟,默认内部2M晶振
PORT_Init ();
while (1) {
for(x=0;x<=5000;x++);
P0=~P0;//按字节取反
P1=~P1;
P2=~P2;
P3=~P3;
P4=~P4;
P5=~P5;
P6=~P6;
P7=~P7;
}
}
//------------------------------------------------------------------------------------
// PORT_Init
//------------------------------------------------------------------------------------
//
// Configure the Crossbar and GPIO ports
//
void PORT_Init (void)
{
XBR2 = 0x40; // 使能交叉开关
P0MDOUT |= 0xFF; // 配置为推拉模式
P1MDOUT |= 0xFF;
P2MDOUT |= 0xFF;
P3MDOUT |= 0xff;
P74OUT|= 0xff;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -