发布网友 发布时间:2022-05-17 17:17
共2个回答
热心网友 时间:2023-10-31 04:48
我看了你说放置有问题,没有看到你的源代码,肯定是程序那里写错了,我也现场仿真了一下看没有问题。
我程序是安装模块化写的,发上来有点乱,想要可以加下QQ370670734 我发你参考一下。
这是主程序:
/*****************************************
*
* LCD1602电子钟 DS1302
*
*
*
******************************************/
#include "REG52.H"
#include "DS1302.H"
#include "LCD1602.H"
sbit Key_out1 = P1^3;
sbit Key_out2 = P1^4;
sbit Key_out3 = P1^5;
sbit Key_out4 = P1^6;
sbit LED_out4 = P2^2;
unsigned char value_mum = 0;
unsigned char Vata_Time1[7] = {00, 29, 10, 00, 00, 0, 00};
unsigned char Vata_Time2[7];
unsigned char Vata_Time3[3] = {00, 00, 00};
unsigned char Vata_Time4[] = {"QQ:370670734"};
unsigned char Vata_Time5[] = {"158888609310"};
unsigned char code Table_out[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39};unsigned char Clock_Xtnm;
void Scank_key(void)
{
unsigned char key;
unsigned char temp;
P3 = 0xFE;
temp = P3;
temp = temp & 0xF0;
if(temp != 0xF0)
{
Delay_1ms(10);
temp = P3;
temp = temp & 0xF0;
if(temp != 0xF0)
{
temp = P3;
switch(temp)
{
case 0xEE: key = 7; break;
case 0xDE: key = 8; break;
case 0xBE: key = 9; break;
case 0x7E: key = 6; break;
default : break;
}
while(temp != 0xF0)
{
temp = P3;
temp = temp & 0xF0;
}
LCD_crye_Pritf(0, 4);
Write_LCDcrys_DataCmd(Table_out[key]);
}
}
}
void Shuax_ds1302_ReadtemCmd(void)
{
if(Vata_Time1[0] != Vata_Time2[0])
{
Vata_Time2[0] = Vata_Time1[0];
}
if(Vata_Time1[1] != Vata_Time2[1])
{
Vata_Time2[1] = Vata_Time1[1];
}
if(Vata_Time1[2] != Vata_Time2[2])
{
Vata_Time2[2] = Vata_Time1[2];
}
LCD_crye_Pritf(0, 0);
LCD_Tank_lingCmd(Vata_Time1[2]);
LCD_Pritf(":");
LCD_Tank_lingCmd(Vata_Time1[1]);
LCD_Pritf(":");
LCD_Tank_lingCmd(Vata_Time1[0]);
}
/*
void LCD_fanyelunx_temkCmd(void)
{
}
*/
void Gont_Caindan_KeyCmd(void)
{
if(Key_out4 == 0)
{
Delay_1ms(10);
if(Key_out4 == 0)
{
LED_out4 = ~ LED_out4;
value_mum++;
if(value_mum == 4)
value_mum = 0;
while(Key_out4 == 0);
}
}
}
void LCD_Tiaokefanye_Cmd(void)
{
if(value_mum == 0)
{
Write_LCDcrys_ByteCmd(0x01);
do
{
Gont_Caindan_KeyCmd();
Read__ds1302_ReadtimeCmd(Vata_Time1);
Shuax_ds1302_ReadtemCmd();
}while(value_mum == 0);
}
else if(value_mum == 1)
{
Write_LCDcrys_ByteCmd(0x01);
do
{
Gont_Caindan_KeyCmd();
LCD_crye_Pritf(0, 3);
LCD_Tank_lingCmd(Vata_Time3[0]);
LCD_Pritf(":");
LCD_Tank_lingCmd(Vata_Time3[1]);
LCD_Pritf(":");
LCD_Tank_lingCmd(Vata_Time3[2]);
}while(value_mum == 1);
}
else if(value_mum == 2)
{
Write_LCDcrys_ByteCmd(0x01);
do
{
Gont_Caindan_KeyCmd();
LCD_crye_Pritf(0, 1);
LCD_Pritf(Vata_Time4);
}while(value_mum == 2);
}
else if(value_mum == 3)
{
Write_LCDcrys_ByteCmd(0x01);
do
{
Gont_Caindan_KeyCmd();
LCD_crye_Pritf(0, 1);
LCD_Pritf(Vata_Time5);
}while(value_mum == 3);
}
}
int main(void)
{
Init_LCDcrysRst();
LCD_crye_Pritf(0, 0);
Setup_ds1302_ReadtimeCmd(Vata_Time1);
while(1)
{
// Scank_key();
Gont_Caindan_KeyCmd();
LCD_Tiaokefanye_Cmd();
}
}
热心网友 时间:2023-10-31 04:49
你是用protues 仿真的吧,建议你检查下