Skip to content

t/bare_metal

Bare Metal: top posts

The most useful posts in this topic, by likes from the community.

Posts

  1. Article

    volatile is not a lock: 4 ISR bugs I have personally shipped to pump controllers

    All four of these went to the field in products with my name in the git blame. All four passed bench testing. Sharing so you can ship different bugs. Bug 1: the missing volatile bool adc_done = false; /* BUG: not volatile */ void ADC_IRQHandler(void) { adc_value = ADC1->DR; adc_done = true; } void read_adc(void) { start_conversion(); while (!adc_done) { } /* at -O2 this becomes while(1) */ adc_done = false; } The…

    Karthikeyan S19likes10comments

  2. Experience

    The pump that stopped every 40 minutes: a FreeRTOS priority inversion story

    Field complaint: a pressure booster pump in an apartment building stops for 2 seconds roughly every 40 minutes. Water pressure drops, people on the 9th floor shout, the building manager calls our service guy, the service guy calls me. On the bench: nothing. Ran it for 3 days, no stop. The system STM32F4, FreeRTOS, three tasks that matter: MotorControl , priority 5, runs every 1 ms, kicks the watchdog through a…

    Karthikeyan S14likes9comments

  3. Experience

    The BOR level nobody set: why our controllers reset when the farmer's motor starts

    Field returns from farms in Tiruppur district. Controllers resetting at random, and some of them came back with the settings corrupted: pressure set point became 0, or the pump type changed by itself. Bench test: perfect, 2 weeks, zero resets. "Lab bench power supply never shows this. Farm shows it on day one only." I say this sentence to every new engineer now. Going to site One farm, 200 m of cable from the…

    Karthikeyan S12likes6comments

  4. Article

    ESP32 module placement: why your WiFi range is 3 meter

    Every week customers send me ESP32 board for review before production. 7 of 10 have the same problem. They say "WiFi range very bad, maybe ESP32 is bad". ESP32 is fine. Layout is bad. 1. Antenna at board edge, nothing under it The PCB antenna on the module (the zigzag part) must be at the edge of your board, or better, hanging out past the edge. Under the antenna: no copper on any layer . No ground pour, no traces,…

    Leo Chen 陈立12likes10comments

  5. Question

    IWDG vs WWDG on STM32: which one you actually use in production, and how do you feed it?

    Discussion in our team this week, I want outside opinions. Today: IWDG only, ~100 ms timeout, kicked from a low priority FreeRTOS task. Colleague says this is useless, because a stuck high priority task will block the low priority one and we reset, fine, but a runaway loop that still lets the kicking task run will never reset. He wants WWDG with a window, so kicking too early also resets. Constraints: motor control…

    Karthikeyan S10likes6comments

  6. Question

    How do you unit test firmware? We test almost nothing on host

    Honest question. In my team all the testing is on the target hardware: flash, run, look at the logs and the scope. We have some integration tests on a HIL bench but zero unit tests. When I propose unit tests, the people say is impossible because the code touch registers everywhere. Is a codebase of around 60k lines of C, STM32, FreeRTOS. The drivers call the HAL directly from the application logic in many places.…

    Diego Ramírez3likes3comments

  7. Article

    volatile is not a mutex: sharing data between an ISR and your main loop

    Every few months a junior in my team come with the same bug: a counter updated in an interrupt, read in the main loop, and sometimes the value is garbage. And the first answer is always "but I put volatile". So here is the explanation I give them, maybe is useful for someone else. What volatile does volatile tells the compiler: this variable can change outside of the normal program flow, so read it from memory every…

    Diego Ramírez3likes3comments

  8. Experience

    The CAN node that went bus-off only on cold mornings

    This was some years ago but I still think about it every winter. We had a body control module, nothing special, talking on CAN at 500 kbit/s with the other modules. On the test bench everything perfect. In the field, some customers report that the module "die" in the morning and come back after the car is driving some minutes. Only in the north. Only in winter. First we suspect the power supply, because cold…

    Diego Ramírez2likes3comments

Get the best of Dynamo Geeks weekly

One email each Monday with the most useful posts. No spam; unsubscribe in one click.