cpq / bare-metal-programming-guide

A bare metal programming guide (ARM microcontrollers)
MIT License
3.27k stars 284 forks source link

suggested fix #25

Open uliano opened 1 year ago

uliano commented 1 year ago

the last line of clock_init

while ((RCC->CFGR & 12) == 0) spin(1); // Wait until done

should probably be:

while ((RCC->CFGR & 12) != 8) spin(1);

cpq commented 1 year ago

@uliano thank you.

Apparently in this context, both ways achieve the same. Current approach: "wait until the clock is set to something that is not the default (HSI)" Your suggestion: "wait until the clock is set to PLL"

Your suggestion is more precise, though.

uliano commented 1 year ago

@cpq Hi Sergey,

thanks for coming back. Yes I was meaning exactly that, it is a “fix” for something that’s already working :-D!

But many more thanks for the effort you put in your tutorial, it provided me a "way out” from AVRs the only MCU I was able to program bare metal (and design hardware too).

In a couple of days I ported your code (without the web server, for sure) to a blackpill F411 and I learned a lot!

My next endeavor will be irq on serial monitor or maybe even exploiting the USB connector of the board

cpq commented 1 year ago

@uliano awesome, that's great to hear.

You might want to check out this: https://github.com/cesanta/mongoose/tree/master/examples/stm32/nucleo-f429zi-usb-rndis

This is a bare metal firmware for F429. I think it'll work on 411. Just clone mongoose repo, cd examples/stm32/nucleo-f429zi-usb-rndis && make flash Maybe the clock settings would need tweaking... But I expect the peripherals (GPIO & UART) be the same.

It should make your F411 to look like an Ethernet connected device (ethernet-over-USB) It uses our Mongoose Library of course. With that approach, you can talk to your F411 over a usual browser / REST API.

It uses an awesome TInyUSB library, which is worth checking out