I use the upp_bios_drv_v10 example code in LOCAL_mode_AB_dlb , and find the first time, the upp can receive data accurately, but later the upp can't receive data any more:
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;
}