836uart.c

来自「8051试验程序 基础教材」· C语言 代码 · 共 51 行

C
51
字号
//********************************************************************
//
// Author        : ADI - Apps            www.analog.com/MicroConverter
//
// Date          : Feb 2003
//
// File          : 836uart.c
//
// Hardware      : ADuC836
//
// Description   : sample program that performs ADC conversions in
//                 continuous mode and sends results to a PC via the
//                 UART.
//		
//********************************************************************

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

#define adcled P3_bit.P33
#define LED P3_bit.P34		//P3.4 drives red LED on eval board

#pragma vector = adc0i
__interrupt void ADC_int ()
{
	LED ^= 1;
	printf("\n\n");
	printf("%bX%bX",ADC0H,ADC0M);
    ADCSTAT_bit.RDY0 = 0;
}

void main (void)
{

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

	//CONFIGURE ADC AND START CONVERTING....
	SF = 0x200;
    ADC0CON = 0x45;
    IE_bit.EADC = 1;
    IE_bit.EA = 1;
    ADCMODE = 0x23;	// continuous conversion on Main channel on main channel

	//WAIT FOR INTERRUPTS....
	while(1);
}

⌨️ 快捷键说明

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