B-G431B-ESC1 is missing one PWM output signal

Hi,
I am using a B-G431B-ESC1 together with the Arduino Simple FOC 2.2. running a test example with 6PWM velocity_openloop, built using Platformio.
TIM1_CH2N is not generating any PWM signal and motor is not mowing correctly, if at all.

`Platformio.ini`
[env:disco_b_g431b_esc1]
platform = ststm32
board = disco_b_g431b_esc1
framework = arduino
monitor_speed = 115200
lib_archive = false
build_flags = 
	-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
	-D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF
	-D HAL_OPAMP_MODULE_ENABLED
lib_deps = 
	SPI
	Wire
	askuric/Simple FOC@^2.2

All the others outputs from the MCU are producing a PWM sigal following the target_velocity;
TIM1_CH1N, TIM1_CH3N, TIM1_CH1,TIM1_CH2,TIM1_CH3

Using ST Motor Profiler with same board and motor works perfect. PWN is generated and the motor can be adjusted freely.

I have read about a similar problem in the forum and checked the /variants/STM32G4xx/G431C(6-8-B)U_G441CBU/PeripheralPins_B_G431B_ESC1.c. Looked OK

What else can be wrong? Perhaps with the init of the complementary output on TIM1 (my guess)?

Best regards

Anders

Hello again,
some more investigations.

  • The PA12 (pin 34) is constantly held HIGH by some reasons.
  • It is the same using a simple Blink program for PA12 and PA9 with the B_G431B-ESC1 board. PA9 toggles as expected
    main.c
#include <Arduino.h>

void setup()
{
  pinMode(PA9, OUTPUT);
  pinMode(PA12, OUTPUT);
}

void loop()
{
  delay(20);
  digitalWrite(PA12, LOW);
  digitalWrite(PA9, LOW);
  delay(20);
  digitalWrite(PA12, HIGH);
  digitalWrite(PA9, HIGH);
}```
When switching to another STMG431 board using platformio.ini both PA12 and PA9 toggles as they should!! Strange and to deep in the STM32 for my knowledge.
Note that I am still using the B-G431B-ESC1 board for debugging. 
Only change the build target def.

platform.ini

[platformio]
default_envs = disco_b_g431b_esc1

[env:nucleo_g431rb]
platform = ststm32
board = nucleo_g431rb
framework = arduino

[env:disco_b_g431b_esc1]
platform = ststm32
board = disco_b_g431b_esc1
framework = arduino
lib_archive = false
build_flags =
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF
-D HAL_OPAMP_MODULE_ENABLED

Can someone please help?

Anders

Hi @aneds , and welcome to SimpleFOC.

It sounds like you know what you are doing. Based on your description, and especially your second test, I really only see an error in the board setup files as the explanation.

You could check programmatically by seeing if digitalPinToBitMask(PA12) and digitalPinToPort(PA12) gives the values expected for port and pin numbers.

Do I understand correctly that if you switch the board from
board = disco_b_g431b_esc1
to
board = nucleo_g431rb

PA12 begins to work?

Regards from Vienna,

Richard

Hi,
thank you for your reply. I will try your suggestions.
Yes that is correct, PA12 starts to work.

I will also try to get SimpleFoc working with the board = Nucleo_g431 initially and then manually configure it to be disco_b_g431.
I have tried several differnt B-G431-ESC1 board so no problem with the hardware itself

Regards from Sweden

Anders

Hi,

the results from trying your suggestions are (I dont understand the results yet. It is to deep into the registers)

Board: disco_b_g431b_esc1 Pin: PA12
Mask 0x1000
AFR_0 0x0
AFR_1 0x0
BRR 0x0
BSRR 0x0
IDR 0xA000
LCKR 0x0
MODER 0xA9F7FFFF
ODR 0x0
OSPEDR 0xF0C0000
OTYPER 0x0
PUPDR 0x64000000

Regards,

Anders

Hi Anders, did you find a solution for this? I seem to face exactly the same problem and wasted two days on it now. Just found out what you observed above.

Thanks for any help, Chris

Hi, I spent some time figuring out that all low level registers where correct from the SimpleFoc way of config, but still no luck. Then some day ago I saw this topic which seems to found the problem. Sounds correct, havent tested yet.

Thanks a lot, that solved it indeed, you saved my day (or better night…)!