Part Number: TMS320F28379D
Hi Team,
My customer is trying to implement on F28379D. By far, they can successfully achieve the bootloader based on F2837xD_usb_flash_kernels_cpu01.
However, they would like the MCU to send a feedback via EP1 at the end of the code to indicate the success or error of the bootloader.
To achieve the function, they did the following modifications:
1) USB Clock configuration in USB_Init(void)
DevCfgRegs.DC12.bit.USB_A = 1; //feature enabled: device only
CpuSysRegs.PCLKCR11.bit.USB_A = 1; //module clock turned on
2) EP1 TxFIFO configuration:
//Set up endpoint 1 for bulk transfers with a 64-byte FIFO
USBREG8(USB_O_TXFIFOSZ) = 0x03;
USBREG16(USB_O_TXFIFOADD) = 0x120;
USBREG8(USB_O_TXCSRH1) = 0x20;
3)Enable USB EP1 Tx interrupt:
//USBREG16(USB_O_TXIE) = 0x0001;
USBREG16(USB_O_TXIE) = 0x0003;
4) USB descriptor configuration:
const sUsbInterfaceDescriptor loaderInterfaceDescriptor =
{
USB_DTYPE_INTERFACE<<8 | (2*sizeof(sUsbInterfaceDescriptor) - 1),
0<<8 | 0,
// 0xFF<<8 | 1,
0xFF<<8 | 2,
0x00<<8 | 0x00,
4
};
const sUsbEndpointDescriptor loaderEndpointDescriptor =
{
USB_DTYPE_ENDPOINT<<8 | (2*sizeof(sUsbEndpointDescriptor) - 1),
{
1, 0, 0, //Endpoint 1, OUT type
2, 0, 0, 0 //Bulk mode transfers
},
64, //Max packet size in bytes (64 is max for bulk transfers)
0
};
const sUsbEndpointDescriptor loaderEndpointDescriptor1 =
{
USB_DTYPE_ENDPOINT<<8 | (2*sizeof(sUsbEndpointDescriptor) - 1),
{
1, 0, 1, //Endpoint 1, in type
2, 0, 0, 0 //Bulk mode transfers
},
64, //Max packet size in bytes (64 is max for bulk transfers)
0
};
5) CombineUsbDescriptors(Uint16 *buffer)
d = 0;
byteLength = loaderEndpointDescriptor1.bDescriptorType_bLength & 0xFF;
while (byteLength--)
{
__byte((int *)buffer, b) = __byte((int *)&loaderEndpointDescriptor1, d);
b++; d++;
}
//Added (loaderEndpointDescriptor1.bDescriptorType_bLength & 0xFF);
buffer[1] = (loaderConfigDescriptor.bDescriptorType_bLength & 0xFF) +
(loaderInterfaceDescriptor.bDescriptorType_bLength & 0xFF) +
(loaderEndpointDescriptor.bDescriptorType_bLength & 0xFF) +
(loaderEndpointDescriptor1.bDescriptorType_bLength & 0xFF);
6) Transmit function of EP1
//Transmit data from USB endpoint 1
void TxDataEp1(const Uint16 *data, Uint16 length8, eDataEnd dataEnd)
{
Uint16 c;
// Enables the endpoint1 direction as TX
//Write the data to the FIFO
for (c = 0; c < length8; c++)
{
USBREG8(USB_O_FIFO1) = __byte((int *)data, c);
}
//Kick off the transmission. If there's no more data, set the end bit.
USBREG8(USB_O_TXCSRL1) = (dataEnd == USB_END_DATA) ? (USB_TXCSRL1_TXRDY | USB_TXCSRL1_SETUP) : U SB_TXCSRL1_TXRDY;
}
Function Call:
Uint16 ui16TxBuffer[5];
ui16TxBuffer[0] = 0xA5;
ui16TxBuffer[1] = 0x00;
ui16TxBuffer[2] = 0x41;
ui16TxBuffer[3] = 0x5A;
ui16TxBuffer[4] = 0x41;
TxDataEp1(ui16TxBuffer, 5, USB_END_DATA);
We have covered all the configuration according to our knowledge. The computer can recognize Bulk in EP1 and Bulk out EP1,but we still cannot receive the data on the host PC.
Could you please help review the code to find out what the problem is? We doubt the problem should be caused by TxDataEp1 function.
Looking forward to your advice.