MCP3202 and XC8 problem

MCP3202 and XC8 problem

Postby Claudione » Thu Jun 04, 2015 7:21 pm

Hi Guys.

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 :

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 ?
User avatar
Claudione
 
Posts: 3
Joined: Thu Jun 04, 2015 7:15 pm
Location: Italy
PIC experience: Professional 1+ years with MCHP products

Re: MCP3202 and XC8 problem

Postby ric » Fri Jun 05, 2015 3:30 am

Please don't ask the same question in multiple forums.
Continue in your other topic at viewtopic.php?f=45&t=222
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products


Return to ADC & Comparators

Who is online

Users browsing this forum: No registered users and 7 guests

cron