完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
各位好!
最近烧写一个程序到STC15W408AS单片机中,原先用的是CH340烧写的,一直烧不进去,提示“正在检测目标单片机”,后来改用U8W编程器 也烧不进去,提示“继续检测目标单片机”。 第二天用CH340给另外一个板子是STC90的片子烧写成功,偶尔有几次不成功,但插拔下USB口就可以烧进去。当时就想这个CH340是可以的呀,于是继续又给我的STC15W408AS烧写,奇了怪了,竟然烧进去了!!提示成功,但郁闷的是我的12864上什么也不显示!后来我想了想,是不是因为程序的问题导致的。于是我只用了12864的单独程序测试,在STC90的板子上正常显示,在STC15的板子上不显示!!我很纳闷,为什么程序烧写进去了不显示?明明用的都是51的基本程序。 继续郁闷了好几天,调试无果,就是可以烧写进去,但是不显示。于是我又焊了一块STC15W408AS的板子,用CH340烧写了一下程序烧写进去了,屏幕上也显示了,心想原来是板子的问题。然后我把CH340的杜邦线拔了,重新插电的时候,屏幕上又什么都不显示了!!我断电通电好几次也不显示!于是我打算再烧写一次的时候,发现新板子居然又烧写不进去了!试了N次就是烧写不进去。但是奇怪的是有一次我在烧写的时候STC-ISP提示“正在检测目标单片机”,但是屏幕上居然又出现了程序内容,仅仅显示2.3秒又消失了。 分析了一下原因,排除了程序问题,排除了CH340的问题(我用串口助手测试正常,况且试了几十次也不可能一次都不行把),剩下只有单片机的问题,奇怪的是我再烧写时在硬件选项中也没有点涉及到EEPROM的选项,程序中也没有对ISP进行操作,没有占用串口,感觉就像烧进去了 但很快又被擦除了,但是从我偶然一次又显示出来看的话,貌似程序没有被激活一样,当时偶然激活了一下又灭了。实在不明白是什么原因。。难道STC15W408AS这个片子烧写时有什么不同的地方??有遇到这种情况的朋友们吗?麻烦给在下解惑一下,感激不尽! 附件里有烧写的图 和原理图。 |
|
相关推荐
34个回答
|
|
STC-ISP的硬件选项只保留选择内部时钟和默认频率11.0592和复位脚用作I/O口,其他选项统统不要,用4根杜邦线引出VCC、GND、P3.0、P3.1,接外挂单片机的对应脚。一定要记得要冷启动!
评分
|
||
|
||
wulinwl 发表于 2017-7-5 06:54 你好!如果正如你所说的,可能是选取了低压时不对EEPROM操作导致,可是为什么有时候又能烧进去?我用U8W没有烧录成功过,用CH340倒是烧进去不少次,你的意思是我烧进去了也只是相对于烧进去了部分内容吗? |
|
|
|
fight281 发表于 2017-7-5 08:38 你说的情况我没有遇过,是因为我的开发板卡座是51标准线路,不能直接烧写STC的新式脚排列,所以用外挂方式解决,你的问题有可能是烧写器电压不稳定。 |
|
|
|
我也以为是电压不稳,测试5V妥妥的。你说的办法我晚上回去再试一下。看看行不行。这个片子是之前有人烧过一次,不知道是不是设置了什么东西,STC15芯片能设置保护吗? 我觉得没那么悬吧。。 |
|
|
|
|
|
fight281 发表于 2017-7-5 17:04 如果以前在STC-ISP的硬件选项选择了下次冷启动时P3.2/P3.3为0/0才可下载程序,就需要把P3.2/P3.3接地。 |
|
|
|
你好!现在是有个板子可以下载,但是没有反应。因为这个板子上只有12864,所以像是不是1T单片机的问题,我在板子上接个了LED灯测试。 1)首先将LED=~LED放在定时器中测试。LED初值为0。 结果:灯亮,但不闪烁。 2)将LED=~LED放在主程序WHILE中测试。LED初值为0。 结果:灯不亮,也不闪烁。 3)注释掉所有12864子程序和定时器。将LED=~LED放在主程序WHILE中测试。LED初值为0。 结果:灯闪烁。 4)取消定时器的注释。将LED=~LED放在主程序WHILE中测试。LED初值为0。 结果:灯不亮,也不闪烁。 5)注释定时器,取消12864的子程序。将LED=~LED放在主程序WHILE中测试。LED初值为0。 结果:灯不亮,也不闪烁。 5.1)将12864中display_bright(99);注释。LED初值为0。 结果:灯不亮,也不闪烁。 5.2)将12864中display_temp();也注释。 结果:灯不亮,也不闪烁。 5.3)将12864中 displaymain();也注释。 结果:灯不亮,也不闪烁。 5.4)将12864初始化程序也注释,回到第三部.....一切正常。 6)发现定时器程序中有一个12864的子程序,注释之。将LED放入定时器中断中。 结果:一切正常。 结论:程序应该是烧写进去了。但是由于12864的子程序导致程序运行异常,甚至可以影响到定时器中断。 检查下P2口的硬件,P20排阻异常,为12M欧姆,其余为1.3K。软件中设置P2M0 P2M1双向没有作用。于是在软件中将12864所有用到的口都付了0值,PSB赋1值。结果正常,灯还在闪。反向赋值后(即0改成1,1改成0)也为正常,所以应该不是短路造成单片机内部烧坏或者电压拉低。所以应该不是硬件的问题。但是软件的话我直接移植到51上都是正常的啊,实现想不通了。代码拷贝下来大家帮忙看下 哪里出问题了? /* * Copyright (c) * * All rights reserved. * 文件名称:PWM.c * 文件标识: * 摘要: simple version * 当前版本: * 作者: makui281 * 完成日期: 2017-6-22 */ //头文件及定义 #include #include typedef unsigned char uchar; typedef unsigned int uint; //T2 uchar hour=0; uchar minute=0; uchar second=0; uchar time_count=0; //***it LED=P2^0; //12864 ***it di=P1^2;//P2^6;516引脚 //寄存器选择端 H,数据; L,指令 ***it rw=P1^3;//P2^5; //读写选择端 H,读 ; L,写 ***it e=P1^5;//P2^7;// //使能信号 //***it lcd_rst=P3^2;//P3^5; //复位脚 ,低电平有效 ***it BUSY = P2^7;//P0^7;// ***it PSB = P3^7; //液晶使能控制 #define lcd_data P2//P0 const uint code maindisp_128X64[]= { /*-- 调入了一幅图像:界面5.bmp --*/ /*-- 宽度x高度=127x63 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=128x63 --*/ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x87,0xF0,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x84,0x90,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x02, 0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x53,0xA2, 0x80,0x83,0x1B,0x33,0x61,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x62, 0x80,0x84,0x8C,0xC9,0x91,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x22, 0x80,0x87,0x88,0x89,0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x02, 0x80,0x84,0x08,0x89,0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x02, 0x80,0x84,0x88,0x89,0x11,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x02, 0x81,0xC3,0x1D,0xDD,0xE1,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x12, 0x80,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x22, 0x80,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC2, 0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x22, 0x87,0xF2,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x22, 0x84,0x90,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x22, 0x80,0x86,0x69,0x0E,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x22, 0x80,0x82,0x36,0x91,0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE2, 0x80,0x82,0x24,0x9F,0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x22, 0x80,0x82,0x24,0x90,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x22, 0x80,0x82,0x24,0x91,0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x22, 0x81,0xC7,0x76,0xCE,0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x22, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x22, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x30,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x8F,0x80,0x20,0x10,0x20,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x84,0x40,0x00,0x10,0x20,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x84,0x5A,0x67,0x94,0x7E,0x87,0x1C,0xE1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x87,0x8E,0x29,0x1A,0x23,0x48,0xA5,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x84,0x48,0x29,0x12,0x22,0x4F,0x90,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x84,0x48,0x26,0x12,0x22,0x48,0x08,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x84,0x48,0x28,0x12,0x2A,0x48,0xA5,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x8F,0x9C,0x7F,0x3B,0x17,0x67,0x39,0xC1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x08,0x80,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x08,0x80,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x07,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; const uint code tempdisp_16X32[10][64]= { { /*-- 调入了一幅图像:0.bmp --*/ /*-- 宽度x高度=15x31 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=16x31 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x0F,0xF0, 0x1C,0x38,0x18,0x18,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C, 0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x18,0x18,0x1C,0x38,0x0F,0xF0,0x07,0xE0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }, { /*-- 调入了一幅图像:1.bmp --*/ /*-- 宽度x高度=15x31 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=16x31 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0xC0, 0x03,0xC0,0x07,0xC0,0x1E,0xC0,0x1C,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0, 0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }, { /*-- 调入了一幅图像:2.bmp --*/ /*-- 宽度x高度=15x31 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=16x31 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x0F,0xF0, 0x1C,0x38,0x30,0x1C,0x30,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x30, 0x00,0x60,0x00,0xC0,0x03,0x80,0x07,0x00,0x0C,0x00,0x18,0x00,0x3F,0xFC,0x3F,0xFC, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }, { /*-- 调入了一幅图像:3.bmp --*/ /*-- 宽度x高度=15x31 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=16x31 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xC0,0x0F,0xF0, 0x1C,0x38,0x38,0x18,0x30,0x18,0x00,0x18,0x00,0x30,0x03,0xE0,0x03,0xF0,0x00,0x18, 0x00,0x0C,0x00,0x0C,0x00,0x0C,0x30,0x0C,0x38,0x1C,0x18,0x38,0x0F,0xF0,0x07,0xC0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }, { /*-- 调入了一幅图像:4.bmp --*/ /*-- 宽度x高度=15x31 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=16x31 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x70, 0x00,0xF0,0x00,0xF0,0x01,0xB0,0x03,0xB0,0x03,0x30,0x06,0x30,0x0E,0x30,0x0C,0x30, 0x18,0x30,0x38,0x30,0x3F,0xFC,0x3F,0xFC,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }, { /*-- 调入了一幅图像:5.bmp --*/ /*-- 宽度x高度=15x31 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=16x31 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF8,0x0F,0xF8, 0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x1B,0xE0,0x3F,0xF0,0x38,0x18,0x00,0x1C, 0x00,0x0C,0x00,0x0C,0x00,0x0C,0x30,0x0C,0x38,0x18,0x18,0x38,0x0F,0xF0,0x07,0xC0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }, { /*-- 调入了一幅图像:6.bmp --*/ /*-- 宽度x高度=15x31 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=16x31 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xE0,0x07,0xF0, 0x0C,0x38,0x18,0x1C,0x18,0x0C,0x30,0x00,0x33,0xE0,0x37,0xF0,0x3C,0x38,0x38,0x1C, 0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x18,0x18,0x1C,0x38,0x0F,0xF0,0x03,0xE0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }, { /*-- 调入了一幅图像:7.bmp --*/ /*-- 宽度x高度=15x31 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=16x31 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFC,0x3F,0xFC, 0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x60,0x00,0x60,0x00,0xC0,0x00,0xC0,0x01,0x80, 0x01,0x80,0x03,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }, { /*-- 调入了一幅图像:8.bmp --*/ /*-- 宽度x高度=15x31 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=16x31 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x0F,0xF0, 0x1C,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x0C,0x30,0x07,0xE0,0x0F,0xF0,0x18,0x38, 0x38,0x1C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x1C,0x18,0x0F,0xF0,0x07,0xE0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }, { /*-- 调入了一幅图像:9.bmp --*/ /*-- 宽度x高度=15x31 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=16x31 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xC0,0x0F,0xF0, 0x1C,0x38,0x38,0x18,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x38,0x1C,0x1C,0x3C, 0x0F,0xEC,0x07,0xCC,0x00,0x0C,0x30,0x18,0x38,0x18,0x18,0x30,0x1F,0xE0,0x07,0xC0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, } }; //stytem define ***it k1=P3^2; ***it k2=P3^3; /***************函数声明***************** *****************************************/ //延迟函数 void delayus(uint i); void delayms(uint i); //12864函数 void Busy(void); void lcd_wcmd(uchar cmd); void lcd_wdat(uchar dat); void lcd_init(void); void lcd_w2wei(uchar a); //void lcd_w1wei(uchar a); void clear_ddram(void); //void lcd_ql(); void gotoxy(uint y, uint x); void print(uchar *str); void display_area_picture(uint x1,uint y1,uint high,uint width,uint fan,uint code *pin); void display_area_picture2(uint x1,uint y1,uint high,uint width,uint fan); void delete_area_picture(uint x1,uint y1,uint high,uint width,uint fan); void LCD_GDRAM_CLEAR(void); //显示函数 void displaymain(); void display_bright(uint bright); void display_time(); void display_temp(); //定时器 void Timer2Init(); int main(void) { k2=0; P2=0xff;//这里是赋值测试硬件是否存在短路现象拉低单片机电压 di=1;// rw=1;// e=1;// PSB=0; // lcd_init(); //这里全部注释掉程序才能正常运行!!!!!!! // displaymain(); //显示主界面 // delayms(20); // display_time(); //显示时间 // delayms(1); // display_temp(); // delayms(20); // display_bright(99); // delayms(20); Timer2Init(); while(1) { // delayms(500); // k2=~k2; } } void displaymain() //显示主界面 { LCD_GDRAM_CLEAR(); //清屏 clear_ddram(); display_area_picture(0,0,64,8,0,maindisp_128X64); //显示主界面1 } void display_bright(uint bright) //显示当前亮度值 { uint bai,shi,ge; // LCD_GDRAM_CLEAR(); //清屏 // clear_ddram(); bai=bright/100; shi=bright%100/10; ge=bright%10; display_area_picture2(80,33,28,1,0); //显示百位 delayms(1); display_area_picture2(96,33,28,1,0); //显示十位 } void display_temp() //显示温度 { gotoxy(1,5); //以下是显示待机初始画面 lcd_w2wei(27); } void display_time() //显示时间 { gotoxy(2,4); //以下是显示待机初始画面 lcd_w2wei(minute); print(":"); lcd_w2wei(second); } //延时子程序 void delayus(uint i) { while(i--); } void delayms(uint i) { uint n; for(n=i;n>0;n--) { delayus(1000); } } //12864子程序 /************************************************************* * @函数名称: Busy * @参数: none * @返回值: none * @摘要: 忙检测* *************************************************************/ void Busy(void) { lcd_data = 0xFF; di = 0; rw = 1; e = 1; while (1 == BUSY); e =0 ; } /************************************************************* * @函数名称: lcd_wcmd * @参数: command 命令字 * @返回值: none * @摘要: 写命令字 *************************************************************/ void lcd_wcmd(uchar cmd) { Busy(); di=0; rw=0; e=0; delayus(5); lcd_data=cmd; e=1; delayus(10); e=0; } /************************************************************* * @函数名称: lcd_wdat * @参数: Data 命令字 * @返回值: none * @摘要: 写字节数据 *************************************************************/ void lcd_wdat(uchar dat) { Busy(); di=1; rw=0; e=0; delayus(5); lcd_data=dat; e=1; delayus(10); e=0; } /************************************************************* * @函数名称: init_lcd * @参数: 命令字 * @返回值: none * @摘要: 写字节数据 *************************************************************/ void lcd_init(void) { // lcd_rst=0; // delayms(5); // lcd_rst=1; //RST是接电阻直接到5V上的,所以这里注释了。 PSB=0; delayms(5); PSB=1; lcd_wcmd(0x30); //基本指令集 delayus(100); lcd_wcmd(0x30); delayus(100); lcd_wcmd(0x0c); //显示开,关光标 delayus(100); lcd_wcmd(0x01); //清除显示 delayms(5); lcd_wcmd(0x06); //光标的移动方向 } /****************************************************************************************** * 函数名称 :clear_ddram * 功能描述 : 清DDRAM * 参数 : none * 返回值 : * 摘要 : 清除DDRAM,=== 清屏 ******************************************************************************************/ void clear_ddram(void) { lcd_wcmd(0x30); lcd_wcmd(0x01); lcd_wcmd(0x34); lcd_wcmd(0x30); } /************************************************************* * @函数名称: gotoxy * @参数: y:第几行 x:第几位 * @返回值: none * @摘要: 指定要显示字符的坐标:用于字库显示 *************************************************************/ void gotoxy(uint y, uint x) { lcd_wcmd(0x30); if(y==1) lcd_wcmd(0x80|x); if(y==2) lcd_wcmd(0x90|x); if(y==3) lcd_wcmd((0x80|x)+8); if(y==4) lcd_wcmd((0x90|x)+8); } /************************************************************* * @函数名称: printf * @参数: *str 存放编码字符的地址; * @返回值: none * @摘要: 液晶显示字符串程序 :用于字库显示,送出字符编码 *************************************************************/ void print(uchar *str) { while(*str!=' |