Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

SlaveFiFoSync example with a CDC debug console

lock attach
Attachments are accessible only for community members.

SlaveFiFoSync example with a CDC debug console

YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Many user of FX3/CX3 did not design Uart debug port when designing their customized board. Thus, it it difficult for them to debug their firmware.

One way to solve this issue it to use the virtual COM port to debug.

The method to add a CDC interface to FX3 firmware is described in:

Adding Communication Device Class Interface to FX3 Firmware - KBA229099

What we need to do else is to connect the debugprint routine provided by Cypress to the socket created for CDC out.

void SwitchConsoles(void)

{

CyU3PReturnStatus_t Status;

// Only proceed if USB connection is up

if (glIsApplicationActive)

{

// Tear down DMA channels that need to be reassigned

CyU3PDmaChannelDestroy(&CDCtoCPU_Handle);

// Switch console

UsingUARTConsole = !UsingUARTConsole;

CyU3PDebugPrint(4, "Switching console to %s", UsingUARTConsole ? "UART" : "USB");

CyU3PThreadSleep(100); // Delay to allow message to get to the user

// Disconnect the current console

CyU3PDebugDeInit();

CyU3PThreadSleep(100); // Delay to allow Debug thread to complete and all buffers returned

// Connect up the new Console out - this is simpler than the I2C case since the USB socket is an infinite sink

Status = CyU3PDebugInit(UsingUARTConsole ? CY_U3P_LPP_SOCKET_UART_CONS : CY_FX_EP_CONSUMER_CDC_SOCKET, 8);

CheckStatus("DebugInit", Status);

CyU3PDebugPreamble(CyFalse); // Skip preamble, debug info is targeted for a person

// Say hello on the new console

CyU3PDebugPrint(4, "Console is now %s", UsingUARTConsole ? "UART" : "USB" );

// Now connect up Console In

Status = InitializeDebugConsoleIn(UsingUARTConsole);

CheckStatus("InitializeDebugConsoleIn", Status);

// Connect CDC_Loopback if necessary

}

else CyU3PDebugPrint(4, "USB not active, cannot switch consoles\n");

}

CyU3PReturnStatus_t InitializeDebugConsoleIn(CyBool_t UsingUART)

{

CyU3PDebugPrint(4, "\nSetting up USB_CDC Console In");

CyU3PMemSet((uint8_t *)&dmaConfig, 0, sizeof(dmaConfig));

dmaConfig.size  = EpSize[CyU3PUsbGetSpeed()];

dmaConfig.count = 2;

dmaConfig.prodSckId = CY_FX_EP_PRODUCER_CDC_SOCKET;

dmaConfig.consSckId = CY_U3P_CPU_SOCKET_CONS;

dmaConfig.dmaMode = CY_U3P_DMA_MODE_BYTE;

dmaConfig.notification = CY_U3P_DMA_CB_PROD_EVENT;

dmaConfig.cb = CDC_CharsReceived;

Status = CyU3PDmaChannelCreate(&CDCtoCPU_Handle, CY_U3P_DMA_TYPE_MANUAL_IN, &dmaConfig);

CheckStatus("CreateCDC_ConsoleInDmaChannel", Status);

if (Status != CY_U3P_SUCCESS) CyU3PDmaChannelDestroy(&CDCtoCPU_Handle);

else

{

Status = CyU3PDmaChannelSetXfer(&CDCtoCPU_Handle, 0);

CheckStatus("ConsoleInEnabled", Status);

}

    }

return Status;

}

The firmware example is attached with this blog.

Attachments
0 Likes
738 Views
Contributors