|
代码如下:
#include "config.h"
#include "STC8G_H_GPIO.h"
#include "STC8G_H_Delay.h"
u8 code ledNum[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
u8 ledIndex;
void GPIO_config(void)
{
GPIO_InitTypeDef GPIO_InitStructure; //结构定义
GPIO_InitStructure.Pin = GPIO_Pin_2|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7; //指定要初始化的IO, GPIO_Pin_0 ~ GPIO_Pin_7
GPIO_InitStructure.Mode = GPIO_OUT_PP; //指定IO的输入或输出方式,GPIO_PullUp,GPIO_HighZ,GPIO_OUT_OD,GPIO_OUT_PP
GPIO_Inilize(GPIO_P3,&GPIO_InitStructure); //初始化
GPIO_InitStructure.Pin = GPIO_Pin_2|GPIO_Pin_3; //指定要初始化的IO,
GPIO_InitStructure.Mode = GPIO_OUT_PP; //指定IO的输入或输出方式,GPIO_PullUp,GPIO_HighZ,GPIO_OUT_OD,GPIO_OUT_PP
GPIO_Inilize(GPIO_P1,&GPIO_InitStructure); //初始化
GPIO_InitStructure.Pin = GPIO_Pin_1|GPIO_Pin_2; //指定要初始化的IO,
GPIO_InitStructure.Mode = GPIO_OUT_PP; //指定IO的输入或输出方式,GPIO_PullUp,GPIO_HighZ,GPIO_OUT_OD,GPIO_OUT_PP
GPIO_Inilize(GPIO_P0,&GPIO_InitStructure); //初始化
}
/******************** 主函数 ******STC8H1K28-36I-TSSOP20********************/
void main(void)
{
EAXSFR(); // 扩展寄存器访问使能
GPIO_config();
while(1)
{
P32=1;
P34=1;
P35=1;
P36=1;
P37=1;
P12=1;
P13=1;
P01=1;
P02=1;
delay_ms(250);
P32=0;
P34=0;
P35=0;
P36=0;
P37=0;
P12=0;
P13=0;
P01=0;
P02=0;
delay_ms(250);
}
}
P12,P13输出正常,P01,P02始终高电平,P32,P34,P35,P36,P37始终低电平。谁知道原因,说一下哟,在此感谢了
|
|