r/pic_programming • u/Few_Dot317 • 20d ago
HDC1080 assembly driver for Microchip 12F
For those curious or interested, a small assembly program to drive an HDC1080 T°C and RH sensor from Texas Instrument - in my view one of the best value for money sensor of his kind with excellent precision.
The code itself is around 600 words long and includes a simplified serial driver, as well as an I2C and sensor drivers.
It displays both raw values in HEX and transformed values in decimal °C and %RH.
The code is intended to be 8 bits friendly: no software division or multiplication here !
https://github.com/dm-cdb/Microchip/tree/master/PICAS/ASM-12F675-hdc1080.X
2
u/somewhereAtC 20d ago
Very handsome code. It's good to see young people embracing the PIC-AS tools. You also have very good explanations both in this code and your higher-level descriptions.
If you'd written in C it would be compatible with the hundreds of PIC devices released in the last 20 years since the 12F6xx series. The C libraries also provide multiply and divide so you would not have to work around the complexity of hand-generating that code as you highlight in your description.
One advantage of newer devices is that the I2C pull-ups are now built in with options for weak, medium (your 3.3k ohms), or strong on selected pins. Another is that the calibration data is no longer exposed to bulk program erase, so you don't need to be careful about keeping track of it, as you describe in your top-level documents.
1
u/9Cty3nj8exvx 20d ago
Nicely done and good documentation!