I got a problem using MCP3202 , the circuit use a pic18F 3 DA and one MCP41010 and finally the MCP3202 , all devices are working properly , the SPI line is ok ,however MCP3202 wont work , i show strange value . Here is my code :
- Code: Select all
unsigned int getADC(unsigned char channel) { // Returns 0..4095
unsigned int ch=0;
unsigned int datahigh,datalow;
CSD = 1;
if(channel==0){ch=0xA0;}else{ch=0xE0;}
OpenSPI(SPI_FOSC_64, MODE_00, SMPEND);
CSD = 0;
WriteSPI(0x01);
WriteSPI(ch);
datahigh = ReadSPI();
WriteSPI(0x00);
datalow = ReadSPI();
CSD = 1;
return ((datahigh << 8) | datalow);
}
Someone can help me ?