wengbaoguo 发表于 5 小时前

STC8H1K28 P3.1读写引起程序复位

我这个项目是做压力传感器的,


void        GPIO_config(void)
{
        GPIO_InitTypeDef        GPIO_InitStructure;                               
        GPIO_InitStructure.Pin= GPIO_Pin_All;                                       
        GPIO_InitStructure.Mode = GPIO_OUT_PP;                       
        GPIO_Inilize(GPIO_P1,&GPIO_InitStructure);        //P10-P17Êä³ö
        GPIO_Inilize(GPIO_P2,&GPIO_InitStructure);        //P20-P27Êä³ö
        P0 = 0;
        P1 = 0;
       
        GPIO_InitStructure.Pin= GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 ;        //com0-3
        GPIO_InitStructure.Mode = GPIO_HighZ;                        //
        GPIO_Inilize(GPIO_P0,&GPIO_InitStructure);        //
       
        GPIO_InitStructure.Pin= GPIO_Pin_0 |GPIO_Pin_5 | GPIO_Pin_7 | GPIO_Pin_6 ;       
        GPIO_InitStructure.Mode = GPIO_PullUp;                        //
        GPIO_Inilize(GPIO_P3,&GPIO_InitStructure);        //
       
        GPIO_InitStructure.Pin= GPIO_Pin_4;       
        GPIO_Inilize(GPIO_P5,&GPIO_InitStructure);        //
       
        GPIO_InitStructure.Pin= GPIO_Pin_1 |GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 ;                       
        GPIO_InitStructure.Mode = GPIO_OUT_PP;                       
        GPIO_Inilize(GPIO_P3,&GPIO_InitStructure);        //
        P31 = 0;
        P32 = 0;
        P33 = 0;
        P34 = 0;
       
}
这个是IO初始化的,应用中采用了CS1237采集气压,需要2个IO口,P31,P36,P31作为时钟脚,所以设置成输出


#define SCLK_1      P31 = 1;
#define SCLK_0      P31 = 0;
#define DOUT_0      P36 = 0;
#define DOUT_1      P36 = 1;
#define DOUT_IN    {GPIO_InitStructure.Pin= GPIO_Pin_6 ;        GPIO_InitStructure.Mode = GPIO_PullUp;        GPIO_Inilize(GPIO_P3,&GPIO_InitStructure);}
#define DOUT_OUT   {GPIO_InitStructure.Pin= GPIO_Pin_6 ;        GPIO_InitStructure.Mode = GPIO_OUT_PP;        GPIO_Inilize(GPIO_P3,&GPIO_InitStructure);}


因为仿真需要P31,所以仿真时将SCLK改到了P33,

#define SCLK_1      P33 = 1;
#define SCLK_0      P33 = 0;
#define DOUT_0      P36 = 0;
#define DOUT_1      P36 = 1;
#define DOUT_IN    {GPIO_InitStructure.Pin= GPIO_Pin_6 ;        GPIO_InitStructure.Mode = GPIO_PullUp;        GPIO_Inilize(GPIO_P3,&GPIO_InitStructure);}
#define DOUT_OUT   {GPIO_InitStructure.Pin= GPIO_Pin_6 ;        GPIO_InitStructure.Mode = GPIO_OUT_PP;        GPIO_Inilize(GPIO_P3,&GPIO_InitStructure);}

仿真和下载后液晶显示都正确。程序调试完成后,将SCLK恢复到P31,

下载后就不正常了液晶在闪,后检查发现程序只要操作P31口就会不正常。
请各位高手指导一下,看是什么原因?多谢!
页: [1]
查看完整版本: STC8H1K28 P3.1读写引起程序复位