单片机控制12864产生正弦波的程序(原创)

上传人:飞*** 文档编号:43386516 上传时间:2018-06-05 格式:DOC 页数:14 大小:57.50KB
返回 下载 相关 举报
单片机控制12864产生正弦波的程序(原创)_第1页
第1页 / 共14页
单片机控制12864产生正弦波的程序(原创)_第2页
第2页 / 共14页
单片机控制12864产生正弦波的程序(原创)_第3页
第3页 / 共14页
单片机控制12864产生正弦波的程序(原创)_第4页
第4页 / 共14页
单片机控制12864产生正弦波的程序(原创)_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《单片机控制12864产生正弦波的程序(原创)》由会员分享,可在线阅读,更多相关《单片机控制12864产生正弦波的程序(原创)(14页珍藏版)》请在金锄头文库上搜索。

1、电子科技大学吴鉴鹰 #include / SFR declarations #include #include #include #define uchar unsigned char #define uint unsigned int uchar i,j,colour=1,T=0; #define Lcd_Bus P5 /*char code seg360 = 0x80,0x82,0x84,0x86,0x88,0x8b,0x8d,0x8f,0x91,0x94, 0x96,0x98,0x9a,0x9c,0x9e,0xa1,0xa3,0xa5,0xa7,0xa9, 0xab,0xad,0xaf,

2、0xb1,0xb4,0xb6,0xb8,0xba,0xbc,0xbe, 0xbf,0xc1,0xc3,0xc5,0xc7,0xc9,0xcb,0xcc,0xce,0xd0, 0xd2,0xd3,0xd5,0xd7,0xd8,0xda,0xdc,0xdd,0xdf,0xe0, 0xe2,0xe3,0xe4,0xe6,0xe7,0xe8,0xea,0xeb,0xec,0xed, 0xee,0xef,0xf0,0xf2,0xf3,0xf3,0xf4,0xf5,0xf6,0xf7, 0xf8,0xf9,0xf9,0xfa,0xfb,0xfb,0xfc,0xfc,0xfd,0xfd, 0xfe,0xfe

3、,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfe, 0xfe,0xfd,0xfd,0xfc,0xfc,0xfb,0xfb,0xfa,0xf9,0xf9, /*0xf8,0xf7,0xf6,0xf5,0xf4,0xf4,0xf3,0xf2,0xf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0x47,0x49,0x4b,0x4d,0x4f,0x51,0x53,0x55,0x58,0x5a,0x5c,0x5e,0x60,0x62,0x65,0x67, 0x69,0x6b,0x6d,0x70,0x72,0x74,0x76,0x78,0x7b,0x7d ;*/#define SYSCLK 22118400 / SYSCLK frequency in Hz #define INT_DEC 256 / integrate and

8、 decimate ratio #define _Nop() _nop_() /#define FIRST_ADDR 0 /- / 16-bit SFR Definitions for F02x /-sfr16 DP = 0x82; / data pointer sfr16 TMR3RL = 0x92; / Timer3 reload value sfr16 TMR3 = 0x94; / Timer3 counter sfr16 ADC0 = 0xbe; / ADC0 data sfr16 ADC0GT = 0xc4; / ADC0 greater than window sfr16 ADC0

9、LT = 0xc6; / ADC0 less than window sfr16 RCAP2 = 0xca; / Timer2 capture/reload sfr16 T2 = 0xcc; / Timer2 sfr16 RCAP4 = 0xe4; / Timer4 capture/reload sfr16 T4 = 0xf4; / Timer4 sfr16 DAC0 = 0xd2; / DAC0 data sfr16 DAC1 = 0xd5; / DAC1 data /- / 液晶接口定义 /-/#define LEDCTL0Low P4 /#define LEDCTL0High P4|=0

10、x01;#define LCDELow P4 #define LCDEHigh P4|=0x02;#define LCDRWLow P4 #define LCDRWHigh P4|=0x04;#define LCDRSLow P4 #define LCDRSHigh P4|=0x08;#define LCDPSBLow P4 #define LCDPSBHigh P4|=0x10;/=/ uchar num; uint delay_time; /*-*/void SYSCLK_Init (void); void PORT_Init (void);/- / /-void delay(unsign

11、ed int t) unsigned int k,j;for(k=0;k0) write_data(*s);s+;delay(50);delay(100); */void hzkdis(unsigned char code*s) while(*s0) write_data(*s); s+; delay(50); /*-首屏显示-*/- / 液晶显示内容 /-/*void zero_screen() write_com(0x01);delay18(10000);/write_com(0x80);/display(“电子科技大学“);write_com(0x90);/display(“省单片机精品

12、课程“);display(“C8051F020 开发板“);write_com(0x88);/display(“C8051F020 开发板“);display(“ QQ:1811728618 “);/write_com(0x98);/display(“ QQ:1811728618 “); */*-显示字符串-*/ void ceshi() write_com(0x01); /清除显示,并且设定地址指针为 00H delay(5);write_com(0x80); /第一行(如果是地址是:80H,即 LCD 的第一行的第一个位置显示) hzkdis(“电子科技大学“);write_com(0x90);/第二行(如果是地址是:90H,即 LCD 的第二行的第一个位置显示) hzkdis(“通信与信息工程“);write_com(0x88); /第三行(如果是地址是:88H,即 LCD 的第二行的第一个位置显示) hzkdis(“电子信息工程“);write_com(0x98); /第四行(如果是地址是:98H,即 LCD 的第二行的第一个位置显示) hzkdis(“郑海波测试程序“); /*-初始化 LCD 屏-

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号