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

📄 main._c

📁 ds18b20在数码管上显示温度,在avr128已编译通过
💻 _C
字号:
// Target : M128
// Crystal: 8.0000Mhz

#include <iom128v.h>
#include <macros.h> 
#include "define.h"
#include "delay.h"
#include "initrialm128.h"


void Coding_led(void);//8位数码管译码程序


//TIMER0 initialize - prescale:1024
// WGM: Normal
// desired value: 10mSec
// actual value:  9.984mSec (0.2%)
void timer0_init(void)
{
	TCCR0 = 0x00; //stop
	ASSR  = 0x00; //set async mode
	TCNT0 = 0xB2; //set count
	OCR0  = 0x4E;
	TCCR0 = 0x07; //start timer
	TIMSK |= 0x01; //timer interrupt sources
}

#pragma interrupt_handler timer0_ovf_isr:iv_TIM0_OVF
void timer0_ovf_isr(void)
{
	
	TCNT0 = 0xB2; //reload counter value
	//LED_PORT ^= BIT(LED1);
	
	if(sbit_led == 8)
	{
		sbit_led = 0;
	}
	SMG_PORT = 0XFF;
	SMG_BIT_PORT = 0xff;
	SMG_BIT_PORT &=~ BIT(sbit_led);
	SMG_PORT = led_disbuf[led_buf[i]];
	sbit_led ++;
	
	/*
	SMG_PORT = 0XFF;
	SMG_BIT_PORT &=~ BIT(0);
	SMG_PORT = led_disbuf[0];
	SMG_PORT = 0XFF;
	SMG_BIT_PORT &=~ BIT(1);
	SMG_PORT = led_disbuf[1];
	*/
	
	
}


void main(void)
{
	unsigned char n;
	Init_Devices();
	timer0_init();
	BELL_OFF();
	while(1)
	{	
		Coding_led();
	}
}


void Coding_led(void)//8位数码管译码程序
{
	unsigned char i;
	for(i=0;i<8;i++)
	{
		led_disbuf[i] = led_table[led_buf[i]];
	}
}






⌨️ 快捷键说明

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