tempsen.c

来自「845官方源码C语言」· C语言 代码 · 共 47 行

C
47
字号
//====================================================================
//
// Author        : ADI - Apps
//
// Date          : November 2001
//
// File          : TempUart.c
//
// Hardware      : ADuC845
//
// Description   : This Program takes a temperature measurement
//                 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 <ADuC845.h>

void main (void)
{
	int i, temp;

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

        ADCMODE = 0x10;		// ENABLE AUX Mode - Power down, Chop ON
        ADC1CON = 0x0E;         // USE Internal REFERENCE PTAT(+) --> PTAT(-) BIPOLAR MODE Fixed +/- 2.5V range

	printf("___________\nAnalog Devices MicroConverter ADuC845\nInternal Temp Sensor Demo Routine____________\n");


	while(1)
	{
		RDY1 = 0;
        ADCMODE = 0x12;
        	while (! RDY1){};	// 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 + =
减小字号Ctrl + -
显示快捷键?