找回密码
 立即注册
查看: 17|回复: 0

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

[复制链接]
  • 打卡等级:初来乍到
  • 打卡总天数:3
  • 最近打卡:2026-04-02 15:05:04
已绑定手机

2

主题

6

回帖

24

积分

新手上路

积分
24
发表于 昨天 15:53 | 显示全部楼层 |阅读模式
我这个项目是做压力传感器的,


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口就会不正常。
请各位高手指导一下,看是什么原因?多谢!
回复

使用道具 举报 送花

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

GMT+8, 2026-4-3 02:14 , Processed in 0.095481 second(s), 42 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表