📄 ad2disp.c
字号:
//ICC-AVR application builder : 2005-6-5 18:27:12
// Target : M16
// Crystal: 7.3728Mhz
#include <iom16v.h>
#include <macros.h>
#include "time.h"
#include "Display.h"
#include "key.h"
#include "ADC.h"
extern const unsigned char ADChannel;
extern unsigned int AdValue[8];
extern unsigned char AdP;
extern unsigned char time_flag;
extern unsigned char keyflag[4];
extern unsigned char AdFlag;
extern unsigned char pwm;
unsigned char Itrans[4]={0,241,100,88};
void port_init(void)
{
PORTA = 0xFF;
DDRA = 0x00;
PORTB = 0xFF;
DDRB = 0x00;
PORTC = 0xFF; //m103 output only
DDRC = 0x00;
PORTD = 0xFF;
DDRD = 0x00;
}
//call this routine to initialise all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
timer1_init();
disp_init();
adc_init();
timer2_init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x40; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialised
}
//
void main(void)
{
unsigned char key=0;
unsigned long result=0;
init_devices();
//insert your functional code here...
while(1)
{
time_flag=0;
AdFlag=0;
adc_start();
while(!AdFlag);
pwm=(unsigned char)(AdValue[7]>>2);
pwm_change(pwm);
if(key)
{
if(key==4)
result=0;
else
{
result=(10*(long)AdValue[3]*Itrans[key])/AdValue[5];
}
display((unsigned int)(result),0);
}
display(AdValue[3],1);
display(AdValue[5],2);
display(AdValue[7]*5,3);
while(!time_flag)
key=ReadKey();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -