微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 利用单片机以及24064液晶制作简单的示波器

利用单片机以及24064液晶制作简单的示波器

时间:11-23 来源:互联网 点击:

// Conversion time: 104uS
void adc_init(void)
{
ADCSR = 0x00; //disable adc
ADMUX = 0x20; //select adc input 0
ACSR = 0x80;
ADCSR = 0xEE;
}

#pragma interrupt_handler adc_isr:15
void adc_isr(void)
{
Voltage = ADCH>>2;
}

//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
PORT_Init();
adc_init();

MCUCR = 0x00;
GICR = 0x00;
//TIMSK = 0x01; //timer interrupt sources
SEI(); //re-enable interrupts
InitLCDModule();
}
flash char shi[]="示";
flash char bo[]="波";
flash char qi[]="器";
void main(void)
{
char X_Pixel = 0;
char Stick = 0;
char X_Disappear = 0;
char Y0 = 0;
char Y1 = 0;
init_devices();
CLS();
DisplayTextScreen(28,0,shi);
DisplayTextScreen(28,23,bo);
DisplayTextScreen(28,47,qi);
for (Stick=0;Stick<=64;Stick++)
{
Point(224,Stick,1);
}
while(1)
{
for(X_Pixel=0;X_Pixel<221;X_Pixel++)
{
Y1 = 64-Voltage;
Point(X_Pixel,Y1,1); //绘制电压点

if (Y1>Y0) //补竖线
{
if ( (Y1-Y0)>1 )
{
for (Stick=Y0;Stick<=Y1;Stick++)
{
Point(X_Pixel,Stick,1);
}
}
}
else if (Y1 {
if ( (Y0-Y1)>1 )
{
for (Stick=Y1;Stick<=Y0;Stick++)
{
Point(X_Pixel,Stick,1);
}
}
}
Y0 = Y1;
for (Stick=0;Stick<64;Stick++) //将前一列的数据清空
{
Clear(X_Pixel,Stick);
}
}
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top