main2.c

来自「AD592温度传感器在Atmega8L下的测量程序」· C语言 代码 · 共 70 行

C
70
字号
/*
文件:main.c
描述:AD592温度探测程序
编写:黄曦
*/
#include <avr/io.h>
#include <avr/delay.h>
#include <avr/pgmspace.h>
#include <stdio.h>

#define uchar unsigned char
#define uint unsigned int

static uint AdConvertBuff[8];

void delayms(uint t)
{
     uint i;
	 for(i=0;i<t;i++)
	     _delay_loop_2(1000);
}

//////////////////////////
/////////串口部分/////////
/////////////////////////
int usart_putchar(char ch)
{
	if(ch=='\n')
		usart_putchar('\r');
	loop_until_bit_is_set(UCSRA,UDRE);
	UDR=ch;
	return 0;
}

int usart_getchar(void)
{
	loop_until_bit_is_set(UCSRA,RXC);
	return UDR;
}
////

void IoInit(void)
{

	PORTC=0x00;
	DDRC=0x00;
	
	//uart初始化
	UCSRB=_BV(RXEN)|_BV(TXEN);
	UBRRL=25;				//9600bps
	
	//IO流UART连接
	fdevopen(usart_putchar,usart_getchar,0);
}


void main()
{
	uchar i;
	int ret;
	IoInit();
	delayms(10);
	
	while(1)
	{
		//ret=GetAdc()/2-25;
		printf("Test\r\n");
		delayms(250);
	}
}

⌨️ 快捷键说明

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