#include <iom16v.h>
#include <macros.h>
#define uchar unsigned char
#define uint unsigned int
uchar num;
#pragma interrupt_handler miao:9
#pragma data:code
const table[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,
0x5E,0x79,0x71};
void delay(uint ms)
{
uint i,j;
for (i=0;i<ms;i++)
for (j=0;j<1141;j++);
}
void show(uchar j,uchar k)
{
PORTA=table[k];
delay(10);
PORTC=table[j];
delay(10);
}
void miao (void)
{
uchar a,b;
TCNT1H=0X85;
TCNT1L=0XED;
a=num%10;
b=num/10;
show(a,b);
}
void main(void)
{
uint pre=0,cur=0;
uchar j=0,k=0;
DDRD=0x00;
DDRA=0xff;
DDRC=0xff;
TCCR1B=0X04;
TCNT1H=0X85;
TCNT1L=0XED;
TIMSK|=BIT(2);
SREG|=BIT(7);
show(j,k);
delay(10);
while(1)
{
cur = PIND&0x01;
if(pre&(cur^pre)) num++;
delay(1);
pre=cur;
}
}
这样一个程序,用JTAG口仿真时,为什么数码管连接PA口的那个可以正常显示,连接PC口的那个却显示不正常。(实现的功能是计脉冲,PA口显示10位,PC口显示个位。) |