AnsweredAssumed Answered

Displaying ADC readout through SCI

Question asked by Chris Doe on Apr 14, 2009
Latest reply on Apr 14, 2009 by Peter House

Hello all.  I'm trying to read an analog input ranging from 0 to 2.5 volts, convert it to a digital signal, and read the bits outputted through hyperterminal (for now...).  I will eventually be using a gui to take these bits and make sense of them but just want to get a solid reading first.  I am getting a reading but it is a bunch of letters and symbols on hyperterminal and I'm not sure why.  When I remove my input I get a bunch of "]"'s, so I know it's reading something from the ADC when it's hooked up.  Below is my code and a picture of my output.  Any ideas would be appreciated.  Please let me know if anything should be changed or is unessesary as I'm new to microcontrollers, Thanks!


My hardware/Software:


* DEMOQE128 board

* MC9S08QE128

* Code Warrior


My code:


int PyrRding;

void main(void) {

/*******Set up SCI Registers********/

SCI1BDL=0x1A;//baud rate=9600bps and bus freq=4MHz.

/**********Pyranometer ADC**********/
ADCSC1_ADCO = 1;        // enable continuous conversion
ADCCFG_MODE = 0x00;     // 8 bit mode
PTADD = 0x00;           // initialize as input

/****************First ADC to SCI*************/

ADCSC1_ADCH = 0x00;           // set channel PTA0
ADCSC1 = 0;                   // Commence new conversion Ch0

while (ADCSC1_COCO == 0){}    // Wait until conversion complete
PyrRding = ADCRL;             // output 8bit ADC to PyrRding variable

while (SCI1S1_TDRE == 0){};   // Wait for the transmitter to be empty
SCI1D = PyrRding;             // Stores new data to be transmitted via serial port
SCI1S1_TDRE = 0;              // Clear flag to send





My output:




Hyperterminal reading