cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring Peripheral ADC Issue

Vincent7
Associate III

Hello Everybody,

MCSDK:6.3.0

CubeMX: 6.3.0

Workbench : 6.3.0

CubeIDE : 1.15.0

I encountered an issue after generating FOC code using Workbench v6.3.0.
I then used CubeMX to configure PB15 as ADC2_IN15 to read the torque sensor voltage.
However, after regenerating the code in CubeMX, I observed two problems:

1) The configuration for ADC2_IN15 was not automatically generated by CubeMX. I had to manually set it up. Is this expected behavior?

2) During initialization, I first measured PIN PB15 using a multimeter, and its voltage level was 0.7V (which is the correct baseline voltage for the torque sensor).
However, once the program executes MX_MotorControl_Init();, this pin is pulled up to 3.3V.
I checked Workbench, and this pin does not appear to be used by the FOC configuration.
How can I resolve this issue? Please help me...

Note: In the FOC code generated by Workbench, ADC2 uses injection mode, while the additional ADC I configured uses regular mode.

4 REPLIES 4
ahsrabrifat
Senior

Even if PB15 is not explicitly shown in Workbench, the FOC firmware might still be using it for internal purposes, such as debugging, GPIO triggering, or an alternate function. In Workbench, double-check that PB15 is not assigned to any function (even indirectly).

 

TDK
Guru

Check the GPIOB registers to see what PB15 is configured as. If it's configured as something, find out where in your code it's being configured. Stepping through can help to locate this.

If you feel a post has answered your question, please click "Accept as Solution".
Vincent7
Associate III

Hello ahsrabrifat and TDK

Thank you guys for providing the clues. I will check the code again, and if I find a solution, I will share the cause of the issue. I really appreciate the direction you provided! I originally thought that the generated FOC code, if not visible in CubeMX, should be customizable by the user.

Once again, I really appreciate you all.

Vincent7
Associate III

Hello Everybody,

MCSDK:6.3.0

CubeMX: 6.3.0

Workbench : 6.3.0

CubeIDE : 1.15.0

Power Board : IHM08M1

Control Board : NUCLEO-G431RB

 

I only found that it was occupied in FOC_Ini(), but I still couldn't see any place where PB15 was being used.

So, I moved it to PB2 to read the torque sensor voltage, but a new issue arose:

After Workbench generated the FOC code, I pressed "Run CubeMX" in Workbench and additionally set PB2 as the channel for reading the torque sensor voltage.
Since Workbench had set PC6 for reading phase current (configured in regular mode), I changed it to DMA (circular mode) and regenerated the code.

But I found that in the program, I have to execute HAL_ADC_Start_DMA() first before calling MX_MotorControl_Init() in order to read the torque sensor voltage.

I feel like this logic is incorrect. Did I misconfigure something?

Also, after switching to DMA, will FOC know that it should read from Get_ADCBuf[0] for the original phase current reading? (while torque sensor voltage is in Get_ADCBuf[1])

If I regenerate the FOC code from Workbench and run CubeMX again, my previous manual configuration of PB2 gets cleared. This doesn’t seem normal, right? Is there a way to resolve this issue?