Q&As to XMC4500 Low-Level Driver Library

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

cross mob
Not applicable
Hi,

I'm currently trying to use the initial version of the XMC_Peripheral_Library_v1.0.0 specifically the usb device driver. In order to initalize the USB device it is necessary to fill an USB Device Initialization Structure XMC_USBD_t. The first member of this structure is USB0_GLOBAL_TypeDef *const usbd and is registered as a read-only member. So if I'm trying to fill this member with the USB Module Base Address it triggers a compiler error because I'm trying to write to a read-only member. Could that be a bug or do I need to call another function first which fills this structure with default values? Furthermore if I delete the const keyword for this member and I store the USB Base Module Address in it and I call the XMC_USBD_Init() function the 32-bit Base Address is stored in a variable called XMC_USBD_BASE_ADDRESS which is a uint8_t *. Shouldn't the datatype for the variable XMC_USBD_BASE_ADDRESS be a uint32_t *?

Code snippets:

USER_APP:

XMC_USBD_t usb_config;

usb_config.usbd = (USB0_GLOBAL_TypeDef const *)USB0;
usb_config.cb_xmc_device_event = NULL;
usb_config.cb_endpoint_event = NULL;
usb_config.usbd_max_num_eps = XMC_USBD_MAX_NUM_EPS_1;
usb_config.usbd_transfer_mode = XMC_USBD_USE_DMA;

XMC_USBD_Init(&usb_config);

XMC_USBD (c-file):

uint8_t *XMC_USBD_BASE_ADDRESS;

XMC_USBD_BASE_ADDRESS = (uint8_t *)(obj->usbd);

xmc_device.global_register = (dwc_otg_core_global_regs_t*)(obj->usbd);

XMC_USBD (h-file):

typedef struct XMC_USBD_OBJ
{
USB0_GLOBAL_TypeDef *const usbd; /**< USB Module Pointer. The USB0 module base address. */
XMC_USBD_SignalDeviceEvent_t cb_xmc_device_event; /**< USB device event callback. Use ::XMC_USBD_SignalDeviceEvent_t type of function pointer. */
XMC_USBD_SignalEndpointEvent_t cb_endpoint_event; /**< USB endpoint event callback. Use ::XMC_USBD_SignalEndpointEvent_t type of function pointer.*/
XMC_USBD_MAX_NUM_EPS_t usbd_max_num_eps; /**< Maximum number of end points used. The maximum range can be 7.*/
XMC_USBD_TRANSFER_MODE_t usbd_transfer_mode; /**< USB data transfer mode.Use ::XMC_USBD_TRANSFER_MODE_t type to specify the transfer mode. */
} XMC_USBD_t;

Thanks,

Roman
0 Likes
3 Replies
Not applicable
Hi Roman,

usbd variable is defined as constant because is the address of the module and should not be changed in runtime.

What you should do is..

XMC_USBD_t usb_config =
{
.usbd = USB0,
.usbd_max_num_eps = XMC_USBD_MAX_NUM_EPS_1,
.usbd_transfer_mode = XMC_USBD_USE_DMA,
.cb_xmc_device_event = NULL,
.cb_endpoint_event = NULL
};

XMC_USBD_Init(&usb_config);

However, without the middleware, it is very hard to build an application with just the LLD.
May I know what is your use case here?
0 Likes
Not applicable
Hi Jackson,

thanks for the reply, I implemented the changes according to your post, and if I check the address of the usbd-member the debugger (Segger J-Link) displays the address 0x11111111 which isn't the USB0 base address, maybe that is because I'm using the low-level drivers with an RTOS (uCOSIII) and there are some memory problems. However the use-case would be to establish a usb_bulk communication between the XMC4500 and a workstation. I know that the whole USB-Stack is still missing but the low-level drivers are helping a lot to achieve a solid connection. Do you have a matching USB Stack which offers a configuration descriptor and a stack? Or is there any download-able content regarding this use-case?
0 Likes
Not applicable
Hi Roman,

What class stack are you planning to use?
If you are using CDC(ATM), you may want to look at the USBD_VCOM APP.
Basically the APP provides the full solution for communication via USB Virtual COM Port.
It is using Bulk transfer for the communication too.
Perhaps you may want to refers to the APP for your implementation.
0 Likes