各位好!
最近烧写一个程序到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这个片子烧写时有什么不同的地方??有遇到这种情况的朋友们吗?麻烦给在下解惑一下,感激不尽!
附件里有烧写的图 和原理图。
STC-ISP的硬件选项只保留选择内部时钟和默认频率11.0592和复位脚用作I/O口,其他选项统统不要,用4根杜邦线引出VCC、GND、P3.0、P3.1,接外挂单片机的对应脚。一定要记得要冷启动!
wulinwl 发表于 2017-7-5 06:54
STC-ISP的硬件选项只保留选择内部时钟和默认频率11.0592和复位脚用作I/O口,其他选项统统不要,用4根杜邦线引出VCC、GND、P3.0、P3.1,接外挂单片机的对应脚。一定要记得要冷启动!
fight281 发表于 2017-7-5 08:38
你好!如果正如你所说的,可能是选取了低压时不对EEPROM操作导致,可是为什么有时候又能烧进去?我用U8W没有烧录成功过,用CH340倒是烧进去不少次,你的意思是我烧进去了也只是相对于烧进去了部分内容吗?
wulinwl 发表于 2017-7-5 08:57
你说的情况我没有遇过,是因为我的开发板卡座是51标准线路,不能直接烧写STC的新式脚排列,所以用外挂方式解决,你的问题有可能是烧写器电压不稳定。 把电源线拔了,再插进去,这就是所谓的冷启动。
fight281 发表于 2017-7-5 17:04
我也以为是电压不稳,测试5V妥妥的。你说的办法我晚上回去再试一下。看看行不行。这个片子是之前有人烧过一次,不知道是不是设置了什么东西,STC15芯片能设置保护吗? 我觉得没那么悬吧。。
wulinwl 发表于 2017-7-5 17:24
如果以前在STC-ISP的硬件选项选择了下次冷启动时P3.2/P3.3为0/0才可下载程序,就需要把P3.2/P3.3接地。
wulinwl 发表于 2017-7-5 17:24
如果以前在STC-ISP的硬件选项选择了下次冷启动时P3.2/P3.3为0/0才可下载程序,就需要把P3.2/P3.3接地。 /*
* 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;
//sbit LED=P2^0;
//12864
sbit di=P1^2;//P2^6;516引脚 //寄存器选择端 H,数据; L,指令
sbit rw=P1^3;//P2^5; //读写选择端 H,读 ; L,写
sbit e=P1^5;//P2^7;// //使能信号
//sbit lcd_rst=P3^2;//P3^5; //复位脚 ,低电平有效
sbit BUSY = P2^7;//P0^7;//
sbit PSB = P3^7; //液晶使能控制
#define lcd_data P2//P0
const uint code maindisp_128X64[]=
{
/*-- 调入了一幅图像:D:companyNED2000NED2000-60W-PWM(界面改)界面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[56]=
//{
///*-- 宽度x高度=15x28 --*/
///*-- 宽度不是8的倍数,现调整为:宽度x高度=16x28 --*/
//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
//};
const uint code tempdisp_16X32[10][64]=
{
{
/*-- 调入了一幅图像:D:companyNED2000NED2000-60W-PWM(界面改) .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,
},
{
/*-- 调入了一幅图像:D:companyNED2000NED2000-60W-PWM(界面改)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,
},
{
/*-- 调入了一幅图像:D:companyNED2000NED2000-60W-PWM(界面改)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,
},
{
/*-- 调入了一幅图像:D:companyNED2000NED2000-60W-PWM(界面改)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,
},
{
/*-- 调入了一幅图像:D:companyNED2000NED2000-60W-PWM(界面改)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,
},
{
/*-- 调入了一幅图像:D:companyNED2000NED2000-60W-PWM(界面改)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,
},
{
/*-- 调入了一幅图像:D:companyNED2000NED2000-60W-PWM(界面改)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,
},
{
/*-- 调入了一幅图像:D:companyNED2000NED2000-60W-PWM(界面改)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,
},
{
/*-- 调入了一幅图像:D:companyNED2000NED2000-60W-PWM(界面改)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,
},
{
/*-- 调入了一幅图像:D:companyNED2000NED2000-60W-PWM(界面改)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
sbit k1=P3^2;
sbit 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;//P2^6;516引脚 //寄存器选择端 H,数据; L,指令
rw=1;//P2^5; //读写选择端 H,读 ; L,写
e=1;//P2^7;// //使能信号
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); //显示十位
// delayms(10);
// display_area_picture2(112,40,32,8,0,tempdisp_16X32,ge,0); //显示个位 //尝试改成一维数组
}
void display_temp() //显示温度
{
gotoxy(1,5); //以下是显示待机初始画面
lcd_w2wei(27);
// print("℃");
// lcd_wcmd(0x0e); //整体显示开,游标显示开 //解决游标丢失问题
}
void display_time() //显示时间
{
gotoxy(2,4); //以下是显示待机初始画面
lcd_w2wei(minute);
print(":");
lcd_w2wei(second);
// lcd_wcmd(0x0e); //整体显示开,游标显示开 //解决游标丢失问题
}
//延时子程序
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;
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);
}
//void lcd_ql() //清屏
//{
// lcd_wcmd(0x01);//清零
// delayms(13);
//}
/*************************************************************
* @函数名称: 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!=' ')
{
lcd_wdat(*str);
str++;
}
lcd_wcmd(0x0c);
}
/******************************************************************************************
@ 函数名称 :display_area_picture
@ 功能描述 : 显示图形
@ 参数 : x1 x的坐标0-127;y1 y坐标0-64,high:字体高度;fan,反相;×img 字符指针
@ 返回值 : width 16位的倍数,包含几个16位
@ 摘要 :显示的图像为 (high)*(16*width) ,高度最小为步进1,宽度最小步进为16位
******************************************************************************************/
void display_area_picture(uint x1,uint y1,uint high,uint width,uint fan,uint code *pin)
{
uint i,j;
uint X_byte = x1/16; //计算在列的那个位元上(一行共16个位元)
for(j=0;j
{
lcd_wcmd(0x34);
if((y1+j)>=32)
{
lcd_wcmd(0x80+j+y1-32); //下屏
lcd_wcmd(0x88+X_byte);
}
else
{
lcd_wcmd(0x80+j+y1); //上屏
lcd_wcmd(0x80+X_byte);
}
lcd_wcmd(0x30);
for(i=0;i
{
if (1 == fan)
{
lcd_wdat(~(*pin++)); //显示高8位数据
lcd_wdat(~(*pin++)); //显示低8位数据
}
else
{
lcd_wdat(*pin++); //显示高8位数据
lcd_wdat(*pin++); //显示低8位数据
}
}
}
lcd_wcmd(0x36);
}
/******************************************************************************************
@ 函数名称 :display_area_picture2
@ 功能描述 : 显示图形
@ 参数 : x1 x的坐标0-127;y1 y坐标0-64,high:字体高度;fan,反相;×img 字符指针
@ 返回值 : width 16位的倍数,包含几个16位
@ 摘要 :显示的图像为 (high)*(16*width) ,高度最小为步进1,宽度最小步进为16位
******************************************************************************************/
void display_area_picture2(uint x1,uint y1,uint high,uint width,uint fan)
{
uint i,j;
uint X_byte = x1/16; //计算在列的那个位元上(一行共16个位元)
uint *pin;
pin=&tempdisp_16X32[9][0];
for(j=0;j
{
lcd_wcmd(0x34);
if((y1+j)>=32)
{
lcd_wcmd(0x80+j+y1-32); //下屏
lcd_wcmd(0x88+X_byte);
}
else
{
lcd_wcmd(0x80+j+y1); //上屏
lcd_wcmd(0x80+X_byte);
}
lcd_wcmd(0x30);
for(i=0;i
{
if (1 == fan)
{
lcd_wdat(~(*pin++)); //显示高8位数据
lcd_wdat(~(*pin++)); //显示低8位数据
}
else
{
lcd_wdat(*pin++); //显示高8位数据
lcd_wdat(*pin++); //显示低8位数据
}
}
}
lcd_wcmd(0x36);
}
/******************************************************************************************
@ 函数名称 :delete_display_area_picture
@ 功能描述 : 显示图形
@ 参数 : x1 x的坐标0-127;y1 y坐标0-64,high:字体高度;fan,反相;
@ 返回值 : width 16位的倍数,包含几个16位
@ 摘要 :显示的图像为 (high)*(16*width) ,高度最小为步进1,宽度最小步进为16位
******************************************************************************************/
void delete_area_picture(uint x1,uint y1,uint high,uint width,uint fan)
{
uint i,j;
uint X_byte = x1/16; //计算在列的那个位元上(一行共16个位元)
for(j=0;j
{
lcd_wcmd(0x34);
if((y1+j)>=32)
{
lcd_wcmd(0x80+j+y1-32); //下屏
lcd_wcmd(0x88+X_byte);
}
else
{
lcd_wcmd(0x80+j+y1); //上屏
lcd_wcmd(0x80+X_byte);
}
lcd_wcmd(0x30);
for(i=0;i
{
if (1 == fan)
{
lcd_wdat(0xff); //显示高8位数据
lcd_wdat(0xff); //显示低8位数据
}
else
{
lcd_wdat(0); //显示高8位数据
lcd_wdat(0); //显示低8位数据
}
}
}
lcd_wcmd(0x36);
}
/******************************************************************************************
@ 函数名称 :LCD_GDRAM_CLEAR
@ 功能描述 : 无
@ 参数 : 无
@ 返回值 :
@ 摘要 : 清除绘图区RAM
******************************************************************************************/
void LCD_GDRAM_CLEAR(void)
{
uint j,i;
for(j=0;j<64;j++)
{
lcd_wcmd(0x34);
if(j<32)
{
lcd_wcmd(0x80+j); //计算行地址
lcd_wcmd(0x80); //8*Y_Dyte上下屏标志,确定列地址
}
else
{
lcd_wcmd(0x80+j-32); //计算行地址
lcd_wcmd(0x80+8); //8*Y_Dyte上下屏标志,确定列地址
}
lcd_wcmd(0x30);
for (i=0;i<16;i++)
lcd_wdat(0); //清除
}
lcd_wcmd(0x36);
}
/*************************取值******************************
************************************************************/
//void lcd_w1wei(uchar a)
//{
// switch(a)
// {
// case 0:lcd_wdat('0'); break;
// case 1:lcd_wdat('1'); break;
// case 2:lcd_wdat('2'); break;
// case 3:lcd_wdat('3'); break;
// case 4:lcd_wdat('4'); break;
// case 5:lcd_wdat('5'); break;
// case 6:lcd_wdat('6'); break;
// case 7:lcd_wdat('7'); break;
// case 8:lcd_wdat('8'); break;
// case 9:lcd_wdat('9'); break;
// }
//}
void lcd_w2wei(uchar a)
{
uchar x,y;
x=a%10;
y=a/10;;
switch(y)
{
case 0:lcd_wdat('0'); break;
case 1:lcd_wdat('1'); break;
case 2:lcd_wdat('2'); break;
case 3:lcd_wdat('3'); break;
case 4:lcd_wdat('4'); break;
case 5:lcd_wdat('5'); break;
case 6:lcd_wdat('6'); break;
case 7:lcd_wdat('7'); break;
case 8:lcd_wdat('8'); break;
case 9:lcd_wdat('9'); break;
}
switch(x)
{
case 0:lcd_wdat('0'); break;
case 1:lcd_wdat('1'); break;
case 2:lcd_wdat('2'); break;
case 3:lcd_wdat('3'); break;
case 4:lcd_wdat('4'); break;
case 5:lcd_wdat('5'); break;
case 6:lcd_wdat('6'); break;
case 7:lcd_wdat('7'); break;
case 8:lcd_wdat('8'); break;
case 9:lcd_wdat('9'); break;
}
}
//AD子程序
/**************************************定时器初始化***********************
****************************************************************************/
void Timer2Init() //50毫秒@12.000MHz
{
// T2MOD = 0; //初始化模式寄存器
// T2CON = 0; //初始化控制寄存器
// TL2 = 0xB0; //设置定时初值
// TH2 = 0x3C; //设置定时初值
// RCAP2L = 0xB0; //设置定时重载值
// RCAP2H = 0x3C; //设置定时重载值
// TR2 = 1; //定时器2开始计时
// ET2=1;
// EA=1; //开总中断
AUXR &= 0xFB; //定时器时钟12T模式
T2L = 0x00; //设置定时初值
T2H = 0x4C; //设置定时初值
AUXR |= 0x10; //定时器2开始计时
IE2=0x04;
EA=1; //开总中断
}
void t2_isr() interrupt 12 //50毫秒@12.000MHz
{
time_count++;
if(time_count==20)
{
k2=~k2;
second++;
// if(!(second%2))
// {
// gotoxy(2,5);
// print(" ");
// }
// else
// {
// gotoxy(2,5);
// print(":");
// }
time_count=0;
}
if(second==60)
{
minute++;
second=0;
}
if(minute==60)
{
hour++;
minute=0;
}
if(hour==100)
{
hour=0;
}
// display_time();
}
昨天发的回复怎么没显示?
上升沿烧写开机
战胜心魔 发表于 2017-7-6 10:29
上升沿烧写开机 void Busy(void)
{
lcd_data = 0xFF;
di = 0;
rw = 1;
e = 1;
while (1 == BUSY);
e =0 ;
}
这部分可能要改,应该是每次读取busy时要将e=1,读取busy,读取完后再e=0,若为busy=1,则要再次e=1,读取busy,读取完后再e=0。
并不是e=1后,当12864不忙的时候,busy会自动变为0,这是读数据,e要有相应的变化。
人中狼 发表于 2017-7-6 11:22
void Busy(void)
{
lcd_data = 0xFF;
人中狼 发表于 2017-7-6 11:22
void Busy(void)
{
lcd_data = 0xFF; 试试看程序有没有超出芯片容量 看看芯片型号对不对晶振是不是好的还有电源
谢谢楼主,支持分享
本帖最后由 fight281 于 2017-7-8 08:57 编辑
人中狼 发表于 2017-7-6 22:50
试试看程序有没有超出芯片容量
锂电池剩余电量检测电路设计设计了一个电路,电源用的是两节18650锂电池7.4v,现在想对这两节电池进行电量精确检测,只要求检测放电过程中的电量,因为充电的时候电池是取下来的,所以充电时候电量不用检测,在网
|