Interfacing 12 bit SPI ADC (MCP3204) with AVR Micro

Hello All, Sometimes the Internal ADC is not enough. Like when you need more resolution or high speed. The internal ADC of AVR generally has the following specifications. 15K samples per second 10 bit resolution. If you need more than that you need an external ADC. You may also need external ADCs if you have already used the internal ones. This tutorial will guide you how to install an external ADC with AVR MCU and write a test program to get data from it. A very common external ADC is from Microchip the MCP3204. It has the following configuration. 100K samples per second. (More than 6 times faster than AVRs inbuilt) 12 bit resolution (4 times more detailed) 4 input channels (MCP3208 has 8 channels). SPI Bus Compatible. Basic SPI Tutorial These ADCs are SPI Bus based which is a serial bus. So the number of pins in IC is very low. Total of 4 lines are required to interface it with AVR MCU. MISO (Master In Slave Out) MOSI (Master Out Slave In) SCK (Serial Clock) CS (Chip Select) As you know in synchronous serial communication their is a clock line (SCK in case of SPI) which synchronizes the transfer. Please read the article :- Synchronous Serial Communication Tutorial – The Basics of I2C and SPI. The clock is […]

Sound Generation by AVR Micro – Tutorial I

Many project requires some kind of Audio output. For example a burglar alarm, an automated school bell or simple electronic games or even a robot! In Old days we used some some dedicated Music and Audio Effect chip to do that. At that time ICs such as UM66 were very popular. Now in the days of microcontrollers, a good design is to use least number of external components to get the job done. So if you still use external audio ICs with a MCU based design then your design is inefficient and costly. The smart idea is to get most of the job done in software. In this article we will learn step by step how to produce different kinds of audio effect by just using an AVR MCU and A speaker. After reading this you would be able to provide simple sound output in many AVR based projects. So lets get started! I will start this series with a direct runnable example so that you can burn it into an AVR and see how it sounds! In latter parts I will elaborate how this was achieved. Some techniques that were used to achieve audio generation are. PWM or Pulse width modulation: It is a technique to generate analog voltage levels by a digital device (say a MCU). Generally a […]