I have a custom board having F103RET6 with 8Mhz Clock, I'm using multiple serials but having some random errors at higher baud rate which didn't happen before with Steve's core.
Serial baud rate 460800 works good, but 921600 has so many data missing issues.
How do I know the what clock is selected in Generic STM32F103RETx board option ?
Whats the clock frequency of Generic STM32F103RETx
Re: Whats the clock frequency of Generic STM32F103RETx
Generic uses the HSI.
You can redefine the clock config to use HSE :
https://github.com/stm32duino/Arduino_C ... ock_config
You can redefine the clock config to use HSE :
https://github.com/stm32duino/Arduino_C ... ock_config
Re: Whats the clock frequency of Generic STM32F103RETx
if possible use usb-CDC-serial I think that can get close to or exceed 1 Mbps dependent on the number of devices multiplexed.
usb full speed bandwidth is 12 Mbps but that I've not observed anything close to that. The latencies is probably elsewhere, e.g. number of devices multiplexed (mouse, keyboard, hubs etc), use of interrupts handling, host latency etc.
usb is *polled* from the host, i.e. the host mostly determine the multiplexing and bandwidth.
if uart handling depends on interrupts or polling the bandwidth is likely limited.
I think it is possible to use dma with uart, but i've not tried nor know how to use it.
usb full speed bandwidth is 12 Mbps but that I've not observed anything close to that. The latencies is probably elsewhere, e.g. number of devices multiplexed (mouse, keyboard, hubs etc), use of interrupts handling, host latency etc.
usb is *polled* from the host, i.e. the host mostly determine the multiplexing and bandwidth.
if uart handling depends on interrupts or polling the bandwidth is likely limited.
I think it is possible to use dma with uart, but i've not tried nor know how to use it.
Re: Whats the clock frequency of Generic STM32F103RETx
Is there any example how to do it ?fpiSTM wrote: Wed Nov 13, 2024 5:14 am Generic uses the HSI.
You can redefine the clock config to use HSE :
https://github.com/stm32duino/Arduino_C ... ock_config
Re: Whats the clock frequency of Generic STM32F103RETx
You can use stm32cubemx to generate the clock config.
Re: Whats the clock frequency of Generic STM32F103RETx
Code: Select all
extern "C" void SystemClock_Config() {
RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
}
Added this in main.ino, Is this okay ?
It has no effect.
Re: Whats the clock frequency of Generic STM32F103RETx
Yes it seems correct.
If you have an STLink, you can try to debug to see if you well use this new configuration. To do this enable the "Optimize for Debugging" in the Sketch menu than build and upload. Finally add a breakpoint in the new SystemClock_Config click on the "Start debugging" button. Then you will see if you reach it.
Anyway high baud rate can lead to data loss for several reason, USART implementation uses IT. If data are lost when you send it maybe you can try to flush the Serial before doing anything else --> Serial.flush();
It probably works with Steve core because it uses DMA ?
If you have an STLink, you can try to debug to see if you well use this new configuration. To do this enable the "Optimize for Debugging" in the Sketch menu than build and upload. Finally add a breakpoint in the new SystemClock_Config click on the "Start debugging" button. Then you will see if you reach it.
Anyway high baud rate can lead to data loss for several reason, USART implementation uses IT. If data are lost when you send it maybe you can try to flush the Serial before doing anything else --> Serial.flush();
It probably works with Steve core because it uses DMA ?
Re: Whats the clock frequency of Generic STM32F103RETx
I'm using Visual Studio 2022 with visual micro plugin. There is no such option for debugging.
Also the program is reading 1/4 of ADC Voltage, if voltage is 1.0V, the adc is reading it as 0.25V. Is this also because of clock ?
Edit :
I had to call analogReadResolution(12); once in setup to remove 10bit default resolution.
Also the program is reading 1/4 of ADC Voltage, if voltage is 1.0V, the adc is reading it as 0.25V. Is this also because of clock ?
Edit :
I had to call analogReadResolution(12); once in setup to remove 10bit default resolution.
Last edited by DrBanana on Thu Nov 14, 2024 6:21 pm, edited 1 time in total.
Re: Whats the clock frequency of Generic STM32F103RETx
I've checked with pin output, the method is being called.
Edit : I have checked the baud rate, its working fine now with external clock.
Edit : I have checked the baud rate, its working fine now with external clock.