仿真图:其中左边的的温度传感器等AD转换与本例子无关
#include “iom48v.h”
#include “macros.h”
#define uchar unsigned char
#define uint unsigned int
#define KEY_Press keycode!=0x00
#pragma interrupt_handler T1_refresh: 12
void delay(uint a)
{
while(a–);
}
const uchar disp[] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,0xA7,0xA1,0x86,0x8E};
uchar segcode[4]={0XFF,0XFF,0XFF,0XFF}; //段码 (存放译码值)
uchar data[4]; //显示数据
uchar keycode; //判断按键位置
uchar n=0; //显示刷新标志
uchar key=0; //键值 PINB!=0X0F
uchar digit=0;
/IO口初始化函数/
void IO_Init(void)
{
DDRB = 0xF0;
PORTB = 0x0F; //上拉
DDRC = 0xFF;
PORTC = 0xFF;
DDRD = 0xFF;