#include "CH554.H"? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
#include "Debug.H"
#include "GPIO.H"
#include "HT1621.H"
#include "ADC.H"
#include "stdio.h"
#include
#include
#define uchar unsigned char
#define uint? unsigned int?
//? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0? ? ? 1? ? ? 2? ? ? 3? ? ? ?4? ? ? ?5? ? ? 6? ? ? ?7? ? ? 8? ? ? ? 9
uchar code tabe1[11] = {0xF0,0x00,0xD0,0x90,0x20,0xB0,0xF0,0x10,0xF0,0xB0};
uchar code tabe2[11] = {0xA0,0xA0,0x60,0xE0,0xE0,0xC0,0xC0,0xA0,0xE0,0xE0};
uchar a0,a1,a2,num;
/*******************************************************************************
* Function Name? : Show_Init()
* Description? ? : 顯示對應(yīng)的電壓
*******************************************************************************/
void Show_Init(uchar a0,uchar a1,uchar a2)
{
Write_1621(15,tabe1[a0],4);
Write_1621(16,tabe2[a0],4);
Write_1621(17,tabe1[a1],4);
Write_1621(18,tabe2[a1],4);
Write_1621(19,tabe1[a2],4);
Write_1621(20,tabe2[a2],4);
}
void main( )?
{
UINT16 i;
ADCInit(0);
EA=1;? ? ? ? ? ? ? //開啟全局中斷
Init_1621();? ? ? ?//初始化HT1621
HT1621_all_off();? //清空LCD顯示
while(1)
{
for(i=0;i<4;i++)
{
ADC_ChannelSelect(3);? ? ? ? ?//ADC采樣電源開啟和通道設(shè)置,采樣通道AIN3
ADC_START = 1;? ? ? ? ? ? ? ? //開啟采樣,等待采樣完成進(jìn)入中斷
while(ADC_START);? ? ? ? ? ? ?//采樣完成,ADC_START=0
num=ADC_DATA;
mDelaymS(100);? ? ? ? ? ? ? ? //等待,進(jìn)入下通道采集數(shù)據(jù)
}
a0=num/100;
a1=num%100/10;
a2=num%10;
Show_Init(a0,a1,a2);
}
}