• 大小: 1.69MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-27
  • 语言: 其他
  • 标签: stm32  

资源简介

stm32芯片控制ds8b20在1602上显示

资源截图

代码片段和文件信息

 /*******************************************************************************
*  标题:                  试验数码管上显示温度                                  *
*     *
*********************************************************************************
* 目的: 1.通过本例程了解 DLASS18b20的基本原理和使用 理解并掌握18B20驱动程序的编写 *
*        2.了解掌握“一线”总线接口的工作原理及一般编程方法。  *
* 现象:   插上18B20 观察数码管的实际温度显示
* 连接: 用排线将JP8(P0口) 与 J12 连接在数码管上可以看温度显示 *
*  *
* 建议: 不要延时等待,用定时中断实现时序,来提高程序处理速度                   *
* 请学员认真消化本例程,懂DLASS18b20在C语言中的操作                            *
********************************************************************************/
#include “stm32f10x_lib.h“


 /********************************硬件接口定义*********************************/
#define    LS138A  GPIO_Pin_5 //=P2^2;       //管脚定义
#define    LS138B  GPIO_Pin_4 //=P2^3;
#define    LS138C  GPIO_Pin_3 //=P2^4; 


/******************************** 变量定义 ---------------------------------------------------------*/
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimebaseInitTypeDef  TIM_TimebaseStructure;
ErrorStatus HSEStartUpStatus;

//此表为 LED 的字模 共阴数码管 0-9  - 
unsigned char  Disp_Tab[] = {0x3f0x060x5b0x4f0x660x6d0x7d0x070x7f0x6f0x40}; 
u32  LedOut[7]LedNumVal;
u8 Count;
static vu32 TimingDelay;



/*********************************声明函数 -----------------------------------------------*/
void RCC_Configuration(void);
void NVIC_Configuration(void);
void SysTick_Configuration(void);
void HC595SendData(unsigned char SendVal);
void NOP(void);
extern GetTemp(void);       //声明引用外部函数
extern unsigned int   Temperature;               // 声明引用外部变量
void delay(unsigned int i);
void Tim_Setting(void);
void Delay_us(u32 nTime);


main()
{    unsigned char i; 

#ifdef DEBUG
// debug();  //在线调试使用
#endif

RCC_Configuration();      //系统时钟配置函数 

NVIC_Configuration();     //NVIC配置函数 

    SysTick_Configuration();   //Systick配置函数

Tim_Setting();   //调用事件设定函数

//启动GPIO模块时钟
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB1Periph_TIM2 | RCC_APB2Periph_AFIO ENABLE);
//把调试设置普通IO口
GPIO_PinRemapConfig(GPIO_Remap_SWJ_DisableENABLE);  
                        
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; //所有GPIO为同一类型端口
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;  //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;  //输出的最大频率为50HZ
GPIO_Init(GPIOA &GPIO_InitStructure);   //初始化GPIOA端口
GPIO_Init(GPIOB &GPIO_InitStructure);   //初始化GPIOB端口

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; //将DS18B20设为16脚
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;  //开漏输出  
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;  //输出的最大频率为50HZ
GPIO_Init(GPIOA &GPIO_InitStructure);   //初始化GPIOA端口

 

GPIO_Write(GPIOA0xffff);  //将GPIOA 16个端口全部置为高电平
GPIO_Write(GPIOB0xffff);  //将GPIOB 16个端口全部置为高电
   
    

    while(1)
   {
  GetTemp();

      /********以下将读18b20的数据送到LED数码管显示**

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      27718  2013-06-26 16:23  21 DS18B20 温度检测\18B20电路图.jpg

     文件     431769  2013-06-26 16:23  21 DS18B20 温度检测\datasheet-相关芯片手册\18b20x.pdf

     文件     396700  2013-06-26 16:23  21 DS18B20 温度检测\datasheet-相关芯片手册\18b20[1].pdf

     文件     470349  2013-06-26 16:23  21 DS18B20 温度检测\datasheet-相关芯片手册\18B20中文.pdf

    ..A..H.     16384  2013-06-26 16:23  21 DS18B20 温度检测\Thumbs.db

     文件     145508  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20.axf

     文件       9792  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20.hex

     文件      47783  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20.htm

     文件        370  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20.lnp

     文件      86177  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20.map

     文件       1577  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20.opt.bak

     文件        725  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20.plg

     文件       1129  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20.tra

     文件       2652  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20.Uv2.bak

     文件      57955  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20.uvopt

     文件      15148  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20.uvproj

     文件       4212  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20_HC6800-EM3.dep

     文件       1574  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20_Opt.Bak

     文件        249  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20_Target 1.dep

     文件       2324  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20_Uv2.Bak

     文件      57961  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20_uvopt.bak

     文件      15148  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32-18B20_uvproj.bak

     文件      35281  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32F10x.lst

     文件       5224  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32F10x.o

     文件      11307  2013-06-26 16:23  21 DS18B20 温度检测\程序\STM32F10x.s

     文件        173  2013-06-26 16:23  21 DS18B20 温度检测\程序\stm32f10x._ia

     文件    1759306  2013-06-26 16:25  21 DS18B20 温度检测\程序\STM32F10xR.LIB

     文件      10294  2013-06-26 16:23  21 DS18B20 温度检测\程序\TemMain.c

     文件     150019  2013-06-26 16:23  21 DS18B20 温度检测\程序\temmain.crf

     文件       1639  2013-06-26 16:23  21 DS18B20 温度检测\程序\temmain.d

............此处省略12个文件信息

评论

共有 条评论