Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/22/09 23:59
Read: times


 
#171048 - Serial Port configuration - UART - ADUC816
Hello, I'm having trouble with the UART on an ADuC816 microcontroller (ADC). I'm trying to configure it correctly so that I can read that output of the Analog to digital converter on the computer when it's interfaced through the serial port (and possibly serial to USB).

I'm using the Keil compiler but I can't seem to get everything configured correctly. It's becoming a nightmare at this point.

I will post my entire code below. The code is just to read in a voltage signal and display it on the COM1 port.


.#include <ADUC816.H>
#include <stdio.h>

void main (void)
{
/*-----------------------------------------------
Configure the serial port
-----------------------------------------------*/
SCON  = 0x50;
TMOD |= 0x20;
TH1   = 0xFA;
TR1   = 1;
TI    = 1;
PCON |= 0x80;

/*-----------------------------------------------
Configure the A/D to sequentially convert each
input channel.
-----------------------------------------------*/
  ADC0CON = 0x07;
  SF = 0x0D;


while (1)
  {
  unsigned int conv_val;

/*-----------------------------------------------
Start a conversion and wait for it to complete.
-----------------------------------------------*/
  ADCMODE |= 0x22;								 /*Enables Primary ADC*/
  while (RDY0 != 1);
  RDY1 = 0;										/*Ready bit for PRIMARY ADC	 */

/*-----------------------------------------------																	  
Read A/D data and print it out.
-----------------------------------------------*/
  conv_val = ADC0M | ((ADC0H) << 8);

  
  printf ("Primary ADC Channel 3 = %urn", conv_val);
  }

}
 



List of 3 messages in thread
TopicAuthorDate
Serial Port configuration - UART - ADUC816            01/01/70 00:00      
   Duplicate Thread!            01/01/70 00:00      
   Duplicate Thread            01/01/70 00:00      

Back to Subject List