This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

usb_dev_serial Receiver is not working in F28M35x

Hi all,

   I am using F28M36x device. For that usb_dev_serial code i am taking from F28M35x( someone suggest this in forum, because F28M36x was building ). In this usb_dev_serial project transmitter is working fine with my device. But receiver is not working. See my code below. Please help me ASAP.

 ###############################################################################################################################################

int
main(void)
{
unsigned char pucData[15];
unsigned long ulLength;
// Disable Protection
HWREG(SYSCTL_MWRALLOW) = 0xA5A5A5A5;

// Setup main clock tree for 75MHz - M3 and 150MHz - C28x
SysCtlClockConfigSet(SYSCTL_SYSDIV_1 | SYSCTL_M3SSDIV_2 | SYSCTL_USE_PLL |
(SYSCTL_SPLLIMULT_M & 0x0F));

// Setup USB clock tree for 60MHz
// 20MHz * 12 / 4 = 60
SysCtlUSBPLLConfigSet(
(SYSCTL_UPLLIMULT_M & 12) | SYSCTL_UPLLCLKSRC_X1 | SYSCTL_UPLLEN);

// Setup pins for USB operation
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
GPIOPinTypeUSBAnalog(GPIO_PORTF_BASE, GPIO_PIN_6);
GPIOPinTypeUSBAnalog(GPIO_PORTG_BASE, GPIO_PIN_2 | GPIO_PIN_5 | GPIO_PIN_6);

// Enable the UART.
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

// Enable and configure the UART RX and TX pins
// Set GPIO E4 and E5 as UART.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);
GPIOPinConfigure(GPIO_PE4_U0RX);
GPIOPinConfigure(GPIO_PE5_U0TX);

// Set the default UART configuration.
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(SYSTEM_CLOCK_SPEED), 115200,
UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE |
UART_CONFIG_STOP_ONE);
UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8);

// Configure and enable UART interrupts.
UARTIntClear(UART0_BASE, UARTIntStatus(UART0_BASE, false));
UARTIntEnable(UART0_BASE, (UART_INT_OE | UART_INT_BE | UART_INT_PE |
UART_INT_FE | UART_INT_RT | UART_INT_RX));

// Initialize the transmit and receive buffers.
USBBufferInit(&g_sTxBuffer);
USBBufferInit(&g_sRxBuffer);

// Register interrupt handler in the RAM vector table
IntRegister(INT_USB0, USB0DeviceIntHandler);
IntRegister(INT_UART0, USBUARTIntHandler);

// Set the USB stack mode to Device mode with VBUS monitoring.
USBStackModeSet(0, USB_MODE_DEVICE, 0);

// Pass the device information to the USB library and place the device
// on the bus.
USBDCDCInit(0, &g_sCDCDevice);

// Enable interrupts now that the application is ready to start.
IntEnable(INT_UART0);
UARTIntEnable(0, UART_INT_TX);
UARTIntEnable(0, UART_INT_RX);
// Main application loop.

ulLength = 0;
while(1)
{
ulLength = USBBufferRead((tUSBBuffer *)&g_sRxBuffer,pucData,15);
if (ulLength )
{
USBBufferWrite((tUSBBuffer *)&g_sTxBuffer,&pucData,15);

ulLength = 0;
}

}
}

###############################################################################################################################################

Sometimes i get some collapsed value.( e.g input is  "Texas instruments" means some times "ments Tesas" , "instrum Texas", "Texas Texas instrum")

Please help me to fix this problem.

  • HI,

    I try to read the data by using    ulLength = USBBufferRead((tUSBBuffer *)&g_sRxBuffer,pucData,15);

    But i cannot able to read  the data until the buzzer size reaches to 240.

    So i compare the ReadIndex with the old ReadIndex. If both are different means i read the buffer directly from the pucBuffer.

    My code for you:

    // This is a echo program. If you send a data from hyper termainal , then you can echo back.

    if (ulLength != psVars->sRingBuf.ulReadIndex )
    {
    if ( psVars->sRingBuf.ulReadIndex = psVars->sRingBuf.ulWriteIndex )
    {
    ulLength1 = ulLength > psVars->sRingBuf.ulReadIndex ? ((256 - ulLength) + psVars->sRingBuf.ulReadIndex):(psVars->sRingBuf.ulReadIndex - ulLength);
    USBBufferWrite((tUSBBuffer *)&g_sTxBuffer,psVars->sRingBuf.pucBuf,ulLength1);
    psVars->sRingBuf.ulReadIndex -= ulLength1;
    psVars->sRingBuf.ulWriteIndex -= ulLength1;
    printf("Read length is %lu\n",ulLength1);
    }
    }

  • Hi Thirumoorthy R,

         Hope you are doing well, sir I have I am trying to send data from M3 side to PC using usb_dev_serial as you have mention your Transmitting Section is working could pls suggest some this I am not able to carry out the transmitting process.As I am running the project and debugging it  I am able to see

    ReadUARTData(void)  is excuting well but in following function:

    ScheduleNextTransmission(const tUSBBuffer *psBuffer)
    {
    tUSBBufferVars *psVars;
    unsigned long ulPacket, ulSpace, ulTotal;

    psVars = psBuffer->pvWorkspace;


    ulPacket = psBuffer->pfnAvailable(psBuffer->pvHandle);

    Here ulPacket get value 0 and further process Stops as I think .

    Could u pls suggest so the I can able to send data to PC from M3 board using usb_dev_serial

    Thanks Regards 

    Praveen