/* Main.c file generated by New Project wizard
*
* Created: 周日 5月 17 2020
* Processor: AT89C52
* Compiler: Keil for 8051
*/
#include <regx52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
#define IF 10700 //中频为10.7MHz
#define FREQ_MAX 200000
#define FREQ_MIN 5000
#define FREQ_CHAN 10000
sbit K1=P3^3; //移位按键
sbit K2=P3^4; //调整加按键
sbit K3=P3^5; //调整减按键
//LCD显示
sbit RS =P0^7;
sbit RW =P0^6;
sbit EN =P0^5;
#define LCD_DATA P2
/**********设置写MB1540的总线 *********/
sbit MB1504_DATA = P1^4;
sbit CLK =P1^3;
sbit LE =P1^5;
void Delay_x10us(uint i)//i*10 us(17+26*i)us(8051_11.0592M)
{
while(i--);
}
/* LCD1602显示部分 */
bit lcd_bz() //LCD读忙检测
{
bit result;
RS=0; RW=1; EN=1;
_nop_();_nop_();_nop_();_nop_();
result = LCD_DATA&0x80;//最高位可获取LCD当前工作状态
EN=0;return result;
}
void LCD_write(uchar date,bit type) //写命令或者数据,type=0,写命令;type=1,写数据
{
while (lcd_bz());
if(type) RS=1;
else RS=0;
RW=0;EN=0;
LCD_DATA=date;_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
EN=1;
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
EN=0;
}
void write_by_xy(uchar x,uchar y)//坐标定位
{
uchar address;
if(y==0) address=0x80+x;//y=0,写第一行