我想实现的功能就是通过GP8_9提供信号通知FPGA,然后FPGA反馈一个GP8_8信号进入中断,利用UPP进行数据的接收。下面是部分代码,但是一直是没法正常的接收数据,我想问下具有什么原因,请教TI大神帮我分析分析,卡了好几天了。我代码中UPP初始化了两次是不是有问题
main()
{
int target_int_count=1;
open_int(); //打开中断
UPID0 = (unsigned int)&fpga8way; //Window Address
UPID1 = 0x00028000; //Line Count,Byte Count
UPID2 = 0x00008000; //Line Offset Address
while(UPIS2 & 0x2){};
GPIO_OUT_DATA8 &=(0<<9);
for(i=0;i<1000;i++);
GPIO_OUT_DATA8 |=(1<<9); //通过gp8_9信号给FPGA让其反馈gp8_8外部中断信号
while(upp_interrupt_count_1<target_int_count) //upp_interrupt_count_1表示是否接收完成,完成赋值1
{
//asm(" nop");
if(flag_8way==1) //flag_8way置1代表的是进入了中断 if{}体内的代码是由于有的时候不能够正常的接收到数据重新再发送一次GP8_9信号,再进行接收数据,如果upp_interrupt_count_1计数为1则跳出循环表示成功接收到数据
{
UPP_init();
UPID0 = (unsigned int)&fpga8way; //Window Address
UPID1 = 0x00028000; //Line Count,Byte Count
UPID2 = 0x00008000; //Line Offset Address
while(UPIS2 & 0x2){};
//delay(1000000);
printf("delay1000\n");
GPIO_OUT_DATA8 &=(0<<9);
for(i=0;i<1000;i++);
GPIO_OUT_DATA8 |=(1<<9);
}
}
}
void UPP_init()
{
UPPCR = 0x00000010; //复位 Set the SWRST bit in the uPP peripheral control register (UPPCR) to 1
sw_wait(300); //Wait at least 200 device clock cycles
UPPCR = 0; //复位结束
UPCTL = 0x02020006; //16位数据,CHA收,CHB发
//UPICR = 0X21000100; //uppCLK=300/2=150Mhz I/O_clk=150/2/(CLKDIVB + 1)=75Mhz //Channel B data pins are in a high-impedance state while idle(29 bit)
UPICR = 0X053f051f;
UPIVR = 0x10000000; //0x10000000 4096
UPTCR = 0; //64byte DMA bursts read / write
UPDLB=0;
UPIES = 0X00001818;
UPPCR = 0x0000000e; //使能UPP
}
interrupt void serv_upp(void)
{
interrupt_status = UPIER;
while (interrupt_status != 0)
{
if (interrupt_status & 0x0010 )//EOLI
{
UPIER |= 0x10; // clear EOLI
}
if (interrupt_status & 0x0008)//EOWI
{
UPIER |= 0x0008;// clear EOWI
upp_interrupt_count_1++;
}
if (interrupt_status & 0x0004)//ERRI
{
UPIER |= 0x0004; // clear ERRI
upp_error_count++;
}
if (interrupt_status & 0x0002)//UORI
{
UPIER |= 0x0002; // clear UORI
upp_error_count++;
}
if (interrupt_status & 0x0001)//DPEI
{
UPIER |= 0x0001; // clear DPEI
upp_error_count++;
}
if (interrupt_status & 0x1000)//EOLQ
{
UPIER |= 0x1000; // clear EOLQ
}
if (interrupt_status & 0x0800)//EOWQ
{
UPIER |= 0x0800; // clear EOWQ
upp_interrupt_count++;
}
if (interrupt_status & 0x0400)//ERRQ
{
UPIER |= 0x0400; // clear ERRQ
upp_error_count++;
}
if (interrupt_status & 0x0200)//UORQ
{
UPIER |= 0x0200;// clear UORQ
upp_error_count++;
}
if (interrupt_status & 0x0100)//DPEQ
{
UPIER |= 0x0100; // clear DPEQ
upp_error_count++;
}
// loop again if any interrupts are left
interrupt_status = UPIER;
} // end of while
// write end of interrupt vector to allow future calls
UPEOI = 0;
} // end of function
interrupt void gpio8_8(void) //触发中断信号由FPGA提供
{
printf("gpio8_8 falling singal received\n");
flag_8way=1;
}