在ADS1.2环境下,下面程序1不会报错,调了一下的程序2相同程序却报错,那是为什么?
我只是调换了中断函数void __irq IRQ__eint0(void)
与函数void interrupt_init(void)
的顺序。
程序1:
#include "config.h"
#define port 0xff<<18
uint8 tab[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void output(uint8 data)
{ IO1SET|=port;
//IO1CLR|=port;
IO1CLR|=((~data)<<18);
}
void delayns(uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=0;i<50000;i++);
}
void io_init(void)
{
PINSEL1=(PINSEL1&0xfffffffc)|0x01;
PINSEL2&=(~0x08);
IO1DIR|=port;
}
void __irq IRQ__eint0(void)
{
uint8 i;
for(i=0;i<8;i++)
{
output(0x77);
delayns(20);
output(0xff);
delayns(20);
}
while((EXTINT&0x01)!=0)
{
EXTINT=0x01;
}
VICVectAddr=0;
}
void interrupt_init(void)
{
EXTMODE=EXTMODE&0x0E;
EXTPOLAR=EXTPOLAR&0x0E;
IRQEnable();
VICIntSelect=VICIntSelect&(~(1<<14));
VICVectCntl0=0x20|14;
VICVectAddr0= (uint32)IRQ__eint0;
EXTINT=0x01;
VICIntEnable=(1<<14);
}
int main (void)
{// add user source code
uint8 i;
io_init();
interrupt_init();
while(1)
{
output(tab[i]);
delayns(20);
i++;
if(i==8)
i=0;
}
return 0;
}
程序2:
#include "config.h"
#define port 0xff<<18
uint8 tab[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void output(uint8 data)
{ IO1SET|=port;
//IO1CLR|=port;
IO1CLR|=((~data)<<18);
}
void delayns(uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=0;i<50000;i++);
}
void io_init(void)
{
PINSEL1=(PINSEL1&0xfffffffc)|0x01;
PINSEL2&=(~0x08);
IO1DIR|=port;
}
void interrupt_init(void)
{
EXTMODE=EXTMODE&0x0E;
EXTPOLAR=EXTPOLAR&0x0E;
IRQEnable();
VICIntSelect=VICIntSelect&(~(1<<14));
VICVectCntl0=0x20|14;
VICVectAddr0= (uint32)IRQ__eint0;
EXTINT=0x01;
VICIntEnable=(1<<14);
}
void __irq IRQ__eint0(void)
{
uint8 i;
for(i=0;i<8;i++)
{
output(0x77);
delayns(20);
output(0xff);
delayns(20);
}
while((EXTINT&0x01)!=0)
{
EXTINT=0x01;
}
VICVectAddr=0;
}
报错情况是:Error : C2456E: undeclared name, inventing 'extern int IRQ__eint0'
main.c line 56
Error : (Serious) C2933E: type disagreement for 'IRQ__eint0'
main.c line 62
D:\ARM\interrupt\src\main.c: 0 warnings, 1 error, 1 serious error
|