Originally it was in Flash, which I figured was causing the problem, so I changed it so that it was in RAM. Unfortunately the problem was still present.
For this project I am trying to create a simple USB CDC module that will be able to receive data from the computer and re-transmit it on the UART serial bus, and vis-versa. I downloaded the USB stack v5 before and I used that as a reference for this problem but had no luck.
From the couple examples that I have seen, you simply need to set the 'address' bits of both of the endpoint 0 Tx BDT entries to the address of the device descriptor in memory. My device descriptor is as follows:
static devdesc_t usbDeviceDesc =
{
0x12,
DESCRIPTOR_DEVICE,
0x00 , 0x02, // USB 2.0
DEVCLASS_COMMUNICATIONS,
0x00,
0x00,
EP0_MAX_SIZE,
0xA2 , 0x15, // Vender ID (MUST ACQUIRE)
0x54 , 0x43, // Product ID
0x01 , 0x00, // Device number
0x01,
0x02,
0x03,
0x01,
};
And this is how I handle passing the device descriptor to the bdt entry:
| bdDataBuffer[ BD_IDX_EP0_IN_EVEN].addr = bdDataBuffer[BD_IDX_EP0_IN_ODD].addr = (uint8_t*)&usbDeviceDesc; // Set addr to the device descriptor | | | | | |
bdDataBuffer[BD_IDX_EP0_IN_EVEN].desc.dts = bdDataBuffer[BD_IDX_EP0_IN_ODD].desc.byte32 = 0x00; // Clear information
bdDataBuffer[BD_IDX_EP0_IN_EVEN].desc.bc = bdDataBuffer[BD_IDX_EP0_IN_ODD].desc.bc = sizeof(usbDeviceDesc);// Set bc as the size of the device descriptor
| bdDataBuffer[BD_IDX_EP0_IN_EVEN].desc.dts = bdDataBuffer[BD_IDX_EP0_IN_ODD].desc.dts = 0x01u; | // Allow data sync from the host |
bdDataBuffer[BD_IDX_EP0_IN_EVEN].desc.data1 = bdDataBuffer[BD_IDX_EP0_IN_ODD].desc.data1 = 0x01u; // Set Data1/0 to Data1
bdDataBuffer[BD_IDX_EP0_IN_EVEN].desc.own = bdDataBuffer[BD_IDX_EP0_IN_ODD].desc.own = 0x01u; // Allow access to the BDT