2015-12-25 03:33 AM
Hello,
I am using STM32F103, library versionV3.1.2. I have to use USE, USART2 and USART3. I am trying to set 110 baud but usart2 and usart3 doesn't work correct. I see these 3 peripheral clocked by APB1. When I set APB1 like:/* HCLK = SYSCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1; /* PCLK2 = HCLK */ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1; /* PCLK1 = HCLK/2 */ RCC->CFGR |=(uint32_t)RCC_CFGR_PPRE1_DIV8; //default DIV1 I am able to use 300 baud, 110 baud is trouble. When I set it like: /* HCLK = SYSCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;/* PCLK2 = HCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;/* PCLK1 = HCLK/2 */
RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV16;//default DIV1 USB device doesn't recognized. Is there any other way to solve this problem? Thank you. #110-baud2015-12-25 07:10 AM
Seems like a rather antiquated version of the F1 library, any particular reason for that?
And what speeds are the buses and processor running at, need to context here? USB likely has some minimum clock requirements so it is serviced quickly. Perhaps you can do 110 baud in software, it's awfully slow.2015-12-28 01:59 AM
Hi clive1,
I use this old version because of a sample project uses it. I didn't update to v4.0.0.How can I set baud rate in software, Could you give me some example code parts or a way. Thanks.2015-12-28 07:03 AM
I'm not looking to wade into a Soft USART implementation, perhaps you can try Google?
One of the problems with this low a baud rate is that the APB1 clock would need to be below 8 MHz, and as the USB is on the same bus this presents an issue because it requires a >= 8 MHz clock. Why the low rates? Can you use a different STM32 part that has the USB on the AHB buses?