2017-01-13 05:51 AM
edit: previously I wrote that problems occurs with freertos, I checked without it and I am having the same problem (ending in dead loop after sending more than 8 characters).
Steps to reproduce:
Create project in CubeMX for STM32F4DISCOVERY, enable USB_FS Device only. Configure clock: PLL_N = 72, PLL_Q=3, that gives me 48 MHz for usb, other settings remain unchanged. In configuration I enable CDC device with default parameters. Generate code for SW.
I add some led toggle in order to know it it is running.
/* StartDefaultTask function */
void StartDefaultTask(void const * argument)
{
/* init code for USB_DEVICE */
MX_USB_DEVICE_Init();
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
osDelay(500);
}
/* USER CODE END 5 */
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
In file usbd_cdc_if.c I am setting breakpoint at CDC_Receive_FS function.
When I am sending 8 characters or less it works fine. Program enters function above. When I send more than 8 characters, program is not entering CDC_Receive_FS function
>>> import serial
>>> ser = serial.Serial(port='/dev/ttyACM0')
>>> ser.write('12345678')
8
>>> ser.write('123456789')
9
>>> ser.write('12345678')
# python hangs here�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
/**
* @brief This is the code that gets called when the processor receives an
* unexpected interrupt. This simply enters an infinite loop, preserving
* the system state for examination by a debugger.
* @param None
* @retval None
*/
.section .text.Default_Handler,'ax',%progbits
Default_Handler:
Infinite_Loop:
b Infinite_Loop
.size Default_Handler, .-Default_Handler�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Solved! Go to Solution.
2017-01-15 10:06 PM
Hello,
Please check the link:
https://community.st.com/0D50X00009XkfcpSAB
There is a link in the thread.
/external-link.jspa?url=https%3A%2F%2Fbitbucket.org%2Frwmao%2Fcdc_onstm32f411rc%2Fdownloads
You can download the detailed instructions of using CDC. Code is geneated by cubemx. Or simply click this to download:
The buffer typically is much large, such as I have tested to send over 200bytes at a time. And tested to keep sending data.
To receive data from pc, please check another thread
2017-01-13 09:24 AM
Hi
Krajewski.Zdzis_
,It seems that you are adding mbed code after generating initial project using CubeMX, right?
This shouldn't be the correct way to do it: either you start CubeMX and call Cube functions (as done in the examples available in the Cube package), or use mbed.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2017-01-13 10:56 AM
Hi,
Nope, I'm not adding anything but one line for blinking led. Beside that pre code generated by CubeMXhttps://hastebin.com/ucobocuwih.swift
and here settings from CubeMX:
I will try now to makek it without freertos to see if something will change.
2017-01-13 12:53 PM
By default CubeMX sets rx and tx buffer to 4 bytes (but they remain in user code section.
/* Define size for the receive and transmit buffer over CDC */
/* It's up to user to redefine and/or remove those define */
#define APP_RX_DATA_SIZE 4
#define APP_TX_DATA_SIZE 4�?�?�?�?
further buffers are defined one by one, so while receiving data if you go outside rx buffer, you will be in tx buffer (so kind of safe zone), writing 9 bits will write data further.
2017-01-15 10:06 PM
Hello,
Please check the link:
https://community.st.com/0D50X00009XkfcpSAB
There is a link in the thread.
/external-link.jspa?url=https%3A%2F%2Fbitbucket.org%2Frwmao%2Fcdc_onstm32f411rc%2Fdownloads
You can download the detailed instructions of using CDC. Code is geneated by cubemx. Or simply click this to download:
The buffer typically is much large, such as I have tested to send over 200bytes at a time. And tested to keep sending data.
To receive data from pc, please check another thread