描述
<h3 style="line-height:1.8">* 1、项目功能介绍</h3>
<div>
<p id="u56996930">桌面温湿度仪项目使用<strong>STM32G030K6T6</strong>芯片作为主控芯片,该芯片使用Arm Cortex-M0+内核;最大主频64Mhz;</p>
<p id="u3e5f431e">具有32KB的Flash以及8K的SRAM,供电电压在2.0V~3.6V之间。</p>
</div>
<p style="line-height:1.8"> </p>
<h3 style="line-height:1.8">*2、项目属性</h3>
<hr>
<p style="line-height:1.8"><span style="color:#95a5a6;font-size:14px">首次公开</span></p>
<p style="line-height:1.8"> </p>
<p style="line-height:1.8"> </p>
<p style="line-height:1.8"> </p>
<h3 style="line-height:1.8">* 3、开源协议</h3>
<hr>
<p style="line-height:1.8"><span style="color:#95a5a6;font-size:14px">拥抱开源</span></p>
<p style="line-height:1.8"> </p>
<p style="line-height:1.8"><strong><span style="color:#0093e6">请在竞赛阶段填写 ↓</span></strong></p>
<p style="line-height:1.8"> </p>
<h3 style="line-height:1.8">*4、硬件部分</h3>
<hr>
<p style="line-height:1.8"><strong>STM32G030K6T6</strong>芯片作为主控芯片。</p>
<div>使用一个<strong>SHT40</strong>温湿度传感器模块用于检测温湿度,SHT40采用IIC进行通信,模块上R8、R9是IIC通信的上拉电阻,起到“线与”的作用,支持挂载多个设备。</div>
<p style="line-height:1.8"> </p>
<p style="line-height:1.8"> </p>
<h3 style="line-height:1.8">*5、软件部分</h3>
<hr>
<p> </p>
<p> 1.睡眠模式代码</p>
<p>//进入睡眠模式<br>HAL_SuspendTick(); //暂停滴答定时器,防止通过滴答定时器中断唤醒<br>HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /* 执行WFI指令, 进入睡眠模式 */</p>
<p>//退出睡眠模式,任意中断/事件退出<br>HAL_ResumeTick(); //恢复滴答定时器</p>
<p> 2.定时器相关代码</p>
<p>HAL_TIM_Base_Start_IT(&htim14); //开始定时器<br>HAL_TIM_Base_Stop_IT(&htim14); //停止定时器</p>
<p>/*<br> 函数内容:定时器溢出中断回调函数<br> 函数参数:TIM_HandleTypeDef *htim--定时器句柄<br> 返回值: 无<br>*/<br>void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)<br>{<br> if(htim->Instance == TIM14)<br> {<br> HAL_TIM_Base_Stop_IT(&htim14);<br> updata_flag++;<br> if(updata_flag <= 5000)<br> {<br> ShowNum(1,1,(device_paramter.Temp/100));<br> ShowNum(1,2,(device_paramter.Temp / 10 % 10));<br> ShowNum(1,3,device_paramter.Temp%10);<br> }<br> else if(updata_flag <= 10000)<br> {<br> ShowNum(2,1,(device_paramter.Humi/100));<br> ShowNum(2,2,(device_paramter.Humi / 10 % 10));<br> ShowNum(2,3,device_paramter.Humi%10);<br> }<br> else<br> {<br> updata_flag = 0;<br> sleep_flag++;<br> }<br> <br> __HAL_TIM_SetCounter(&htim14,0);<br> if(sleep_flag >= 2)<br> {<br> sleep_flag = 0;<br> device_paramter.sleepStatus = 1;<br> SN74HC595_Send_Data(SN_DIG,0xFF);<br> SN74HC595_Send_Data(SN_LED1,0x00);<br> SN74HC595_Send_Data(SN_LED2,0x00);<br> }<br> else{<br> HAL_TIM_Base_Start_IT(&htim14); <br> } <br> }<br>}</p>
<p> 3.优化数码管</p>
<p>/* 64Mhz时钟时,当ulCount为1,函数耗时3个时钟,延时=3*1/64us */<br>__asm void SysCtlDelay(unsigned long ulCount)<br>{<br> SUBS r0,#1;<br> BNE SysCtlDelay;<br> BX lr;<br>}</p>
<p>/*<br> 函数内容:数码管显示数据函数<br> 函数参数:uint8_t row----行号<br> uint8_t column-列号<br> uint8_t value--显示数据<br> 返回值:无<br>*/<br>void ShowNum(uint8_t row, uint8_t column, uint8_t value)<br>{<br> if(row == 1)<br> {<br> switch(column)<br> {<br> case 1: //如果是第一排第一个<br> SN74HC595_Send_Data(SN_DIG,0xFE);<br> SN74HC595_Send_Data(SN_LED1,sgh_value[value]);//显示值对应16进制数<br> break;<br> case 2:<br> SN74HC595_Send_Data(SN_DIG,0xFD);<br> SN74HC595_Send_Data(SN_LED1,(sgh_value[value]|0x80));<br> break;<br> case 3:<br> SN74HC595_Send_Data(SN_DIG,0xFB);<br> SN74HC595_Send_Data(SN_LED1,sgh_value[value]);<br> break;<br> default:<br> break;<br> }<br> SysCtlDelay(1000); //大致延时50us<br> SN74HC595_Send_Data(SN_LED1,0x00); //消影,防止错位<br> }<br> else<br> {<br> switch(column)<br> {<br> case 1:<br> SN74HC595_Send_Data(SN_DIG,0xF7);<br> SN74HC595_Send_Data(SN_LED2,sgh_value[value]);<br> break;<br> case 2:<br> SN74HC595_Send_Data(SN_DIG,0xEF);<br> SN74HC595_Send_Data(SN_LED2,(sgh_value[value]|0x80));<br> break;<br> case 3:<br> SN74HC595_Send_Data(SN_DIG,0xDF);<br> SN74HC595_Send_Data(SN_LED2,sgh_value[value]);<br> break;<br> default:<br> break;<br> }<br> SysCtlDelay(1000); //大致延时50us<br> SN74HC595_Send_Data(SN_LED2,0x00);<br> }<br>}</p>
<p style="line-height:1.8"> </p>
<p style="line-height:1.8"> </p>
<h3 style="line-height:1.8">*7、大赛LOGO验证</h3>
<hr>
<p style="line-height:1.8"> </p>
<p style="line-height:1.8"><span style="color:#95a5a6;font-size:14px">点击zip可下载大赛logo标识! <span style="text-decoration:underline"><a href="https://image.lceda.cn/easyedaResource/images/d1bbfd69f9404f56901a0e7b849b7245.rar" target="_blank">(大赛标识).zip</a></span></span></p>
<h3 style="line-height:1.8"> </h3>
<p style="line-height:1.8"><span style="font-size:14px"><a href="/posts/de460543d4cf4dacb5f0326612455578" target="_blank">前往查看更多详情 ></a></span></p>
<p style="line-height:1.8"> </p>
评论(0)