在项目中,我需要使用C6748的UPP模块接收FPGA发送过来的数据,我根据TI提供的例程upp_bios_drv_v10进行修改:
static int LOCAL_upp_demo()
{
upp_UserParams upp_setup;
upp_Transfer upp_xfer_a, upp_xfer_b;
GIO_Handle upph;
int i, status, target_int_count;
// initialize uPP buffers
for (i = 0; i < sizeof(upp_buffer_a) / 4; i++)
{
// put data in transmit buffer and clear receive buffer
if (upp_mode == LOCAL_mode_BA_dlb)
{
((Uint32 *)upp_buffer_b)[i] = 0xAAAA5555;
((Uint32 *)upp_buffer_a)[i] = 0x00000000;
}
else
{
((Uint32 *)upp_buffer_a)[i] = 0xAAAA5555;
((Uint32 *)upp_buffer_b)[i] = 0x00000000;
}
}
// specify driver parameters
LOCAL_upp_config(&upp_setup);
// create driver handle
upph = GIO_create("/UPP", IOM_INOUT, &status, &upp_setup, NULL);
if (upph == NULL)
{
LOG_printf (&trace, "GIO_create failed");
return -1;
}
while(1)
{
// program transfer(s)
LOCAL_upp_config_xfers(&upp_xfer_a, &upp_xfer_b);
LOG_printf (&trace, "Programming uPP transfers…");
// note: begin read first if in DLB mode
switch (upp_mode)
{
case LOCAL_mode_AB_dlb:
status = GIO_read(upph, &upp_xfer_b, NULL);
status |= GIO_write(upph, &upp_xfer_a, NULL);
break;
case LOCAL_mode_BA_dlb:
status = GIO_read(upph, &upp_xfer_a, NULL);
status |= GIO_write(upph, &upp_xfer_b, NULL);
break;
case LOCAL_mode_A_transmit:
status = GIO_write(upph, &upp_xfer_a, NULL);
break;
case LOCAL_mode_A_receive:
status = GIO_read(upph, &upp_xfer_a, NULL);
break;
default:
// unrecognized mode (shouldn't happen)
status = -1;
break;
}
// catch GIO_submit errors)
if (status < 0)
{
LOG_printf(&trace, "Error programming uPP transfers.\n");
upp_error_count++;
}
// wait until transfer(s) complete
target_int_count = (upp_mode == LOCAL_mode_AB_dlb ||
upp_mode == LOCAL_mode_BA_dlb) ? 2 : 1;
while (upp_interrupt_count < 1 && upp_error_count == 0)
asm(" nop");
}
return 0;
}
现在UPP只能接收第一次数据,第二次就无法接收了,不知道什么原因,请帮忙分析一下
jie li1:
收一次数据之后,我重新将设备删除,然后重新对设备进行初始化操作,第一次接收数据正常,设备重新初始化后无法接收数据,不知道哪个地方出错了。
static int LOCAL_upp_demo(){ upp_UserParams upp_setup; upp_Transfer upp_xfer_a, upp_xfer_b; GIO_Handle upph; GIO_Params ioParams; int i, status, target_int_count;
// initialize uPP buffers for (i = 0; i < sizeof(upp_buffer_a) / 4; i++) { ((Uint32 *)upp_buffer_a)[i] = 0xAAAA5555; ((Uint32 *)upp_buffer_b)[i] = 0x00000000; }
while(1){ GIO_Params_init(&ioParams);
// specify driver parameters LOCAL_upp_config(&upp_setup);
ioParams.chanParams = &upp_setup;
upph = GIO_create("/UPP", IOM_INOUT, &ioParams, NULL); if (upph == NULL) { System_printf ( "GIO_create failed"); return -1; }
for (i = 0; i < sizeof(upp_buffer_a) / 4; i++) { ((Uint32 *)upp_buffer_a)[i] = 0xAAAA5555; ((Uint32 *)upp_buffer_b)[i] = 0x00000000; } // program transfer(s) LOCAL_upp_config_xfers(&upp_xfer_a, &upp_xfer_b);
System_printf ( "Programming uPP transfers…");
// note: begin read first if in DLB mode switch (upp_mode) { case LOCAL_mode_AB_dlb: status = GIO_read(upph, &upp_xfer_b, NULL); status |= GIO_write(upph, &upp_xfer_a, NULL); break;
case LOCAL_mode_BA_dlb: status = GIO_read(upph, &upp_xfer_a, NULL); status |= GIO_write(upph, &upp_xfer_b, NULL); break;
case LOCAL_mode_A_transmit: status = GIO_write(upph, &upp_xfer_a, NULL); break;
case LOCAL_mode_A_receive: status = GIO_read(upph, &upp_xfer_a, NULL); break;
default: // unrecognized mode (shouldn't happen) status = -1; break; }
// catch GIO_submit errors) if (status < 0) { System_printf( "Error programming uPP transfers.\n"); upp_error_count++; }
// wait until transfer(s) complete target_int_count = (upp_mode == LOCAL_mode_AB_dlb || upp_mode == LOCAL_mode_BA_dlb) ? 2 : 1; while (upp_interrupt_count < target_int_count && upp_error_count == 0) asm(" nop");
// check buffers (loopback modes only) if (target_int_count == 2 && upp_error_count == 0) for (i = 0; i < sizeof(upp_buffer_a); i++) if (upp_buffer_a[i] != upp_buffer_b[i]) { System_printf( "Data mismatch in buffers.\n"); upp_error_count++; }
// report test result if (upp_error_count) System_printf( "uPP transfers completed with %u errors.\n", upp_error_count); else System_printf ( "uPP transfers complete!");
GIO_flush(upph); //GIO_removeDevice("/UPP"); GIO_delete(&upph);
upp_interrupt_count = 0;} return 0;}
sophia wei1:
回复 jie li1:
你好,我也遇到了这个问题,历程的话,我把while (1)放在GIO_read ,这个接收正常,但是当我移植到CCS5中时,只能接收到一次数据,就不再也收不到了额,我猜是队列地方没链接好,但是我现在还没找到,请问你的解决好了吗?