USB on RX651 using Usb_Basic and Usb_PCDC FIT modules and FreeRTOS


I am working on a project where I try to use a USB port in order to send simple datas to a Windows RS232 Terminal.

For that, I have used the "Sample Program using USB Peripheral Communication Device Class Driverxxxx" : R01AN2238EJ0130 document.

So, I have added the following modules to my project : (r_bsp, r_usb_basic, r_usb_pcdc, r_dtc_rx, r_dmaca_rx, r_byteq, r_sci_rx)

and as described in the sample code I have started the SCI and the USB modules using the drivers. It seems that

there are no error when runninf the R_OPEN functions (for the SCI and the USB devices). Unfortunately, the USB is not recognized when connected to

a computer and no callback functions are called when I connect the USB to a computer. Could you please help me ? The initialisation procedure is the following :

usb_cfg_t cfg;
usb_ctrl_t ctrl;
volatile usb_err_t result;

// Creation de la queue des structures pour la reception des evenements Usb :
m_pUsbCtrlQueue = new cnxSystem::QueueContainerCommon3<usb_ctrl_t>(TASKUSB_USBCTRL_QUEUE_SIZE);

/* Initialisation des variables de l'application : */
memset((void *)&g_line_coding, 0, sizeof(usb_pcdc_linecoding_t));
memset (g_usb_data, 0, DATA_LEN);
memset (g_sci_data, 0, DATA_LEN);
memset (g_serial_state, 0, 2);
memset (g_console, 0, sizeof(sci_hdl_t));
g_is_usb_bulk_writing = USB_NO;
g_is_usb_interrupt_writing = USB_NO;
g_is_serial_state = 0;
g_sci_counter = 0UL;
g_read_size = 0UL;

/* Initialisation de la broche VBUS_USB0 : */
/* Set USB0_VBUS pin */
MPC.P16PFS.BYTE = 0x11U;

/* Initialisation de la liaison SCI : */

/* Initialisation de la liaison USB : */
ctrl.module = USB_IP0;
ctrl.type = USB_PCDC;
cfg.usb_speed = USB_FS; /* USB_HS/USB_FS */
cfg.usb_mode = USB_PERI;
cfg.p_usb_reg = (usb_descriptor_t *)&usb_descriptor;
result = R_USB_Open(&ctrl, &cfg); /* Initializes the USB module */

/* On enregistre la fonction de Callback pour la reception des structures de controle USB : */

I don't see any Interrupt functions in the sample code. Can someone tell me if there are used and how ? Shall I implement interrupt functions

on my sample code ?

Thank you for your help.

Parents Reply
  • Hi,

    thank you for your answer.

    Now I manage to get the USB interruptions (USBI0 is int the software configuration interruption B 185 using source 62).

    However, the USBRI0 interruption call be called 2 or 3 times but after that, 

    the program crashes. It seems that when entering the interruption, the call stack

    is corrupted and when exiting from the interruption, the PC is not reloaded with the good

    adresse and the crash occurs.

    I am using FreeRTOS.

    Does anyone have an idea ?


No Data