根据 8H8K64U-LQFP32官方芯片手册,
设计如下开发板,PCB 工程详见:
https://oshwhub.com/jinleili/scalable-temperature-and-humidit
视频展示
部分测试代码如下
- void main(void)
- {
- P_SW2 |= 0x80; //扩展寄存器(XFR)访问使能
-
- P0M1 = 0x00; P0M0 = 0x00; //设置为准双向口
- P1M1 = 0x00; P1M0 = 0x00; //设置为准双向口
- P2M1 = 0x00; P2M0 = 0x00; //设置为准双向口
- P3M1 = 0x00; P3M0 = 0x00; //设置为准双向口
- P4M1 = 0x00; P4M0 = 0x00; //设置为准双向口
- P5M1 = 0x00; P5M0 = 0x00; //设置为准双向口
- P6M1 = 0x00; P6M0 = 0x00; //设置为准双向口
- P7M1 = 0x00; P7M0 = 0x00; //设置为准双向口
-
- UartInit();
-
- printf("STC8H DHT11 Test.\r\n");
-
- while(1)
- {
- DHT_Collect(); //DHT11数据采集
- printf("Temperature = %u.%u°C\r\n",Temperature[0],Temperature[1]);
- printf("Humidity = %u.%u%%RH\r\n",Humidity[0],Humidity[1]);
- delay_ms(1000); //delay 1s
- }
- }
复制代码
完整项目工程见附件。
|