Page 2 of 2
Re: Internal oscilator bluepill stm32f103
Posted: Wed Sep 18, 2024 9:45 am
by GonzoG
marce002 wrote: Tue Sep 17, 2024 5:15 pm
I am a beginner with the Arduino environment and I need some help figuring out how to use some .c source files in a sketch and or even .h header files.
Arduino use C++, so you include header file same way as in any other C++ IDE:
marce002 wrote: Tue Sep 17, 2024 5:15 pm
Currently only have my .INO code and nothing else, of course my stlink v2 and my board with internal crystal only... the definition inside my SystemClock_Config(void) is from another user who gave me a working internal clock in cubeide
As fpiSTM wrote, you probably use Roger Clark's core (based on Maple). It does not use ST HAL and changing clock setup isn't that easy.
Install official STM core:
https://github.com/stm32duino/Arduino_C ... ng-Started . There you can just select F1 boards, there you select "Generic F103C8Tx". It uses HSI. With USB enabled MCU is clocked @48MHz, as USB needs exactly 48MHz. With USB disabled it's clocked @64MHz.
Re: Internal oscilator bluepill stm32f103
Posted: Wed Sep 18, 2024 11:52 am
by marce002
Install official STM core:
have already ..see 1st post
this is what im using
It uses HSI. With USB enabled MCU is clocked @48MHz, as USB needs exactly 48MHz. With USB disabled it's clocked @64MHz.
no need to use usb just blink led with hsi but only have code for external one.... the code i pasted is from my ino sample and in 3rd post added somthing from cubeide for you guys help... i thought i would just add or remove some lines to use hsi
Re: Internal oscilator bluepill stm32f103
Posted: Wed Sep 18, 2024 1:34 pm
by GonzoG
marce002 wrote: Wed Sep 18, 2024 11:52 am
i thought i would just add or remove some lines to use hsi
It's even simpler - you just need to read:
1st time:
GonzoG wrote: Tue Sep 17, 2024 12:39 pm
...
Or you can use "Generic F103C8", as all generic variants use HSI as clock source.
2nd:
GonzoG wrote: Wed Sep 18, 2024 9:45 am
There you can just select F1 boards, there you select "Generic F103C8Tx". It uses HSI.
Re: Internal oscilator bluepill stm32f103
Posted: Wed Sep 18, 2024 2:51 pm
by marce002
Sorry to bother but still need to know what should i add to this code to use internal clock. The code is working fine with external clock and i can upload with stlink v2 and (arduino IDE with stm32 support from library json:
https://dan.drown.org/stm32duino/packag ... index.json ), just that: compile and upload. I have selected generic STM32F103C8 and upload method STLINK, tried 72mhz and 48.. But now i have no external clock and need to mod the code and upload to test blink led internal crystal.
Code: Select all
HardwareSerial my_serial_name(USART3, PB10, PB11);
#define pinLED PC13
void setup() {
my_serial_name.begin(9600); // on PB11 PB10
pinMode(pinLED, OUTPUT);
}
void loop() {
digitalWrite(pinLED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2000); // wait for a second
digitalWrite(pinLED, LOW); // turn the LED off by making the voltage LOW
delay(1000);
my_serial_name.println("La verdad es que anda");
}
Re: Internal oscilator bluepill stm32f103
Posted: Wed Sep 18, 2024 5:51 pm
by GonzoG
marce002 wrote: Wed Sep 18, 2024 2:51 pm
Sorry to bother but still need to know what should i add to this code to use internal clock.....
For the 4th and last time... there is no sense in repeating it more times.
GonzoG wrote: Wed Sep 18, 2024 9:45 am
Install official STM core:
https://github.com/stm32duino/Arduino_C ... ng-Started . There you can just select F1 boards, there you select "Generic F103C8Tx".
It uses HSI. With USB enabled MCU is clocked @48MHz, as USB needs exactly 48MHz. With USB disabled it's clocked @64MHz.
Re: Internal oscilator bluepill stm32f103
Posted: Wed Sep 18, 2024 7:00 pm
by marce002
For the 4th and last time... there is no sense in repeating it more times.
hey hey take it easy, who do you think you are? if I ask is because that is exactly what i have configured, or you do not read my post? despite of that same setup (no longer listed with "contributed") the blink does not blink.. not interested in your help anymore thks//
Re: Internal oscilator bluepill stm32f103
Posted: Wed Sep 18, 2024 10:19 pm
by ag123
this core is not supported here,
https://dan.drown.org/stm32duino/packag ... index.json
you would need to approach the author there if you intended to use it.
that is a fork of libmaple core which may have features different from what is currently hosted in github
e.g. 'official' stm core
https://github.com/stm32duino/Arduino_Core_STM32/wiki
https://github.com/stm32duino/Arduino_Core_STM32
(roger's) libmaple core
https://github.com/rogerclarkmelbourne/Arduino_STM32
is deemed 'community' support
and for both cores volunteers here is not obliged to provide an answer.
what has been mentioned is simply this, there is no such thing as an 'internal crystal'
using 'internal' means using the on chip RC oscillator and for that matter if you don't setup clocks that is 'internal'.
in the 'official' stm core
https://github.com/stm32duino/Arduino_Core_STM32/wiki
https://github.com/stm32duino/Arduino_Core_STM32
that can be selected by selecting 'generic stm32f103cx' board that is not specific to any board
or make your variant with an empty SystemClock_Config()
you may not have usb support when you use that and normally for internal the speeds is more like 8 Mhz'
usb has stringent timing requirements, which normally needs an external crystal to keep it stable.
https://electronics.stackexchange.com/q ... by-the-hsi
alternatively, like mentioned prior, use a better board, e.g. the stm32f4xx family.
those boards normally have the external crystal built with it.