📄 uartprintf.c
字号:
//********************************************************************
//
// Author : ADI - Apps www.analog.com/MicroConverter
//
// Date : 16 October 2003
//
// File : 847uart.c
//
// Hardware : ADuC845, ADuC847, ADuC848 (taking into account fact that the ADuC848 is a 16-bit ADC)
//
// Description : sample program that performs ADC conversions in
// continuous mode and sends results to a PC via the
// UART. Operates on the RTD (PT100) on the eval board
// via Ain1->Ain2 ADC inputs. The switches (S4) on the
// eval board must be set as follows to get this program
// working correctly...RTD AIN1, RTD AIN2, RTD REFIN+
// and RTD REFIN- must be set to ON. All other switches
// must be off.
//********************************************************************
#include <stdio.h>
#include <ADuC845.h> //To use this with an ADuC847 or ADuC848, simply change the
//header file to <ADuC847.h> or <ADuC848>
unsigned char test_data;
void TIC_int () interrupt 10
{ // EA=1;
test_data=test_data+1;
printf("\n");
printf("%bX",test_data);
}
void delay(int length)
{
while (length >=0)
length--;
}
void main (void)
{
T3CON = 0x83; //9600 Baud rate
T3FD = 0x12;
SCON = 0x52;
IEIP2 = 0x04; //Enable TIC interrupt
EA = 1; //Enable global interrupts
TIMECON = 0xD0; //Count in seconds
INTVAL = 0x01; //Count duration (5 second delay between temperature readings)
delay(10000); //Delay to allow TIC registers be written
//Since TIC operates from 32.768kHz time must be given
//to ensure the TIC registers are written to correctly.
TIMECON = 0xD3; //Start counting, enable INTVAL counter & TIC counter
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -