2021-01-23 11:53 PM
This page says:
"With a custom main() on Arduino, do not return from main(). As there is no operating system running on a standard Arduino, there is no where to return to. If you do return, abort() is called, then exit(). On the AVR-8 MCU ( Uno, Mega ) this results in global interrupts being disabled and execution enters an infinite loop. To overcome the eventual return, you can utilize an infinite loop of your own, which is not unlike what the Arduino core does itself."
Does this same rule apply to the STM32 MCUs?"
thx
2021-01-27 09:02 AM
Your Arduino model is this
void main(void)
{
setup();
while(1) loop();
}
You're not running an OS, so when you drop out of main() where does it go? It is a universe where there is no track, what happens to the train? No accommodation has been made unless you make it. In most cases it just crashes, it goes into a Hard Fault handler if you're lucky, and that's got a priority just below an NMI, so what interrupt is going to get serviced.
If you're doing high speed ADC, use a DMA, with a buffer large enough to decimate your interrupt loading to a point you want/have to deal with it. Hold 1ms of data, hold 100ms..
A while(1) __WFI(); loop halts the processor until the next interrupt comes a long, this is the least power consuming mode you can have while still being able to respond to an interrupt.
2021-01-27 09:15 AM