欢迎来到天天文库
浏览记录
ID:955633
大小:75.00 KB
页数:13页
时间:2017-10-18
《ds18b20温度传感器(基于stm32)》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、/*----------------------------------------------main.c-------------------------------------------------------*/#include"stm32f10x.h"#include"stdio.h"#include"platform_config.h"#include"misc.h"#include"DS18b20.h"#include"Systick_Delay.h"/**@addtogroupStdPeriph_Examples*@{*/unsignedcharsi
2、gn,interger;unsignedintdecimal;/**@addtogroupTIM_TimeBase*@{*/voidRCC_Configuration(void);voidGPIO_Configuration(void);voidNVIC_Configuration(void);//intfputc(intch,FILE*f);//重定义串口字符串输出函数voidUSART_Configuration1(void);/*Privatetypedef-----------------------------------------------------
3、------*//*Privatedefine------------------------------------------------------------*//*Privatemacro-------------------------------------------------------------*//*Privatevariables---------------------------------------------------------*/TIM_TimeBaseInitTypeDefTIM_TimeBaseStructure;TIM
4、_OCInitTypeDefTIM_OCInitStructure;__IOuint16_tCCR1_Val=100;u16counter;ErrorStatusHSEStartUpStatus;/*Privatefunctionprototypes-----------------------------------------------*//*Privatefunctions---------------------------------------------------------*//***@briefMainprogram*@paramNone*@re
5、tval:None*/intmain(void){/*SystemClocksConfiguration*/RCC_Configuration();GPIO_Configuration();USART_Configuration1();/*NVICConfiguration*/NVIC_Configuration();/*GPIOConfiguration*//*---------------------------------------------------------------TIM2Configuration:OutputCompareTimingMode
6、:TIM2CLK=36MHz,Prescaler=4,TIM2counterclock=7.2MHz36/(4+1)=7.2MHZCC1updaterate=TIM2counterclock/CCR1_Val=146.48HzCC2updaterate=TIM2counterclock/CCR2_Val=219.7HzCC3updaterate=TIM2counterclock/CCR3_Val=439.4HzCC4updaterate=TIM2counterclock/CCR4_Val=878.9Hz---------------------------------
7、------------------------------*/TIM_TimeBaseStructure.TIM_Period=65535;//定时器最大值就是65535TIM_TimeBaseStructure.TIM_Prescaler=0;TIM_TimeBaseStructure.TIM_ClockDivision=0;TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;TIM_TimeBaseInit(TIM1,&TIM_TimeBaseStructure);/*Timebas
此文档下载收益归作者所有