Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Injected channel #371

Merged
merged 1 commit into from
Jan 31, 2024
Merged

[BUGFIX] Injected channel #371

merged 1 commit into from
Jan 31, 2024

Conversation

askuric
Copy link
Member

@askuric askuric commented Jan 26, 2024

There seems to be a bug in the code ( one pretty hard to find, believe me :D )

Basically when in the for loop the injected channels are read the current code does a completely reasonable assumption that
ADC_INJECTED_RANK_1=1, ADC_INJECTED_RANK_2=2, and ADC_INJECTED_RANK_3=3,
However, at least in case of stm32g474 this is not the case :D
So here is the fix to avoid this assumption.

@askuric askuric changed the base branch from master to dev January 26, 2024 17:16
@Candas1
Copy link
Collaborator

Candas1 commented Jan 26, 2024

Hi,

I added this code for using injected adc registers and not using the interrupt anymore.
For the channel I use i+1, it wasn't OK ?

@askuric
Copy link
Member Author

askuric commented Jan 26, 2024

Your addition works great it's just that for some architectures the i+1 did not correspond to the ADC_INJECTED_RANK_x.
In particular my nucleo stm32f474re, in the case fo G4 architecture it is defined using LL flags

#define ADC_INJECTED_RANK_1                (LL_ADC_INJ_RANK_1) /*!< ADC group injected sequencer rank 1 */

here is the link

For some architectures it is just from 1 to 3 but for others its done using these LL flags. stm32duino repo search. I am not even sure that these LL flags are consecutive. So it's safer to enforce using the ADC_INJECTED_RANK_x.

@Candas1
Copy link
Collaborator

Candas1 commented Jan 26, 2024

My bad, first bug.

@Candas1
Copy link
Collaborator

Candas1 commented Jan 27, 2024

What driver are you using with your nucleo board that has 3 shunts ?
I need a proper 3 shunt setup for my tests.

@runger1101001
Copy link
Member

Here's a higher power one with 3 shunt sensing: https://www.aliexpress.com/item/4000126430773.html
It also has 2 shunt sensing for some reason (as someone recently pointed out on the forum) so this is even a board where we could run 2x current sensing at the same time :-D

This one: https://www.st.com/resource/en/data_brief/x-nucleo-ihm07m1.pdf
Will plug directly into a Nucleo64, and has 3-shunt sensing. Not so high power, but might be convenient...

I also have a DRV8316 based board which has current sensing (3 shunt low side), I could send you one if you want :-) but it is in the shape of a Arduino MKR Shield so you'd need jumper wires to connect it to STM32s.

@Candas1
Copy link
Collaborator

Candas1 commented Jan 27, 2024

Actually I already have:
X-NUCLEO-IHM07M1
X-NUCLEO-IHM16M1

And even managed to order this one when it was finally in stock:
X-NUCLEO-IHM16M1

I need to go through the docs and see if I can use all shunts on same ADC with the nucleo boards I have.

@askuric
Copy link
Member Author

askuric commented Jan 31, 2024

Merging into the dev branch.

@askuric askuric merged commit 412642d into dev Jan 31, 2024
33 checks passed
@runger1101001 runger1101001 added the bug Something isn't working label Feb 5, 2024
@runger1101001 runger1101001 added this to the 2.3.3_Release milestone Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants