Page 1 of 1
'STM32F103C8T6' not work PWM Function.
Posted: Thu Jun 22, 2023 8:50 am
by myksj1105
'STM32F103C8T6' not work PWM Function.
hello. Nice to meet you. If you look at the picture, it is marked 'PWM' in 'PB_4'.
I tried driving it, but the PWM doesn't work. What's the reason?
Code: Select all
#define BACKLIGHT_LED PB4
void setup(){
pinMode(BACKLIGHT_LED, PWM);
analogWrite(BACKLIGHT_LED, 255);
}
Re: 'STM32F103C8T6' not work PWM Function.
Posted: Thu Jun 22, 2023 9:52 am
by GonzoG
There is no such thing as PWM mode for pins.
You can set pin in INPUT or OUTPUT (with pull-up or pull-down also) mode.
For analogWrite you don't need to set pin mode, as analogWrite does it.
How do you check if PWM works ??
Re: 'STM32F103C8T6' not work PWM Function.
Posted: Fri Jun 23, 2023 6:56 am
by myksj1105
Code: Select all
#define BACKLIGHT_LED PB4
void setup(){
pinMode(BACKLIGHT_LED, OUTPUT);
analogWrite(BACKLIGHT_LED, 255);
}
@GonzoG
Thank you for leaving an answer. Even if you proceed with the source code as follows, it does not solve the problem.
The PWM is connecting to the LED to test its brightness. As far as I know, Arduino's PWM range is 0 to 255.
Extreme values of 0 and 255 do not produce the desired results.
Re: 'STM32F103C8T6' not work PWM Function.
Posted: Fri Jun 23, 2023 8:44 pm
by GonzoG
@myksj1105
What do you mean by "desired results".
At 0 it's off, at 255, it's on.
Re: 'STM32F103C8T6' not work PWM Function.
Posted: Sat Jun 24, 2023 11:37 pm
by myksj1105
@GonzoG
Code: Select all
const byte PWM_PIN[20] = {
PA1, PA2, PA3,
PA6, PA7, PB0, PB1, PB10, PB11,
PB5, PB4, PB3, PA15, PA11, PA10, PA9, PA8, PB15, PB14, PB13,
};
#define LED PC13
void setup(){
//------------------------------------------------------------------------//
Serial.begin(115200);
for (uint8_t i = 0; i < 20; i++) { pinMode(PWM_PIN[i],OUTPUT); }
pinMode(LED, OUTPUT);
delay(100);
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
digitalWrite(LED,LOW);
for (uint8_t i = 0; i < 20; i++) { analogWrite(PWM_PIN[i], 150); }
delay(1000);
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
Serial.println(" SETUP OK!");
//------------------------------------------------------------------------//
}
Only 10 out of 20 'PWM PIN' works.
What's the reason?
I wonder. I can't understand.
Re: 'STM32F103C8T6' not work PWM Function.
Posted: Sun Jun 25, 2023 5:39 am
by fpiSTM
I can't help as I do not use this core:
https://github.com/rogerclarkmelbourne/Arduino_STM32
I maintain the STM32 core.
Maybe your chip is a fake which could explain your issues.
Re: 'STM32F103C8T6' not work PWM Function.
Posted: Sun Jun 25, 2023 6:08 am
by GonzoG
@myksj1105
If you use Roger's/Steve's core then with most hardware setup you are limited to standard setup.
With STM32 core all pins connected to timers work in PWM mode.
Re: 'STM32F103C8T6' not work PWM Function.
Posted: Sun Jun 25, 2023 10:09 am
by myksj1105
@GonzoG
It seems you are right.
It seems to be correct that it depends on the core.
Re: 'STM32F103C8T6' not work PWM Function.
Posted: Wed Jul 12, 2023 11:16 am
by trimarco232
STM32C8T6 has only 3 timers with each 4 capture compare channels , so you can only get 12 pwm outputs a time
Re: 'STM32F103C8T6' not work PWM Function.
Posted: Wed Jul 12, 2023 12:21 pm
by dannyf
3 general purpose timer (each with 4 channels) + 1 advanced timer (with 4 channels + 3 compl. channels).