⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tempuart.c

📁 8051试验程序 基础教材
💻 C
字号:
//====================================================================
//
// Author        : ADI - Apps
//
// Date          : November 2001
//
// File          : TempUart.c
//
// Hardware      : ADuC836
//
// Description   : This Program takes a temperature measurement every
//                 second from the on-chip temp sensor and sends the
//                 temp in degrees Celcius up the UART to the PC where
//                 it can be read using hyperterminal
//====================================================================

#include <stdio.h> 
#include <ioADuC836.h>

void main (void)
{	
	int i, temp;

	//UART config        
	T3CON = 0x82;
        T3FD = 0x12;
        SCON = 0x52;

        ADCMODE = 0x10;	// ENABLE AUX Mode - Power down 
        ADC1CON = 0x20; // USE INTERNAL REFERENCE PTAT(+) --> PTAT(-) BIPOLAR MODE Fixed +/- 2.5V range 

	printf("____________________________________\n"
               "Analog Devices MicroConverter ADuC834\n"
               "Temp Sensor Demo Routine\n");
  
	while(1)
	{	
		ADCSTAT_bit.RDY1 = 0;
		ADCMODE = 0x12;
		while (ADCSTAT_bit.RDY1 == 0);	// wait for result	
		temp = ADC1H-128; 		      
		printf("\n\n");
		printf("%d degrees C\n", temp);
	    for (i = 0; i < (10000); i++) {}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -