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

📄 main.c

📁 基于AVR单片机的热电偶测量系统源码
💻 C
字号:
/************************************************************
  FileName: main.c
  Author:        Version :          Date:
  Description:     // 模块描述      
  Version:         // 版本信息
  Function List:   // 主要函数及其功能
    1. -------
  History:         // 历史修改记录
      <author>  <time>   <version >   <desc>
      David    96/10/12     1.0     build this moudle  
***********************************************************/
#include <iom16v.h>
#include <macros.h>
#include "main.h"
#include "initial_mcu.h"
#include "232.h"
#include "lcd.h"
#include "key.h"
#include "6675.h"
#include "1302.h"
#include "7135.h"

#define ICP PORTD&0x40
//全局变量
unsigned char entercount,leftcount,rightcount;
unsigned char position1302,hh,mm,positioncanbi,canbianjian;
unsigned int  time_array[6],canbi_array[5];

unsigned char endflag;
unsigned int ovcounter,pulse;

void show_time(void)
{
	unsigned char hour,min,sec;
	
	hour=pDS1302_Read(mDS1302_HOUR_Reg); //时 
    min=pDS1302_Read(mDS1302_MIN_Reg);  //分 
    sec=pDS1302_Read(mDS1302_SEC_Reg);  //秒 
	time_array[0]=hour>>4;
	time_array[1]=hour&0x0f;
	time_array[2]=min>>4;
	time_array[3]=min&0x0f;
	time_array[4]=sec>>4;
	time_array[5]=sec&0x0f;
	Draw_NtoArab(0x00,0x28,time_array[0]);
	Draw_NtoArab(0x00,0x30,time_array[1]);
	Draw_NtoArab(0x00,0x40,time_array[2]);
	Draw_NtoArab(0x00,0x48,time_array[3]);
	Draw_NtoArab(0x00,0x58,time_array[4]);
	Draw_NtoArab(0x00,0x60,time_array[5]);
}

void show_canbi(void)
{
	Draw_NtoArab(0x04,0x40,canbi_array[1]);
 	Draw_NtoArab(0x04,0x48,canbi_array[2]);
 	Draw_NtoArab(0x04,0x58,canbi_array[3]);
 	Draw_NtoArab(0x04,0x60,canbi_array[4]);
}

void data_init(void) 
{
  	unsigned char i;
  	entercount=0;
  	leftcount=0;
  	rightcount=0;
  	position1302=0;
  	positioncanbi=0x02;
  	for(i=1;i<5;i++)
  		canbi_array[i]=0x00;
}

void main(void)
{
	Initial_MCU();	//初始化mcu
	Initial_LCD();	//初始化LCD
	Com0_Init();	//初始化串口
	pDS1302_Init(); //初始化1302
	data_init();
    Clear_DDRAM(0x00,0x07); //清除lcd的所有显示内容
	Draw_Menu_Interface();	//绘制主菜单
	while(1)
	{
	 	Uart_Transmit('a');
	 	show_time();
	 	show_temperature();
	 	show_canbi();
	 	checkkey();
		display7135();
	}	
}


//测7135的busy信号所需的定时器捕获中断函数
#pragma interrupt_handler timer1_capt_isr:6
void timer1_capt_isr(void)
{
	if(ICP)
	{
	 	endflag=0;
		TCCR1B&=0xbf;	//下降沿捕获
	}
	else
	{
		pulse=ICR1;
		endflag=1;
		TCCR1B=0x00;	//stop timer1
	}
}

/*-----------------------------------------------------------------*-
  --------------------END OF FILE------------------------------------
 -*-----------------------------------------------------------------*/

⌨️ 快捷键说明

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