2023-04-24 07:32 AM
2023-04-24 07:43 AM
analogwrite -> pwm
https://www.arduino.cc/reference/de/language/functions/analog-io/analogwrite/
2023-04-24 09:17 AM
Not a strong Arduino following here.
The STM32 TIM have quite good functional implementation for PWM output for Servo, etc.
Single frequency per TIM, but multiple PWM channels (4 typical)
You can always use the Arduino framework, and then code your own libraries, or access the hardware more directly/explicitly.
2023-04-24 12:12 PM
--- OK. As a matter of necessity, I need to make a 120h pwm and dutycycle
variable from 0 ~ 100%.
I know how to do this in CubeIDE, but inside the Arduino ide with an STM32XX MCU I can't!
In 2019 in Arduino Ide 1.8.4, the parameters below worked with the STM32F103C8 MCU, but now they don't work anymore. It seems that these arguments have become obsolete!
--------------------------------------------
HardwareTimer timer(2);
timer.setPrescaleFactor(1);
//timer.setOverflow(2500);
timer.setOverflow(14400);
//pwmWrite(PA8, 1200);
//pwmWrite(PA9, 1200);
//pwmWrite(PA10, 1200);
pwmWrite(PA2, 7000);
--
the above is not all, but it seems that pwmWrite is no longer used, nor is
HardwareTimer.
It seems to me that nobody uses the Arduino to generate PWM with STM32 anymore. I say this because I did not find anything on the Internet about it. Shouldn't ST provide an APPNOTE on how to use their MCUs inside the Arduino IDE? If not, why give support on the boards and not have information for the users?
The purpose of the MCU is to read two analog inputs and send this reading through wireless communication with NRF24L01, and while it is sending, it will be producing a PWM signal.
As I can't get the NRF24L01 library for CUBEIDE, I have to do everything in the Arduino IDE, but I want to use an STM32 in the Arduino IDE because STMs are more reliable.
Translated with www.DeepL.com/Translator (free version)
2023-04-24 01:23 PM
>Shouldn't ST provide an APPNOTE on how to use their MCUs inside the Arduino IDE?
no. is not up to STM , what "Arduino" doing or not doing
i just can tell you, i had almost same problem: using a TFT , only in Arduino was a lib.
so i tried , in Arduino , include some defines and HAL access , to get ADC of STM doing, what i need.
no success.
then i tried, making a STM32 project, in stm32IDE, include the lib from Arduino; after some compile/see errors turns i had the variables and defines , and got "no errors" , program runs.
now i have the "nice" control over the chip, in stm32IDE, AND the lib. (for you: nrf24 lib .)
so i recommend : make STM32 project, include the lib from Arduino world, resolve the errors - and it works.
or - use lib like... : https://github.com/kehribar/nrf24L01_plus
or
2023-04-25 06:27 AM
Ok, thanks for the tip. Let's be more professional: "give Arduino what is Arduino, and STM what is STM! Thank you and God bless you!