DC motor on I2C Motor Driver(L298): PWM is 25Hz and can’t be changed

Hello Everyone
Thanks for waiting, here is the solution:

To change the frequency, you need to update the firmware of the STM32 on the Grove - I2C Motor Driver (L298P) to the latest version. The link is provided below:
https://github.com/Seeed-Studio/grove_stm32f030/blob/master/firmware/grove_i2c_motor_driver_stm32f030.ino.bin

To change the frequency, use function below(The value represents the frequency, with a maximum of 255Hz.):

Motor.frequence(50)

You can use either ST-link or Jlink to flash the firmware on the STM32. Here are the steps:

Jlink

Hardware:

SWC - SWCLK,
SWD - SWDIO
VCC - 3V3
GND - GND
Voltage input: 12V

Software:

SEGGER J-Flash V7.80

  1. Select STM32F030F4

  2. Change Use target RAM to 2KB.

  3. Drag the firmware into the box. Then click OK

  4. Then connect and flash

FAQ
If the operation fails, please check whether all the above configurations have been properly set. Verify that all Sectors below are checked. All sectors need to be selected.

If flashing fails despite all configurations being completed, try pressing ‘Production Programming’ button several times and the flash should succeed.

ST-link

Hardware:
SWC - SWCLK,
SWD - SWDIO
VCC - 3V3
GND - GND
Voltage input: 12V

Software:STM32 ST-LINK Utility

If your wiring is correct, clicking on Connect will directly recognize your current chip without additional checking.
Then Erase Chip and Program & Verify

Finally, you can successfully flash the firmware

2 Likes