If display is not visible adjust POT(RV2). ExampleĪfter running the demo rotate the POT(RV1) and see the value change in LCD Hardware for Interfacing MCP3204 with AVR ATmega32įuse bits must be set so as to enable external crystal and disable JTAG. SPIADC.c : The main example file making use of functions in above files.
The complete AVR Studio Project with all relevant support files is availableįor download. LCDWriteStringXY( 0, 0, "MCP3204 ADC Test") A varriable to hold the converted value. IF YOU WANT TO USE THEM IN COMMERCIAL APPLICATION PLEASE WRITE TO THE AUTHOR. IT IS INTENDED TO BE USED FOR HOBBY, LEARNING AND EDUCATIONAL PURPOSE ONLY. THE LIBRARY, NOR ANY PART OF IT CAN BE USED IN COMMERCIAL APPLICATIONS. Arguments: uint8_t ch : Channel Number For MCP3204 ch is between 0-3 (Total 4 channels) For MCP3208 ch is between 0-7 (Total 8 channels) Return Value:(TYPE uint16_t, i.e a 16bit unsigned int) The digital equivalent of analog input on selected channel. FollowingĬode Example demonstrate the complete transaction. So Bit B11 to B0 forms the 12bit result of Analog to Digital Conversion. In the same time Slave returns bits B7 to B0 of conversion. In this byte the Master writes a DON’T CARE Byte to slave. Where ‘?’ is Unknown bit and may be 0 or 1 Note: Channel Number 4 to 7 are only available in MCP3208.Īnd the slave return the following sequence So when you just want to read data do some thing like this data_in=SPIWrite(any_junk_value) //any_junk_value is a DON'T Care data byteĪnd when you Only want to write data to the slave you write SPIWrite(data_out) // The Compiler just ignores the return value The MCP3204 12 bit SPI ADC Chip. Here data_in and data_out are 8 bit C variablesĭata_out is the data you want to send to the SLAVE. Write something like this data_in=SPIWrite(data_out) Their is no separate Read and WriteĬommands their is only one command and that is Write. Transaction possible is exchange of data. One most important thing to note about SPI is that for everyīyte MASTER writes to SLAVE the MASTER receives one byte in return. Now master can write to the bus in 8bit (orġ byte) chunks.
#EXTREME SAMPLE CONVERTER 2.3.9 FULL#
SPI is full duplex, that meansĭata can be sent and received simultaneously SPI Transfer.Ī SPI transfer is initiated by the MASTER pulling the CS line low. MASTER and the MCP3204 is a slave on the bus. The clock is always controlled by the MASTER.
#EXTREME SAMPLE CONVERTER 2.3.9 SERIAL#
Serial Communication Tutorial – The Basics of I2C and SPI. In case of SPI) which synchronizes the transfer. As you know in synchronous serial communication their is a clock line (SCK