Go Down

Topic: Updated Code for MCP3208 (Read 6 times) previous topic - next topic

praks1510

Any initializations to be done?
I have just initialized the spi of the LPC2148 and started to read the adc value from the MCP3208.

praks1510

I was using SPI1 of the LPC2148. When I used the SPI0 of LPC2148 my code started working.
Kindly note, with the same SPI1 routines used, I am able to communicate with other devices.

alhinde

#12
May 03, 2012, 10:39 pm Last Edit: Jun 04, 2012, 09:59 pm by alhinde Reason: 1
I've put the code from this topic and from arduino playground joined together into  MCP3208 arduino library.

Download Library: AH_MCP320x.h (control of MCP3204, MCP3208 chips)
Link: description

Code: [Select]

//AH_MCP320x.h functions
   //free pin mode declaration
AH_MCP320x(int CS_pin, int DOUT_pin, int DIN_pin, int CLK_pin)
   //SPI mode declaration
AH_MCP320x(int CS_pin)
   //read channel ADC value
int readCH(int CHANNEL)
   //read all channels
void readALL(int values[], int n)
   //read saved configuration of all channels
void getCONFIG(int config[],int n)
   //set config of measurement mode: single or differential
void setCONFIG(int CHANNEL, boolean SINGLE)
   //set all channels to diff. mode
void setCONFIG_allDiff(int n)
   //set all channels to single mode
void setCONFIG_allSingle(int n)
   //calculate the input voltage from ADC and VREF
float calcVOLT(float VREF, int ADCvalue)


Go Up