Test Ads7841.c
Test Ads7841.c
h" #define NUMBER_OF_DIGITS 16 /*************** Convert long integer to ascii ************/ void _ultoa_(unsigned long value, char* string, unsigned char radix) { unsigned char index; // Counter of digit char buffer[NUMBER_OF_DIGITS]; // Data buffer index = NUMBER_OF_DIGITS; // Load counter by digit count do { buffer[--index] = '0' + (value % radix); // Convert confi guration by radix(10 or 16) if ( buffer[index] > '9') buffer[index] += 'A' - '9' - 1; // For base over 10(base 16) value /= radix; // Div by to calculate into next digit } while (value != 0); // End for convert? do { *string++ = buffer[index++]; buffer } while ( index < NUMBER_OF_DIGITS ); *string = 0; } /*************** Convert long integer to ascii ************/ void _ltoa_(long value_l, char * string_l, unsigned char radix_l) { if (value_l < 0 && radix_l == 10) // For value < 0 (base 10) { *string_l++ = '-'; // Load sign '-' for display _ultoa_(-value_l, string_l, radix_l); // Convert long integer } else { _ultoa_(value_l, string_l, radix_l); // Convert long integer } } void PowerOn() { unsigned char inner, outer; for (outer = 0x00; outer < 0x10; outer++) { for (inner = 0x00; inner < 0xFF; inner++); } LCD_init(); for (inner = 0; inner < 10; inner++) LCD_delay(2); } // Over of digit count? // Place null for end string // Load convert value to string
/***************************** Main Program **********************************/ void main() { unsigned char i,j; char buff[4]; PowerOn(); LCD_row1(); LCD_puts("Ch0:"); LCD_command(0x88); LCD_puts("Ch1:"); LCD_row2(); LCD_puts("Ch2:"); LCD_command(0xC8); LCD_puts("Ch3:"); while(1) { LCD_command(0x84); LCD_puts(" "); hannel 0 value */ _ltoa_(analog(0), buff, 10); LCD_command(0x84); LCD_puts(buff); LCD_command(0x8C); LCD_puts(" "); analog channel 1 value */ _ltoa_(analog(1), buff, 10); LCD_command(0x8C); LCD_puts(buff); LCD_command(0xC4); LCD_puts(" "); analog channel 2 value */ _ltoa_(analog(2), buff, 10); LCD_command(0xC4); LCD_puts(buff); LCD_command(0xCC); LCD_puts(" "); analog channel 3 value */ _ltoa_(analog(3), buff, 10); LCD_command(0xCC); LCD_puts(buff); for (i=0; i<0xFF ;i++ ) for (j=0; j<0xFF; j++); } } /* Show analog c
/* Show previous
/* Show previous
/* Show previous