使用vivado2020.2,用zybo板,气压温度湿度传感器Grove-Temp&Humi&Barometer Sensor (BME280),实时时钟日历模块Pmod RTCC,128x32像素单色OLED屏Pmod OLED开发一个软件,要求:利用气压温度湿度传感器测量环境,并和实时日历一起显示在128x32像素单色OLED屏上,我不会创建工程,请详细说明并给出详细的全部代码
时间: 2023-12-06 22:04:23 浏览: 16
HDL 代码(续):
```verilog
function int16 bme280_data_to_press(int32 data);
int32 adc_P = (data[27:20] << 12) | (data[19:12] << 4) | (data[11:8] >> 4);
int32 v_x1_u32r = (((int32)bme280_t_fine) >> 1) - (int32)64000;
int32 v_x2_u32r = (((v_x1_u32r >> 2) * (v_x1_u32r >> 2)) >> 11) * ((int32)bme280_dig_P6);
v_x2_u32r = v_x2_u32r + ((v_x1_u32r * ((int32)bme280_dig_P5)) << 1);
v_x2_u32r = (v_x2_u32r >> 2) + (((int32)bme280_dig_P4) << 16);
v_x1_u32r = (((bme280_dig_P3 * (((v_x1_u32r >> 2) * (v_x1_u32r >> 2)) >> 13)) >> 3) + ((((int32)bme280_dig_P2) * v_x1_u32r) >> 1)) >> 18;
v_x1_u32r = (((32768 + v_x1_u32r)) * ((int32)bme280_dig_P1)) >> 15;
int32 pressure = (((1048576 - adc_P) - (v_x2_u32r >> 12)) * 3125);
pressure = (pressure / v_x1_u32r) << 1;
v_x1_u32r = (((int32)bme280_dig_P9) * ((int32)(((pressure >> 3) * (pressure >> 3)) >> 13))) >> 12;
v_x2_u32r = (((int32)(pressure >> 2)) * ((int32)bme280_dig_P8)) >> 13;
pressure = (pressure + ((v_x1_u32r + v_x2_u32r + bme280_dig_P7) >> 4));
bme280_data_to_press = pressure;
endfunction
// OLED 显示数据逻辑实现
always @ (posedge CLK_100MHZ) begin
if (rst) begin
oled_rst <= 1;
oled_dc <= 0;
oled_cs <= 1;
oled_data <= 0;
oled_clk <= 0;
oled_addr <= 0;
oled_data <= 0;
oled_clk <= 1;
oled_cs <= 0;
oled_rst <= 0;
end else begin
oled_dc <= 0;
oled_data <= 0;
oled_clk <= 0;
oled_cs <= 1;
oled_addr <= 0;
oled_data <= 0;
oled_clk <= 1;
oled_cs <= 0;
// 显示日期
oled_set_cursor(0, 0);
oled_set_font(1, 1);
oled_put_string("Date: ");
oled_put_number(day, 2, 0);
oled_put_string("/");
oled_put_number(month, 2, 0);
oled_put_string("/");
oled_put_number(year, 4, 0);
// 显示时间
oled_set_cursor(0, 9);
oled_put_string("Time: ");
oled_put_number(hour, 2, 0);
oled_put_string(":");
oled_put_number(min, 2, 0);
oled_put_string(":");
oled_put_number(sec, 2, 0);
// 显示温度
oled_set_cursor(0, 18);
oled_put_string("Temp: ");
oled_put_number(bme280_data_to_temp(bme280_data), 3, 1);
oled_put_string(" C");
// 显示湿度
oled_set_cursor(0, 27);
oled_put_string("Hum: ");
oled_put_number(bme280_data_to_hum(bme280_data), 2, 0);
oled_put_string(" %");
// 显示气压
oled_set_cursor(65, 27);
oled_put_string("Press: ");
oled_put_number(bme280_data_to_press(bme280_data), 4, 0);
oled_put_string(" Pa");
end
end
endmodule
```
这个代码需要从头到尾进行综合和实现,同时需要添加一些约束文件,才能在 Zybo 上正常运行。因此,如果您不熟悉这些步骤,建议您通过学习 Vivado 的相关教程来掌握这些知识。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)