- 打卡等级:初来乍到
- 打卡总天数:5
- 最近打卡:2024-11-03 23:32:15
注册会员
- 积分
- 61
|
发表于 2024-10-28 21:52:28
|
显示全部楼层
本帖最后由 retsen 于 2024-10-28 21:57 编辑
程序我认为写的是没有问题的,但开机还是不跑,有点头大了,软件的功能就是判断到P24断开VDD的状态就执行下电时序,执行PON =0 ; Delayms(200); DD_reset =0; Touch_reset=0;软件功能非常简单,应该是我的写法有问题,但编译是PASS的。下面是源码,请帮忙看下是什么问题,甚谢甚谢!
#include "stc8H.h"
//#include "intrins.h"
void GPIO_Init(void); //
void Delayms(int t1);
void Power_off(void);
sbit Touch_reset = P0^3; //OUTPUT
sbit DD_reset = P1^6; //OUTPUT
sbit Scan_off = P2^4; //INPUT Scan Power Switch
sbit PON = P3^5; //LCD ON
sbit POFF = P2^7; //MAIN Board POWER OFF
//================================================================//
void GPIO_Init(void)
{
P_SW2 |= 0x80;
P0M1 = 0x00; P0M0 = 0xFF; //推挽输出
P1M1 = 0x00; P1M0 = 0xFF; //推挽输出
P2M1 = 0x00; P2M0 = 0xEF; //P24准双向IO,其余推挽输出
P3M1 = 0x00; P3M0 = 0xFF; //推挽输出
P4M1 = 0x00; P4M0 = 0xFF; //推挽输出
P5M1 = 0x00; P5M0 = 0xFF; //推挽输出
P6M1 = 0x00; P6M0 = 0xFF; //推挽输出
P7M1 = 0x00; P7M0 = 0xFF; //推挽输出
}
//================================================================//
void Delayms(int t1)
{
unsigned int i;
do
{
i=1000; //MAIN_Fosc/12000//1T=0.083us ,1ms=12000*1T
while(--i);
}
while(--t1);
}
//================================================================//
void Power_off()
{
POFF=0; //主板Power off
PON =0;
Delayms(200);
DD_reset=0;
Touch_reset=0;
}
//================================================================//
void main()
{
GPIO_Init();
Scan_off=1; //开机RC上电,软件不用控制,仅控制关机时序;
if(Scan_off!=1) // Scan_off 开机状态接VCC,关闭后,为悬空,我后面加下拉电阻
{
Power_off();
}
}
//================================================================//
|
|