这个程序提示ADC_ADDR没有定义,但是我在ADC_INIT()里面已经定义过了,让后我在中断程序中重新定义一边,就出现了很多的错误, 如果您有做过TLV1578,希望您能发一份给我参考一下 非常感谢 邮箱:lou0908@126.com
#pragma CODE_SECTION(vect,"vect") //#define ADC_ADDR (int *)0x0fffe unsigned int *pmem=0; #define IMR *(pmem+0x0000) #define IFR *(pmem+0x0001) #define PMST *(pmem+0x001d) #define SWCR *(pmem+0x002b) #define SWWSR *(pmem+0x0028) #define CLKMD *(pmem+0x0058) #define ST1 *(pmem+0x007) #define PRD0 *(pmem+0x0025) /* timer0 period register */ #define TCR0 *(pmem+0x0026) /* timer0 control register */
int output[256]; int length;
/*--------------------------------------------------------------** **函数原型:void cpu_init() ** **函数功能:CPU初始化 ** **入口参数:无 ** **--------------------------------------------------------------*/ void cpu_init() /*初始化DSP*/ { asm(" ssbx intm"); asm(" ssbx xf "); //总清零 PMST=0x1c00; // SWWSR=0x0000; //不插入等待时间 //SWCR=0x0001; // IFR=0xffff; //消除所有尚未处理完成的中断 IMR=0x01; //开中断0 CLKMD=0x1007; //PLL=PLL x 2 //asm(" rsbx xf "); //打开数据口 asm(" rsbx intm"); //开放中断 } /*-----------------------------------------------------------** **函数原型:void ad_init() ** **函数功能:实现tlv1578的初始子的写入 ** **-----------------------------------------------------------*/ void ad_init() { ioport unsigned int *ADC_ADDR; ADC_ADDR=(unsigned int *)0xfffe; *ADC_ADDR=0x0080; asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); *ADC_ADDR=0x0140; asm("nop"); asm("nop"); asm("nop"); asm("nop"); } /*------------------------------------------------------------** **函数原型:interrupt void INT0(void) ** **函数功能:采样中断程序 ** **------------------------------------------------------------*/ interrupt void INT0(void) { asm(" rsbx xf "); //发出读信号,A/D受到数据后开始下一个数据采样 asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); output[length]=*ADC_ADDR; length++; length%=256; if(length==0) { asm(" nop"); //此处设软件断点 } asm("nop"); asm("ssbx xf"); }
/*------------------------------------------------------------** **函数原型:void main ** **函数功能:主函数 ** **------------------------------------------------------------*/ void main() { cpu_init(); ad_init(); for(;;) { }; } /*------------------------------------------------------------** **函数原型:void vect() ** **函数功能:中断矢量入口参数 ** **------------------------------------------------------------*/
void vect() { asm(" .ref _c_int00"); asm(" .ref _INT0");
asm(" b _c_int00"); /* reset */ asm(" nop"); asm(" nop"); asm(" rete"); /* nmi */ asm(" nop"); asm(" nop"); asm(" nop"); asm(" rete"); // asm(" nop"); asm(" nop"); asm(" nop"); asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop"); asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop"); asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop"); asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop"); asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop"); asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete"); asm(" nop"); asm(" nop"); asm(" nop"); asm(" b _INT0"); /* int0 */ asm(" nop"); asm(" nop"); asm(" nop"); asm(" rete"); /* int1 */ asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete"); /* int2 */ asm(" nop"); asm(" nop");
asm(" nop"); asm(" nop"); /* tint0 */ asm(" nop"); asm(" nop");
asm(" rete"); /* brint0 */ asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete"); /* bxint0 */ asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete"); /* dmac0 */ asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete"); /* tint1 */ asm(" nop"); asm(" nop"); asm(" nop");
asm(" nop"); asm(" nop"); /* int3 */ asm(" nop"); asm(" nop");
asm(" rete"); /* hpint */ asm(" nop"); asm(" nop"); asm(" nop");
asm(" rete "); /* brint1 */ asm(" nop"); asm(" nop"); asm(" nop"); asm(" rete"); /* bxint1 */ asm(" nop"); asm(" nop"); asm(" nop"); asm(" rete"); /* dmac4 */ asm(" nop"); asm(" nop"); asm(" nop"); asm(" rete"); /* dmac5 */ asm(" nop"); asm(" nop"); asm(" nop"); asm(" nop"); asm(" nop"); asm(" nop"); asm(" nop"); }
|