8 bit MCU with 12 bit ADC, possible

adcmicrocontroller

I am trying to measure battery's voltage and current but with a very high accuracy. So i've selected a 12 bit ADC to be interfaced (via I2C) with my micro-controller. My micro-controller will receive these values form the ADC and send them to the PC via the USB.

Now my question is, can we interface a 12bit ADC with an 8bit MCU like this one ?

Being new to microcontrollers i did a research over the internet and got the concept of 8bit Micro-controllers. But i couldn't find any where if i am able to interface it with a 12 bit ADC.

Also IF i am able to interface it, would it be more easy to use for eg a 32 bit MCU like this one instead of using the 8bit micro-controller, and interfacing it with the 12 bit ADC ? P.S by 'more easy' i mean simplicity of coding.

Looking forward for your suggestions.

Thankyou.

Best Answer

Typically you when interfacing devices through I2C or other IC level buses, you will transfer a word of information out of your device, like 8 bits at a time but the payload may vary between protocols (usually a defined protocol word or word range). So to see how your 8bit MCU will work with your 12 bit DAC, first look at the internal data structure of the ADC Output.

enter image description here

You can see that this is a padded 16 bit number and can neatly be stored in two bytes/words using your MCU. In c, this number would transparently be read as a u_int16 or equivalent definition for your platform. Moreover, if you program in C, multi-word data structures are handled transparently, processing and mathematical operations would be slower, but you would be able to safely store a 24bit ADC in a u_int32 and the compiler will handle the word level details for you.

Now when it comes to transfer protocol , I2C is a serial transfer protocol and you can chomp the data on MCU side however you wish (even with a 7 bit mcu if you had such a beast) , but the bus neatly divides the data for you by insisting on an ACK after every 8 bits.

Let's look at the I2C signaling for your ADC.

enter image description here

You can see that all communications are neatly split into 8 bit sections, writing command words, writing registers, reading data, etc. If you were bitbanging this protocol on your MCU in assembly, you would be able to easily work with your word level operations without too much headache. In C this would be done transparently by the compiler.

Your MCU is smart and will handle a lot of bus level details for for you. You can perform I2C transactions using a few control registers on your MCU without dealing with timing details like shown above. For the datasheet you linked (Atmega 48/88/168) the relevant chapter is Chapter 21 (Two-Wire Interface). A high level diagram of I2C communications using your MCU is shown in the following figure.

enter image description here

The benefit of using the integrated I2C is that you save a lot of program space and clock cycles that would be spent bit banging I2C in your code.