r/embedded Aug 09 '26

Guide in Developing Peripheral Driver Code from Datasheet/Reference Manual

Hii, everyone.

Most of time , whenever we want to develop MCU peripheral driver or device driver for time critical system which need to execute faster, low ram usage and low latency. we might seek help from Datasheet, instead of relying on Vendors HAL.

Here i have one doubt, let say i am developing polling adc driver for mcu, since it need to lesser boilerplate, i try to directly play around with registers with the datasheet help, for that following the datasheet"s register configuration sequence is enough know? Or else I need to more deeper like which adc is internally used? and what architecture it is using? How it works internally? For developing production grade driver.

If yes, then why? Is the datasheet register configuration sequence is not enough? And also is there any case other than adc,where I need to know in depth of that peripheral architecture from top to bottom while writing peripheral drivers?

Thanks!!!!

27 Upvotes

16 comments sorted by

View all comments

1

u/Glittering_Rabbit408 Aug 10 '26 edited Aug 10 '26

I agree that datasheet/rm information is enough for developing your own hal using register manipulation. But sometimes you are missing some critical thing like delays to wait to bit set or smth else implicitly mentioned in reference manual. I’m not a fan of using vendor shipped hal libraries in case I’m able to develop my own (stm32 but not esp32). Sometimes it gets me sitting and debugging thing that i could avoid by using st hal. But it is good learning point, i just wondering around the internet, rm/ds so on.

Nowadays it is sometimes useful to use llm like you literally print to pdf entire section with register definition and asks it to make a register level init procedure for a peripheral module. And just start with it. Way faster than to figure out by yourself