2022-11-28 04:47 AM
I've created a project with STM32F407xxx, and using as USBH_CDC with this MCU. STM is working fine but the problem is, the baud rate can not be edited. It is auto by default. How can I keep it fixed at a certain baud rate such as 9600 or 115200?
I tried with GetLineCoding & SetLineCoding but it did not work. It is always in auto baud rate.
2022-11-28 10:27 AM
[EDIT - NEVER MIND - I just re-read your post and this is in HOST mode - my original post doesn't apply]
2022-11-28 11:11 PM
Actual thing is, I'm using STM32F407 as the host and there are some devices connected with it through USB. and I'm using USB CDC as protocol. Everything working fine except for this problem. What is happening, is if one of the connected devices is in reset condition, ST finds and starts transferring at a different baud rate rather than 115200. But if those devices are in an active condition, ST selects 115200. So, when anyhow the connected device(s) is in reset condition, ST can not communicate with those again as those device is not responding at a different baud rate rather than 115200. So I need to fix the auto baud rate option from ST Host.
Tried editing inside USBH_CDC_ClassRequest with
CDC_Handle->data_rx_state = CDC_IDLE;
CDC_Handle->data_tx_state = CDC_IDLE;
CDC_Handle->LineCoding.b.bCharFormat = 1;
CDC_Handle->LineCoding.b.bDataBits = 8;
CDC_Handle->LineCoding.b.bParityType = 0;
CDC_Handle->LineCoding.b.dwDTERate = 115200;
But, I found that this has no effect on selecting the baud rate. From somewhere, anyhow, ST is selecting the baud-rate automatically.
Also tried editing the GetLineCoding & SetLineCoding. But also those are not effective.
2022-12-05 05:02 AM
Tried in different ways, but editing those parameters makes nothing change. It is somewhere inside to change.
2022-12-05 05:08 AM
just to understand: you have stm32-host -> usb7cdc -> to what target ? cdc-device?
2022-12-05 06:10 AM
CH340 based custom device. Which can read only at 115200. but STM is setting baud rate randomly with different devices if once it is reset anyhow. But it the power is not disconnected and once it got a data at 115200, ST selects 115200.
So, I want to make the STM Host fixed at 115200.
2022-12-05 06:41 AM
ok,
maybe, you find in host lib something to set/change target speed, or look in Cube FW repository.
here: in STM32H743I-EVAL/Applications/USB_Host/CDC_Standalone -> cdc_configuration.c
see example , should help you. 'CdcSelectMode' ...
2022-12-06 02:30 AM
Tried, but it did not change anything.
2024-04-14 10:58 AM - edited 2024-04-14 10:59 AM
bCharFormat = 1 means 1.5 stop bits. I doubt this is what you want.
Per CDC spec for PSTN SubClass: