Hi Zhao,
If you are a beginner then the code in the link you give looks like a good place to start. I would start at the beginning.
First get the Blinky project working. https://github.com/ARMmbed/mbed-os-example-blinky
Once you have that working then you can build up very quickly to more complicated things.
However to answer your other questions,
You can certainly do this in STM32Cube. There is an option to enable a timer in quadrature encoder mode, right at the bottom of the timer section in the pinout tab.
You can also do it in the mbed online compiler, but it will be a hard slog to write the low level registers, especially if you are a beginning programmer. I did a test to verify if it is possible to access the STM32F4 hardware registers using the online compiler and published the results.
https://os.mbed.com/users/skyscraper/code/Nucleo_BareMetal_QuadratureEncoder/file/c1a4bf56f1de/main.cpp/
Note that won't work yet as a quadrature encoder. It was just a test to see if it will compile, which it does seem to do.
As I mentioned before, I have a working STM32F4 quadrature encoder but using a different syntax. The hardware works very well:
https://github.com/kwikius/quantracker/blob/master/ground/tracker/v1/azimuth_encoder.cpp
Note: I dont know if mbed sets up the STM32 MPU privileged mode which would prevent direct access to the registers. That would need testing out.
regards
Andy
Hi I am new to programming in general and have recently started using a stm32 F401RE nucleo board to control a DC motor with encoder with a L298N module as the motor driver. I wrote a simple program that should allow me to control the DC motor's rotation and speed if the values are changed.
With this, I can change the rotation of the motor using the user button but the motor speed does not seem to be controlled by the pwm output pin. Furthermore, the DC motor is fitted with an encoder and I need to be able to measure distance moved by the motor but have no idea how to control the A and B channels of the encoder to do so. Any help provided will be well appreciated.
DC motor- part number 110055 https://servo.com.sg/sites/default/files/2018-01/A-max_Program_2017-18_0.pdf
encoder- part number110078 https://www.maxonmotor.com/medias/sys_master/root/8825854328862/17-EN-393-394.pdf