- Sun Feb 12, 2012 6:06 pm
#139693
I've been beating my head against the wall for a couple of days now. I have a Logomatic V2 and can read my ADC channel (AD0.3)with the software given by SFE, but I can't get this code to work and, dang it, it's identical!!! The result of this code is that it either writes empty strings or 0 to the SD card. Any help would be much appreciated.
Code: Select all
IODIR0 &= 0xBFFFFFFF; //This makes sure that P0.30 is 0 (input)
PINSEL1 |= 0x10000000; // set p0.30 to adc0.3
PINSEL1 &= 0xDFFFFFFF; // clear bit 29
void readTemp ( void )
{
unsigned short int val;
char str_data[10];
AD0CR = 0x00020FF08; // AD0.3
AD0CR |= 0x01000000; // start conversion
log_string("conversion started\n\r");
while (1) {
if (AD0GDR & 0x80000000) break;
}
string_printf(str_data,"0x%x\n\r",AD0GDR);
log_string(str_data);
val = AD0DR;
val = ((val>>6)& 0x03FF);
string_printf(str_data,"%u\n\r",val);
log_string(str_data);
}