Here is what I have code wise so far.
#include <hidef.h> /* for EnableInterrupts macro */#include "derivative.h" /* include peripheral declarations */#include <stdio.h>/* Define a shortname for variable types */ typedef unsigned char UINT8; /* 8 bits */typedef unsigned short int UINT16; /* 16 bits */typedef unsigned long int UINT32; /* 32 bits */typedef signed char INT8; /* 8 bits */typedef signed short int INT16; /* 16 bits */typedef signed long int INT32; /* 32 bits */typedef volatile UINT8 VUINT8; /* 8 bits */typedef volatile UINT16 VUINT16; /* 16 bits */typedef volatile UINT32 VUINT32; /* 32 bits *///Register select line#define LCD_RSH (PTDD_PTDD4= 1);#define LCD_RSL (PTDD_PTDD4= 0);//Read/Write#define LCD_RWH (PTDD_PTDD5= 1);#define LCD_RWL (PTDD_PTDD5= 0);//Enable line#define LCD_EH (PTDD_PTDD6 = 1);#define LCD_EL (PTDD_PTDD6 = 0);#define LCD_STROBE_E ((PTDD_PTDD6 = 1),(delay(0xF)),(PTDD_PTDD6=0));UINT16 ones, tenths, hundredths;UINT16 adc_val;UINT32 temp;char volts[10];void initSystems(void), InitADC(void), SetADC(byte, byte);void initLCD(void), LCDCmd(UINT8), LCDChar(UINT8), dsplyString(UINT8 *);void delay(UINT8);void main(void) { initSystems(); InitADC(); initLCD(); SetADC(0x0A,0x01); // ADC10, enable interrupt EnableInterrupts; /* enable interrupts */ LCDCmd(0x0C); while(1){ temp = (ulong)adc_val * 7662; //7324 for 3V ones = temp / 10000000; temp = (temp - (10000000* ones)); tenths = temp/1000000; temp = (temp - (1000000*tenths)); hundredths = temp /100000; sprintf(volts, "gm:%d.%d%d", ones, tenths, hundredths); dsplyString(volts); LCDCmd(0x02); delay(0xFFFF); } }/************************** System Initializations ***************************/void initSystems() { SOPT1 = 0x00; // Disable COP,RSTO, enable BKGD,RESET SOPT2 = 0x00; // SPMSC1 = 0x00; // Disable LVD SPMSC2 = 0x00; // Disable power-down modes SPMSC3 = 0x00; // Disable LVWIE, low trip points SCGC1 = 0xFF; // Enable bus clock to ADC SCGC2 = 0xFF; // } /*************************** ADC Initialization *******************************/void InitADC(void) { ADCCFG = 0x17; ADCSC2 = 0x00; ADCSC1 = 0x00; ADCSC1_ADCO = 1; //hardware trigger interrupt APCTL2 = 0x04; } /************************** SetADC to pick ADC Channel **********************/void SetADC(byte adc_channel, byte aien_value) { ADCSC1_AIEN = aien_value&0x01; ADCSC1_ADCH = adc_channel;}/*************************** ADC Interrupt ****************************/interrupt VectorNumber_Vadc void ADC_ISR(void) { if(ADCSC1_COCO ==1) adc_val = ADCR;}/*************************** LCD Connections ****************************4-bit modePTD0-PTD3 = DB4-DB7 Data busPTD4 = RS Register selectPTD5 = R/W Read / WritePTD6 = E EnablePORTD 0b00000000 ||||||| |||---- data bus 0x0F |||---- RS 0x10 ||----- R/W 0x20 |------ Enable 0x40 */ /*************************** Initialization of LCD ************************/void initLCD(void) { PTDDD = 0xFF; //Set PortC as output PTDD = 0x00; //Set PortC outputs to 0x00 LCD_RWL; //Make sure it's in Write mode PTDD=0x03; LCD_STROBE_E; delay(0xFF); PTDD=0x03; LCD_STROBE_E; delay(0xF); PTDD=0x03; LCD_STROBE_E; delay(0xF); PTDD=0x02; LCD_STROBE_E; delay(0xF); LCDCmd(0x28); LCDCmd(0x08); LCDCmd(0x01); LCDCmd(0x06); LCDCmd(0x0F);}/**************************** LCD Commands ****************************//*0x01; clears screen0x38; sets up the display initalization0x0F; turns display on0x06; sets the cursor on and blinking0x02; move cursor to start and don't destroy data0x18; shifts cursor to the left when a char is entered0x1C; shifts cursor to the right when a char is entered0x10; moves 1 char to the left0x14; moves 1 char to the right0x80; add this to the address of the display to set the cursor position wanted*/void LCDCmd(UINT8 ch) { UINT8 ln, un; //lower and upper nibble ln = ch & 0x0F; un = ch >>4; delay(0xFF); PTDD = un; LCD_STROBE_E; delay(0xFF); PTDD = ln; LCD_STROBE_E; }/********************** Places a Char on LCD screen ***********************/void LCDChar(UINT8 ch) { UINT8 ln, un; //lower and upper nibble ln = ch & 0x0F; un = ch >>4; //upper nibble first PTDD = un; LCD_RSH; LCD_STROBE_E //lower nibble PTDD = ln; LCD_RSH; LCD_STROBE_E; LCD_RSL;}/************************ Places a String on LCD screen ********************/void dsplyString(UINT8 *msgptr) { while(*msgptr){ LCDChar( *msgptr); msgptr++; }}/************************* delay code ***************************/void delay(UINT8 cnt){ int i; for(i=0;i<cnt;i++){ }}