请教高手

2019-03-24 19:43发布

本人做了个光源,遇到疑问请各位高手不吝赐教。此光源采用PWM调光,采用STC12CLE5A48S2单片机,LCD显示LED光源的亮度,定时器1作为串口波特率发生器,定时器0用来产生PWM方波。程序在不加EEPROM读写子程序,光源能正常通过按键进行调光,但是在加了EEPROM读写子程序,在有调光按键按下时,光源都会产生闪烁。听别人说,是EEPROM子程序和其他程序在占用硬件上有冲突,但是还是不懂,不知道哪边有冲突。麻烦高手指点一下,谢谢喽。如果需要程序我可以把程序附上,如果我有什么说不清楚的地方,请指出了,我可以详细再说下。再谢。 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
12条回答
whwshiyuan1984
2019-03-25 06:35
C语言写的  我分几部分给您检查下  谢谢
先一些变量的定义
#define uchar unsigned char
#define uint unsigned int
#define CTRL  0x2F
#define databus  P0
#define DATA_FLASH_START_ADDRESS 0x00
#define ENABLE_ISP 0x82
sbit  CS1 = P2^3;
sbit  RES = P2^4;
sbit  A0 = P2^5;
sbit  WR = P2^6;
sbit  RD = P2^7;

sbit key1 = P1^5;
sbit key2 = P1^6;
sbit DIM = P1^3;

bit flag1 = 0;
bit flag2 = 0;

uchar power;
uint y=1;

uint count_up ; //增按键计数值
uint count_down ; //减按键计数值
uchar contrast;
uint eeprom_address;


uchar code fenhao[]=
{
0x0F,0x10,0x0F,0x00,0x07,0x18,0x00,0x00,0x00,0x84,0x38,0xC0,0x78,0x84,0x78,0x00,//%
};

uchar code digit[]=
{
0x00,0x07,0x08,0x10,0x10,0x08,0x07,0x00,0x00,0xF0,0x08,0x04,0x04,0x08,0xF0,0x00,//0
0x00,0x08,0x08,0x1F,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0xFC,0x04,0x04,0x00,0x00,//1
0x00,0x0E,0x10,0x10,0x10,0x11,0x0E,0x00,0x00,0x0C,0x14,0x24,0x44,0x84,0x0C,0x00,//2
0x00,0x0C,0x10,0x11,0x11,0x12,0x0C,0x00,0x00,0x18,0x04,0x04,0x04,0x88,0x70,0x00,//3
0x00,0x00,0x03,0x04,0x08,0x1F,0x00,0x00,0x00,0xE0,0x20,0x24,0x24,0xFC,0x24,0x00,//4
0x00,0x1F,0x10,0x11,0x11,0x10,0x10,0x00,0x00,0x98,0x84,0x04,0x04,0x88,0x70,0x00,//5
0x00,0x07,0x08,0x11,0x11,0x18,0x00,0x00,0x00,0xF0,0x88,0x04,0x04,0x88,0x70,0x00,//6
0x00,0x1C,0x10,0x10,0x13,0x1C,0x10,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,//7
0x00,0x0E,0x11,0x10,0x10,0x11,0x0E,0x00,0x00,0x38,0x44,0x84,0x84,0x44,0x38,0x00,//8
0x00,0x07,0x08,0x10,0x10,0x08,0x07,0x00,0x00,0x00,0x8C,0x44,0x44,0x88,0xF0,0x00,//9
};

uchar code bangtu[]=              //柱状图 15*30
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x03,0x03,0x07,0x07,0x0F,0x0F,0x1F,0x1F,0x3F,0x3F,0x7F,0x7F,0xFF,0xFF,0xFF,

0x01,0x01,0x03,0x03,0x07,0x07,0x0F,0x0F,0x1F,0x1F,0x3F,0x3F,0x7F,0x7F,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};

uchar code off[]=
{
0x07,0x08,0x10,0x10,0x10,0x08,0x07,0x00,0xF0,0x08,0x04,0x04,0x04,0x08,0xF0,0x00,//O
};

uchar code gong[]=
{
0x00,0x20,0x20,0x20,0x3F,0x20,0x28,0x28,0x08,0x09,0xFE,0x08,0x08,0x0F,0x00,0x00,
0x20,0x30,0x20,0x20,0xC0,0x42,0x44,0x88,0x30,0xC4,0x04,0x06,0x04,0xF8,0x00,0x00,//功
};

uchar code lv[]=
{
0x00,0x30,0x28,0x25,0x20,0x26,0xAC,0x75,0x26,0x24,0x28,0x25,0x28,0x20,0x20,0x00,
0x10,0x50,0x90,0x10,0x10,0x50,0xD0,0x7F,0x50,0xD0,0x30,0x10,0x90,0x50,0x10,0x00,//率
};


//******** Initial System ********


void InitialSystem();
void InitialIO();
void Initial_timer0();
void Initial_Serial();


//******** Initial System  End********

//******** Key1_scan ******************************

void Key1_scan();

//******** Key1_scan End******************************

//******** Key2_scan ******************************

void Key2_scan();

//******** Key2_scan End******************************


//*********Upkey***************************************

void Upkey();

//*********Upkey End************************************

//*********Downkey***************************************

void Downkey();

//*********Downkey End************************************

//******** PWM_P13 ******************************
uchar  duty ;

uchar PWM_P13();
//******** PWM_P13 End******************************

//******** Delay ******************************
void Delay(uint time);

//******** Delay End******************************

一周热门 更多>