but i don't have access to these routines from arm-gcc.
By the way, i am using this to read the adc data:
#include "stm32f407xx.h" ADC1->CR2 |= ADC_CR2_SWSTART; // Start A2D while (!(ADC1->SR & ADC_SR_EOC)); // ready wait r = ADC1->DR;
Didn't find your answer? Ask the community — no account required.
R
Rick C
Have you tried asking your question in comp.arch.embedded? Certainly there is more expertise in this area in that group.
E
Ed Lee
OK, will do.
L
Lasse Langwadt Christensen
mandag den 26. april 2021 kl. 18.52.19 UTC+2 skrev Ed Lee:
why are you doing it the hard way? just install stm32cubeIDE and be done with it
D
Don Y
Ick. If you *really* need to "hang around" until the result is available (instead of checking it, again, "some time later"), AT LEAST put a limit on how many iterations you'll spin. You *know* when it is specified to be complete; if it isn't, something DETECTABLE is broken (and your code should report it instead of just "lock up")
D
Don Y
And, if you're gonna spin on a NoOp, do it in a noticeable way:
while (!(ADC1->SR & ADC_SR_EOC)) { // ready wait }
E
Ed Lee
Yes, if it lock up, will put in timeout in the real code. But if the chip does not stop after the specified cycles, there is serious hardware problem of the chip anyway.
E
Ed Lee
Just to be consistent and a bit faster. Default STM codes read 4 bytes and write 4 bytes to change a bit. I re-coded most registers to do bytes. I can do port I/O, usart and adc. Just haven't figure out mux channels yet.
Of course! But, the *user* just sees "it died"; he has no way of knowing (nor does he care) that it locked up spinning (vs. locked up due to a failure of Vcc at the chip).
The point is, you (can) know something that you can use to inform the user of a problem. Or, prevent some OTHER aspect of the code from chugging along on the assumption that "all is well".
["Can't Happen" should effectively PANIC so everything goes "safe"]
L
Lasse Langwadt Christensen
you do know that the stm32 is 32 bit processsor so it reads and writes 32 bits at a time? and that IO's have bitset and bitreset registers
doing things in bytes is pointless and takes more cycles and code space
E
Ed Lee
Not from gcc. All I/O ends up with 8 bits read and write.
E
Ed Lee
If Vcc failed, the stm32 m4 with internal adc won't run anyway.
My changes are mostly stylistic and you my prefer your style. But do not make the struct packed. I am not sure if having volatile on each member is necessery, but it looks clearer and works.
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.