| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Hi @Candas1 |
Sorry, something went wrong.
|
Bonjour Frederic, Thanks for considering this. Thanks in advance. |
Sorry, something went wrong.
It was used but as you change the code it do not match anymore the format. We provide a script to apply change. in CI/astyle and the rules are defined in the astylerc file: https://github.com/stm32duino/Arduino_Core_STM32/tree/main/CI/astyle |
Sorry, something went wrong.
|
But it's even reporting code that I haven't changed. |
Sorry, something went wrong.
|
I got the style fixed locally by astyle. Do you trust this tool or it requires testing again ? |
Sorry, something went wrong.
You can force push. |
Sorry, something went wrong.
This is normal as you changed code block, so some indent are required 😉 |
Sorry, something went wrong.
|
No worries, I pushed the fixes. |
Sorry, something went wrong.
|
@Candas1 |
Sorry, something went wrong.
|
@fpistm I created this simplified example for you, I hope it's ok |
Sorry, something went wrong.
|
Thanks. I've made a test with a Nucleo-L476RG with your PR and it breaks the analogRead. |
Sorry, something went wrong.
Any details what is happening ? |
Sorry, something went wrong.
I guess the ADC channel conf moved not help and probably more. |
Sorry, something went wrong.
Do you have a table of all models and the ADCs it has ? But do you think it's not worth trying ? |
Sorry, something went wrong.
|
List of ADC is not an issue,it is quite easy to do something generic. |
Sorry, something went wrong.
|
Initializing the ADC for each adc sampling is also not the standard way to proceed to be honest. Maybe some families don't like changing the channel configuration while the ADC is on, that could be fixed as well. |
Sorry, something went wrong.
Well it was implemented like this to be arduino compatible as we made only one conversion.
Unfortunately, no, this would requires some investigations and I have no free bandwidth for this.
Probably if you read the comment it seems it depends of the ADC state. I guess using some LL would help on this but probably not simple and fast to do. |
Sorry, something went wrong.
|
I have some B-G431B-ESC1 laying around, I can maybe try my implementation on those. Do you mind keeping this open and we decide later if it's too complicated ? |
Sorry, something went wrong.
|
Hello, can you upload your optimized code for a look? |
Sorry, something went wrong.
|
Hi, I did an obvious mistake that I didn't upload yet in this PR. Now I got F3/F4/L4/G4/H5 nucleos I can test with. |
Sorry, something went wrong.
|
Thank you very much for your reply. I am looking forward to your sharing. Please call me when you share. |
Sorry, something went wrong.
Use LL functions instead Signed-off-by: Candas1 <candascraig@hotmail.com>
modify for F1/F2/F4/F7/L1 Signed-off-by: Candas1 <candascraig@hotmail.com>
Even after synching some changes were missing somehow Signed-off-by: Candas1 <candascraig@hotmail.com>
Sorry for the late reply. The only doubt I have now is that it's not possible to change the resolution between reads if the adc is not reinitialized, need to check how to deal about it. |
Sorry, something went wrong.
HAL_ADC_Start is ok afterall Signed-off-by: Candas1 <candascraig@hotmail.com>
Signed-off-by: Candas1 <candascraig@hotmail.com>
Signed-off-by: Candas1 <candascraig@hotmail.com>
|
That's all right, I'm looking forward to your effect. Finally, I have a suggestion: I have done a long experiment to improve the speed of ADC in Arduino development environment, for example DMA, but the Arduinol development environment can not call interrupt, I also consulted fpistm, he replied me that Arduino' official does not have DMA API, so he did not do it Method, so I hope the final optimized code can be a library like stevstrongl's [Arduino_.STM32] |
Sorry, something went wrong.
The scope of this PR is only to optimize analogRead without impacting it's behavior and the projects using it. I have idea about an ADC library as part of SimpleFOC but it would require a much more complicated API, it's out of scope here. |
Sorry, something went wrong.
|
Ok, thank you for your reply. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
This PR improves the speed of analogread by initializing each ADC only once(mentioned in this issue)
Currently when using analogread, the following steps are executed:
With this PR, if the ADC wasn't initialized yet by analogread, the following steps are executed:
If the ADC was initialized by analogread, only the following steps are executed:
I tested my changes on a STM32F103RCT6.
I ran analogread in a loop:
With this change, I was also able to run injected adc in parallel with analogread without interfering, the only prerequisite is that analogread should run first.
[EDIT] It was late so I forgot some details.
I tried reading the same pin from 3 different ADCs (PC2_ALT0, PC2_ALT1, PC2_ALT2) consecutively in a loop, it was working well, the init happened only once for each ADC. The same example wasn't working before my change, I was getting readings for one of the analogread calls only.
If you think users were using the previous behavior as a feature, I could also #ifdef the new behavior to make it optional.