MCP3KADC(4)
๐ MCP3KADC(4) โ bestie's guide to the Microchip 3x0x SAR ADC
okay so this is mcp3kadc(4), from the Kernel Interfaces Manual, section 4. it's giving "tiny chip, big voltage-reporting energy" and honestly? we're obsessed. let's get into it โจ
๐ธ NAME ๐ธ
mcp3kadc โ the Microchip 3x0x SAR analog to digital converter. yes bestie, it reads voltages. it's literally the vibe translator between "analog world" and "numbers your computer understands" ๐ฆ
๐ SYNOPSIS ๐
mcp3kadc* at spi? slave ? flags N
that's the whole config line. at spi? (hangs off SPI), slave ? (its slave number), and flags N โ and the N is doing a LOT of work, so keep reading ๐
โจ DESCRIPTION โจ
the mcp3kadc driver reports the current voltage on the chip's ADC channels through the envsys(4) API. and it doesn't just blindly spit numbers โ it calculates these values according to the currently selected reference voltage (Vref). so like, the math is mathing ๐งฎ๐
Vref is changeable through the sysctl(8) node hw.mcp3kadc0.vref. slay.
here's the part you actually need, bestie โ the supported chips. the type of chip gets selected with the flags argument in the config file. no cap, this table is the whole personality of the driver:
MCP3001โ Resolution: 10 bits ยท Input Channels: 1 ยท flags:0MCP3002โ Resolution: 10 bits ยท Input Channels: 2 ยท flags:1MCP3004โ Resolution: 10 bits ยท Input Channels: 4 ยท flags:2MCP3008โ Resolution: 10 bits ยท Input Channels: 8 ยท flags:3MCP3201โ Resolution: 12 bits ยท Input Channels: 1 ยท flags:4MCP3202โ Resolution: 12 bits ยท Input Channels: 2 ยท flags:5MCP3204โ Resolution: 12 bits ยท Input Channels: 4 ยท flags:6MCP3208โ Resolution: 12 bits ยท Input Channels: 8 ยท flags:7MCP3301โ Resolution: 13 bits ยท Input Channels: 1 ยท flags:8MCP3302โ Resolution: 13 bits ยท Input Channels: 4 ยท flags:9MCP3304โ Resolution: 13 bits ยท Input Channels: 8 ยท flags:10
like, pick your fighter. more channels = more to love ๐
๐ SYSCTL VARIABLES ๐
the following sysctl(3) variables are provided:
hw.mcp3kadc0.vrefโ defines the reference voltage on the chip'sVrefpin in millivolts (mV). it defaults to the ADC's maximum output value + 1 in millivolts (e.g.,4096for a 12-bit ADC).
so yeah, that default is the "max value plus one" situation โ like 4096 when you're running a 12-bit ADC. iconic little detail, don't lose it โจ
๐ฆ SEE ALSO ๐ฆ
(the friend group ๐ go read them, iykyk)
๐ HISTORY ๐
the mcp3kadc driver first appeared in NetBSD 8.0. a legend was born ๐
๐ AUTHORS ๐
the mcp3kadc driver was written by Frank Wille. thank you frank, we love you for this ๐ซถ๐
๐ reminder bestie: this page is from Debian, dated August 18, 2015 โ that's the source/version and date energy right there. anyway ily, go read your voltages responsibly ๐โจ
๐ฆ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2015 The NetBSD Foundation, Inc
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms