本文来源电子发烧友社区,作者:卢松涛, 帖子地址:https://bbs.elecfans.com/jishu_2249215_1_1.html
在"【南京中科微CSM32RV20开发板试用体验】+2-oled rtc的使用"基础上增加adc DHT11
adc的使用:
///---- Chapter 11 ADC Test Init -------------------------------------------------------------------------------------
uint32_t adc_result;
uint32_t adc_pack[16];
uint32_t adc_sum;
uint32_t adc_count;
uint32_t adc_avr;
uint32_t voltage_avr;
ADC_Init_case1();//内部基准,测PA4
//ADC_Init_case2();//外部基准,测PA4
10000ms ADC->SEL = 3; //测量通道选择:3-PAD4
串口控制 case 50://"2"
ADC->SEL = 0; //测量通道选择:0-PTAT 显示内部adc温度
DHT11的使用:
DHT11 GPIOB6
串口控制 case 49://"1"显示温度湿度
复制代码
com:
rt_tick_get:21537
RTC_MTIME->mtime:68924127 RTC_MTIME->mtime0-7B:99 f5 1b 4 0 0 0 0
RTC_MTIME->mtime:0
RTC_MTIMECMP->mtimecmp:68960000
->?RTC_MTIME->mtime:041c6480
RTC_MTIMECMP->mtimecmp0-7B:0 a3 1c 4 0 0 0 0
time is 1478 s
rt_tick_get:1482292
RTC_MTIME->mtime:448375682 RTC_MTIME->mtime0-7B:52 ee b9 1a 1 0 0 0
RTC_MTIME->mtime:1
RTC_MTIMECMP->mtimecmp:448411904
->?RTC_MTIME->mtime:1aba5e80
RTC_MTIMECMP->mtimecmp0-7B:0 9d ba 1a 1 0 0 0
val:9231avr:4887 1352.1mV 715.8mV
time:0 day 0 hour' 24:46
收到数据:1
Tempture:0.0 Humi:0.0
read_csr(mcycle):2
mcycle:413283856
Tempture:23.808 Humi:0.0
time is 1492 s
rt_tick_get:1492301
RTC_MTIME->mtime:480404340 RTC_MTIME->mtime0-7B:44 a6 a2 1c 1 0 0 0
RTC_MTIME->mtime:1
RTC_MTIMECMP->mtimecmp:480440704
->?RTC_MTIME->mtime:1ca31700
RTC_MTIMECMP->mtimecmp0-7B:80 55 a3 1c 1 0 0 0
收到数据:2
adc_val:5430
795.4mV
adc_val:5426
794.8mV
adc_val:5430
795.4mV
adc_val:5419
793.7mV
adc_val:5417
793.5mV
adc_val:5416
793.3mV
adc_val:5427
794.9mV
adc_val:5432
795.7mV
adc_val:5421
794.0mV
adc_val:5421
794.0mV
adc_val:5428
795.1mV
adc_val:5419
793.7mV
adc_val:5424
794.5mV
adc_val:5417
793.5mV
adc_val:5420
793.9mV
adc_val:5429
795.2mV
val:9623avr:51657617 1409.6mV 4179.3mV
time:0 day 0 hour' 25:2
rt_tick_get:1502303
RTC_MTIME->mtime:512409229 RTC_MTIME->mtime0-7B:5d 1 8b 1e 1 0 0 0
RTC_MTIME->mtime:1
RTC_MTIMECMP->mtimecmp:512443904
->?RTC_MTIME->mtime:1e8b6b80
RTC_MTIMECMP->mtimecmp0-7B:0 b6 8b 1e 1 0 0 0
在"【南京中科微CSM32RV20开发板试用体验】+2-oled rtc的使用"基础上增加adc DHT11
adc的使用:
///---- Chapter 11 ADC Test Init -------------------------------------------------------------------------------------
uint32_t adc_result;
uint32_t adc_pack[16];
uint32_t adc_sum;
uint32_t adc_count;
uint32_t adc_avr;
uint32_t voltage_avr;
ADC_Init_case1();//内部基准,测PA4
//ADC_Init_case2();//外部基准,测PA4
10000ms ADC->SEL = 3; //测量通道选择:3-PAD4
串口控制 case 50://"2"
ADC->SEL = 0; //测量通道选择:0-PTAT 显示内部adc温度
DHT11的使用:
DHT11 GPIOB6
串口控制 case 49://"1"显示温度湿度
- #include "headfile.h"
- #ifndef __OLEDFONT_H
- #define __OLEDFONT_H
- #define DHT11_REV_DATAGPIO_Read(GPIOB,PIN6)
- //常用ASCII表
- //偏移量32
- //ASCII字符集
- //偏移量32
- //大小:12*6
- /************************************6*8的点阵************************************/
- const unsigned char F6x8[][6] =
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp
- 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// !
- 0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// "
- 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// #
- 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $
- 0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// %
- 0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// &
- 0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// '
- 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// (
- 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// )
- 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// *
- 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// +
- 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// ,
- 0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// -
- 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// .
- 0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// /
- 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
- 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1
- 0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2
- 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3
- 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4
- 0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5
- 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
- 0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7
- 0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8
- 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9
- 0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// :
- 0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ;
- 0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// <
- 0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// =
- 0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// >
- 0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ?
- 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @
- 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A
- 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B
- 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C
- 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D
- 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E
- 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F
- 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G
- 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H
- 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I
- 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J
- 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K
- 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L
- 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M
- 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N
- 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O
- 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P
- 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
- 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R
- 0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S
- 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T
- 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U
- 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V
- 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W
- 0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X
- 0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y
- 0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z
- 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [
- 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55
- 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ]
- 0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^
- 0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _
- 0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// '
- 0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a
- 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b
- 0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c
- 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d
- 0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e
- 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f
- 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g
- 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h
- 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i
- 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j
- 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k
- 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l
- 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m
- 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n
- 0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o
- 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p
- 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q
- 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r
- 0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s
- 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t
- 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u
- 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v
- 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w
- 0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x
- 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y
- 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z
- 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines
- };
- /****************************************8*16的点阵************************************/
- const unsigned char F8X16[]=
- {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//0
- 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1
- 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2
- 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3
- 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4
- 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5
- 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6
- 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7
- 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8
- 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9
- 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10
- 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14
- 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15
- 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16
- 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
- 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
- 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
- 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
- 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
- 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
- 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
- 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
- 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
- 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26
- 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27
- 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28
- 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29
- 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30
- 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31
- 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32
- 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33
- 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34
- 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35
- 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36
- 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37
- 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38
- 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39
- 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40
- 0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41
- 0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42
- 0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43
- 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44
- 0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45
- 0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46
- 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47
- 0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48
- 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49
- 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50
- 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51
- 0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52
- 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53
- 0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54
- 0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55
- 0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56
- 0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57
- 0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58
- 0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59
- 0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,// 60
- 0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61
- 0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63
- 0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64
- 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65
- 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66
- 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67
- 0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68
- 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69
- 0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70
- 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71
- 0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72
- 0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73
- 0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74
- 0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75
- 0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76
- 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77
- 0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78
- 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79
- 0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80
- 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81
- 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82
- 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83
- 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84
- 0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85
- 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86
- 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87
- 0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88
- 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89
- 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90
- 0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91
- 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92
- 0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93
- 0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
- };
- /***********************************************
- PCtoLCD2002设置
- 阴码,逆向,C51格式,十六进制数据,列行式,输出三个全选中
- 每行显示点阵9999,索引9999
- 格式: 段前缀 【无】;
- 段后缀 【无】;
- 注释前缀(右边空格去掉) 【/ *"】;
- 注释后缀 【",】;
- 数据后缀 【,】;
- 行前缀 【{】;
- 行后缀 【},】
- **********************************************/
- /***********************************
- 16x16汉字
- 取字软件:PCtoLCD2002
- 使用方法见文档
- ***********************************/
- const unsigned char Chinese_Word_16[][32]= {
- {0x84,0x84,0xFC,0x84,0x84,0x40,0x64,0x54,0x4C,0x47,0x4C,0x54,0xE4,0x44,0x40,0x00,0x10,0x30,0x1F,0x08,0x08,0x00,0x1F,0x11,0x11,0x1F,0x40,0x80,0x7F,0x00,0x00,0x00},/*"琦",0*/
- {0x00,0x02,0x02,0x7A,0x4A,0x4A,0x4A,0x4A,0x7A,0x02,0x02,0x7E,0x02,0x02,0x00,0x00,0x01,0x01,0x01,0x3D,0x25,0x25,0x25,0x25,0x3D,0x41,0x81,0x7F,0x01,0x01,0x01,0x00},/*"哥",1*/
- {0x00,0x40,0x20,0x1E,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0xFF,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00},/*"牛",2*/
- {0x40,0x40,0x42,0xCC,0x00,0x82,0xBA,0xAA,0xAA,0xAA,0xAA,0xAA,0xBA,0x82,0x00,0x00,0x00,0x40,0x20,0x1F,0x20,0x5F,0x4A,0x4A,0x4A,0x4F,0x4A,0x4A,0x4A,0x5F,0x40,0x00},/*"逼",3*/
- };
- #endif
- void mp_receive_data(uint8_t *buf, uint16_t *len)
- {
- uint8_t rxlen = UART1_RX_CNT;
- uint16_t i = 0;
- *len = 0; //默认为0
- Delay32M_ms(10); //等待40ms,连续超过10ms没有接收到一个数据,则认为接收结束
- if (rxlen == UART1_RX_CNT && rxlen) //接收到了数据,且接收完成了
- {
- for (i = 0; i < rxlen; i++)
- {
- buf[i] = uart_dev.rxbuf[i];
- }
- *len = UART1_RX_CNT; //记录本次数据长度
- UART1_RX_CNT = 0; //清零
- uart_dev.frameok=1; //标记完成一帧数据接收
- // getData=0;//数据接收完成,标志位清零
- }
- }
- #define Max_Column 128
- void OLED_Write_IIC_Command(uint8_t IIC_Command)
- {
- I2C_Write(0x00,IIC_Command);
- }
- void OLED_Write_IIC_Data(uint8_t IIC_Data)
- {
- I2C_Write(0x40,IIC_Data);
- }
- /**
- * @brief :OLED_Clear
- * [url=home.php?mod=space&uid=1902110]@NOTE[/url] : --清屏函数
- --清完屏,整个屏幕是黑色的!和没点亮一样
- * @param : >>
- >>
- * @return :void
- *
- * @date :2021/01/29
- * [url=home.php?mod=space&uid=44345]@design[/url] :
- **/
- void OLED_Clear(void)
- {
- uint8_t i,n;
- for(i=0; i<8; i++)
- {
- OLED_Write_IIC_Command (0xb0+i); //设置页地址(0~7)
- OLED_Write_IIC_Command (0x00); //设置显示位置—列低地址
- OLED_Write_IIC_Command (0x10); //设置显示位置—列高地址
- for(n=0; n<128; n++)
- {
- OLED_Write_IIC_Data(0x00);
- }
- }
- //更新显示
- }
- /**
- * @brief :OLED_Set_Pos
- * @note : --坐标设置
- * @param : >>
- >>
- * @return :void
- *
- * @date :2021/01/29
- * @design :
- **/
- void OLED_Set_Pos(uint8_t x, uint8_t y)
- { OLED_Write_IIC_Command(0xb0+y);
- OLED_Write_IIC_Command(((x&0xf0)>>4)|0x10);
- OLED_Write_IIC_Command((x&0x0f));
- }
- /**
- * @brief :OLED_ShowChar
- * @note : --在指定位置显示一个字符,包括部分字符
- --例如:OLED_ShowChar(20,6,'A',16);
- * @param : >>
- >>x:0~127
- >>y:0~6
- >>mode:0,反白显示;1,正常显示
- >>size:选择字体 8/16
- * @return :void
- *
- * @date :2021/01/29
- * @design :
- **/
- void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size)
- {
- uint8_t c=0,i=0;
- c=chr-' ';//得到偏移后的值
- if(x>Max_Column-1) {
- x=0;
- y=y+2;
- }
- if(Char_Size ==16)
- {
- OLED_Set_Pos(x,y);
- for(i=0; i<8; i++)
- OLED_Write_IIC_Data(F8X16[c*16+i]);
- OLED_Set_Pos(x,y+1);
- for(i=0; i<8; i++)
- OLED_Write_IIC_Data(F8X16[c*16+i+8]);
- }
- else
- {
- OLED_Set_Pos(x,y);
- for(i=0; i<6; i++)
- OLED_Write_IIC_Data(F6x8[c][i]);
- }
- }
- /**
- * @brief :OLED_ShowString
- * @note : --显示一个字符号串
- --例如:
- u8 SET[2][3] = {{"ON "},{"OFF"}};
- OLED_ShowString(0,0,SET[0],8);
- * @param : >>
- >>size:选择字体 8/16
- * @return :void
- *
- * @date :2021/01/29
- * @design :
- **/
- void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size)
- {
- while (*chr!='')
- { OLED_ShowChar(x,y,*chr,Char_Size);
- x+=8;
- if(x>120) {
- x=0;
- y+=2;
- }
- chr++;
- }
- }
- /**********************************************
- //m^n函数
- **********************************************/
- uint32_t oled_pow(uint8_t m,uint8_t n)
- {
- uint32_t result=1;
- while(n--)result*=m;
- return result;
- }
- /**
- * @brief :OLED_ShowNumber
- * @note : --显示数字
- --例如:OLED_ShowNumber(0,0,45125215,10);
- * @param : >>x,y :起点坐标
- >>len :数字的位数
- >>size:字体大小默认16
- >>num:数值(0~4294967295);
- * @return :void
- *
- * @date :2021/01/29
- * @design :
- **/
- void OLED_ShowNumber(uint8_t x,uint8_t y,uint32_t num,uint8_t len)
- {
- uint8_t size2 = 16;
- uint8_t t,temp;
- uint8_t enshow=0;
- for(t=0; t;>
- {
- temp=(num/oled_pow(10,len-t-1))%10;
- if(enshow==0&&t<(len-1))
- {
- if(temp==0)
- {
- OLED_ShowChar(x+(size2/2)*t,y,' ',size2);
- continue;
- } else enshow=1;
- }
- OLED_ShowChar(x+(size2/2)*t,y,temp+'0',size2);
- }
- }
- //初始化SSD1306
- void OLED_Init(void)
- {
- // OLED_GPIO_Init();
- Delay32M_ms(1500);
- // OLED_WR_Byte(0xAE,OLED_CMD);//--display off
- // OLED_WR_Byte(0x00,OLED_CMD);//---set low column address
- // OLED_WR_Byte(0x10,OLED_CMD);//---set high column address
- // OLED_WR_Byte(0x40,OLED_CMD);//--set start line address
- // OLED_WR_Byte(0xB0,OLED_CMD);//--set page address
- // OLED_WR_Byte(0x81,OLED_CMD); // contract control
- // OLED_WR_Byte(0xFF,OLED_CMD);//--128
- // OLED_WR_Byte(0xA1,OLED_CMD);//set segment remap
- // OLED_WR_Byte(0xA6,OLED_CMD);//--normal / reverse
- // OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
- // OLED_WR_Byte(0x3F,OLED_CMD);//--1/32 duty
- // OLED_WR_Byte(0xC8,OLED_CMD);//Com scan direction
- // OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset
- // OLED_WR_Byte(0x00,OLED_CMD);//
- // OLED_WR_Byte(0xD5,OLED_CMD);//set osc division
- // OLED_WR_Byte(0x80,OLED_CMD);//
- // OLED_WR_Byte(0xD8,OLED_CMD);//set area color mode off
- // OLED_WR_Byte(0x05,OLED_CMD);//
- // OLED_WR_Byte(0xD9,OLED_CMD);//Set Pre-Charge Period
- // OLED_WR_Byte(0xF1,OLED_CMD);//
- // OLED_WR_Byte(0xDA,OLED_CMD);//set com pin configuartion
- // OLED_WR_Byte(0x12,OLED_CMD);//
- // OLED_WR_Byte(0xDB,OLED_CMD);//set Vcomh
- // OLED_WR_Byte(0x30,OLED_CMD);//
- // OLED_WR_Byte(0x8D,OLED_CMD);//set charge pump enable
- // OLED_WR_Byte(0x14,OLED_CMD);//
- // OLED_WR_Byte(0xAF,OLED_CMD);//--turn on oled panel
- OLED_Write_IIC_Command(0xAE); //display off
- OLED_Write_IIC_Command(0x20); //Set Memory Addressing Mode
- OLED_Write_IIC_Command(0x10); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
- OLED_Write_IIC_Command(0xb0); //Set Page Start Address for Page Addressing Mode,0-7
- OLED_Write_IIC_Command(0xc8); //Set COM Output Scan Direction
- OLED_Write_IIC_Command(0x00); //---set low column address
- OLED_Write_IIC_Command(0x10); //---set high column address
- OLED_Write_IIC_Command(0x40); //--set start line address
- OLED_Write_IIC_Command(0x81); //--set contrast control register
- OLED_Write_IIC_Command(0xff); //亮度调节 0x00~0xff
- OLED_Write_IIC_Command(0xa1); //--set segment re-map 0 to 127
- OLED_Write_IIC_Command(0xa6); //--set normal display
- OLED_Write_IIC_Command(0xa8); //--set multiplex ratio(1 to 64)
- OLED_Write_IIC_Command(0x3F); //
- OLED_Write_IIC_Command(0xa4); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content
- OLED_Write_IIC_Command(0xd3); //-set display offset
- OLED_Write_IIC_Command(0x00); //-not offset
- OLED_Write_IIC_Command(0xd5); //--set display clock divide ratio/oscillator frequency
- OLED_Write_IIC_Command(0xf0); //--set divide ratio
- OLED_Write_IIC_Command(0xd9); //--set pre-charge period
- OLED_Write_IIC_Command(0x22); //
- OLED_Write_IIC_Command(0xda); //--set com pins hardware configuration
- OLED_Write_IIC_Command(0x12);
- OLED_Write_IIC_Command(0xdb); //--set vcomh
- OLED_Write_IIC_Command(0x20); //0x20,0.77xVcc
- OLED_Write_IIC_Command(0x8d); //--set DC-DC enable
- OLED_Write_IIC_Command(0x14); //
- OLED_Write_IIC_Command(0xaf); //--turn on oled panel
- }
- uint16_t Tempture=0;
- uint16_t Humi=0;
- //void DHT11_Init(void);
- //int DHT11_Read_Data(void);
- static void DHT11_SEND_DATA(uint8_t value)
- {
- if(value==1)
- {
- GPIO_Write(GPIOB,PIN6,GPIO_SET);
- }
- else
- {
- GPIO_Write(GPIOB,PIN6,GPIO_RESET);
- }
- }
- #if 0//0---库函数1---寄存器
- // DTH11---> PB6
- // 输出模式(GPIOB,PIN6)
- void DHT11_OUT(void)
- {
- GPIOB->CRL &=~ (0xf<<24);
- GPIOB->CRL |=(3<<24);//通用推挽输出模式 50M
- }
- // 输入模式
- void DHT11_IN(void)
- {
- GPIOB->CRL &=~ (0xf<<24);
- GPIOB->CRL |=(4<<24);//配置浮空输入(外接上拉电阻)
- }
- //DHT11初始化
- void DHT11_Init(void)
- {
- RCC->APB2ENR |= (1<<3); // 开启PB端口时钟
- DHT11_IN( );// DHT11 的DATA 引脚处于输入状态,时刻检测外部信号
- Delay32M_ms(500);
- Delay32M_ms(500);//DHT11 上电后要等待 1S 以越过不稳定状态在此期间不能发送任何指令
- }
- #else
- // DTH11---> PB6
- // 输出模式
- void DHT11_OUT(void)
- {
- GPIO_MODE_Init(GPIOB,PIN6,GPIO_MODE_OUTPUT); //GPIO 模式
- GPIO_PULL_Init(GPIOB,PIN6,GPIO_PULLUP); //GPIO 上拉//PB6
- }
- // 输入模式
- void DHT11_IN(void)
- {
- GPIO_MODE_Init(GPIOB,PIN6,GPIO_MODE_INPUT); //GPIO 模式
- GPIO_PULL_Init(GPIOB,PIN6,GPIO_PULLUP); //GPIO
- }
- //DHT11初始化
- void DHT11_Init(void)
- {
- DHT11_OUT( );// DHT11 的DATA 引脚处于输出状态
- Delay32M_ms(500);
- Delay32M_ms(500);//DHT11 上电后要等待 1S 以越过不稳定状态在此期间不能发送任何指令
- }
- #endif
- //起始信号
- void DHT11_Start(void)
- {
- DHT11_SEND_DATA(0);
- Delay32M_ms(20);
- DHT11_SEND_DATA(1);
- Delay32M_us(35);//释放总线
- }
- //应答信号
- //返回值 0--无应答1--有应答
- uint8_t DHT11_Ack(void)
- {
- uint8_t count=20;
- while(count-->0)
- {
- if(DHT11_REV_DATA!=0)
- {
- Delay16M_us(2);
- continue;
- }
- while(DHT11_REV_DATA==0);//等待80us低电平应答结束
- while(DHT11_REV_DATA==1);//等待80us高电平应答结束
- return 1;
- }
- return 0;
- }
- //读取一个字节数据
- uint8_t DHT11_Read_Byte(void)
- {
- uint8_t data=0;
- uint8_t i;
- //接受数据,每个数据以50us低电平开始
- for(i=0;i<8;i++)
- {
- data <<= 1;
- while(!DHT11_REV_DATA);//等待发送数据的时序变为高电平
- Delay32M_us(40);//23~27u为数据0,68~74us为u数据1
- if(DHT11_REV_DATA==1)
- {
- data |=1;//数据1
- while(DHT11_REV_DATA);//等待高电平应答结束
- }
- }
- return data;
- }
- //读取温湿度
- int DHT11_Read_Data()
- {
- uint8_t check;
- uint8_t Humi_H,Humi_L,Temp_H,Temp_L;
- DHT11_OUT( );
- DHT11_Start( );
- DHT11_IN( );//切换为输入
- if( DHT11_Ack( )==0 )
- {
- return -1;
- }
- //读取数据
- Temp_H=DHT11_Read_Byte( );
- Temp_L=DHT11_Read_Byte( );
- Humi_H=DHT11_Read_Byte( );
- Humi_L=DHT11_Read_Byte( );
- check=DHT11_Read_Byte( );
- // ee_printf("rn%02xrn",Temp_H);
- // ee_printf("%02xrn",Temp_L);
- // ee_printf("%02xrn",Humi_H);
- // ee_printf("%02xrn",Humi_L);
- //结束读取
- Delay32M_ms(50);
- DHT11_OUT( );//切换为输出
- DHT11_SEND_DATA(1);//释放总线
- //校验数据
- if(check !=(Temp_H+Temp_L+Humi_H+Humi_L) )
- {
- return -2;
- }
- Tempture=(Temp_H&0xFF)<<8+Temp_L;
- Humi=(Humi_H&0xFF)<<8+Humi_L;
- return 0;
- }
- uint8_t ReceiveBuff[RECV_LEN];
- int main(void)
- {
- uint16_t rlen=0;
- uart_dev.rxlen=0;
- ///----System Init ---------------------------------------------------------------------------------------------
- CLIC_Init();//系统中断配置
- System_Clock_Init();//系统时钟初始化
- DHT11_Init();
- ///----Chapter 3 LowPower Test Init ---------------------------------------------------------------------------------
- //低功耗测功耗需要IO不能悬空
- //Delay32M_ms(5000);
- //LowPower_Config_case1();//所有IO设置为输入,下拉
- //LowPower_Config_case2();//所有IO设置为输入,上拉
- //使用外部中断唤醒
- //GPIO_EXIT_Init_case1(GPIOA, PIN2);//检测高电平
- //Interrupt_Level(EXIT2_int_ID, INT_LEVEL0);//CLIC设置中断抢占级别
- //Interrupt_Enable(EXIT2_int_ID);//CLIC使能EXIT中断
- //SYS_Interrupt_Enable();//CLIC开总中断
- //配置不同低功耗模式
- //System_Halt();//待机模式 halt1
- //System_Sleep();//睡眠模式 halt2
- //System_Powerdown();//掉电模式 powerdown1
- //System_DeepPwd();//掉电模式 powerdown2
- ///----Chapter 5 GPIO Test Init ---------------------------------------------------------------------------------
- GPIO_MODE_Init(GPIOA,PIN8,GPIO_MODE_OUTPUT); //GPIO 模式
- GPIO_MODE_Init(GPIOA,PIN10,GPIO_MODE_OUTPUT); //GPIO 模式
- GPIO_MODE_Init(GPIOA,PIN12,GPIO_MODE_OUTPUT); //GPIO 模式
- //GPIO_MODE_Init(GPIOA,PIN14,GPIO_MODE_OUTPUT); //GPIO 模式
- //GPIO_MODE_Init(GPIOA,PIN15,GPIO_MODE_OUTPUT); //GPIO 模式
- //GPIO_Write(GPIOA,PIN8,GPIO_SET); //GPIO 输出
- //GPIO_Write(GPIOA,PIN10,GPIO_SET); //GPIO 输出
- //GPIO_Write(GPIOA,PIN12,GPIO_SET); //GPIO 输出
- //GPIO_Write(GPIOA,PIN14,GPIO_RESET); //GPIO 输出
- //GPIO_Write(GPIOA,PIN15,GPIO_RESET); //GPIO 输出
- //GPIO_Toggle(GPIOA,PIN15); //GPIO 翻转
- //GPIO_MODE_Init(GPIOA,PIN15,GPIO_MODE_INTPUT); //GPIO 模式
- for(uint8_t i=0;i<10;i++)
- {
- GPIO_Toggle(GPIOA,PIN8); //GPIO 翻转
- Delay32M_ms(100);
- }
- ///---- Chapter 6 EXIT Test Init -------------------------------------------------------------------------------------
- //GPIO_EXIT_Init_case1(GPIOA, PIN2);//检测高电平
- //GPIO_EXIT_Init_case2(GPIOA, PIN2);//检测低电平
- //GPIO_EXIT_Init_case3(GPIOA, PIN2);//检测上升沿
- //GPIO_EXIT_Init_case4(GPIOA, PIN2);//检测下降沿
- //Interrupt_Level(EXIT2_int_ID, INT_LEVEL0);//CLIC设置中断抢占级别
- //Interrupt_Enable(EXIT2_int_ID);//CLIC使能EXIT中断
- //载波检测中断
- //CAW_Init();//载波检测
- //Interrupt_Enable(CAW_int_ID);//CLIC使能中断
- //SYS_Interrupt_Enable();//CLIC开总中断
- ///---- Chapter 7 RTC Test Init --------------------------------------------------------------------------------------
- //RTC_Init_case1();
- RTC_Init_case2();
- Interrupt_Level(MTIMER_int_ID, INT_LEVEL2 );//CLIC设置中断抢占级别
- Interrupt_Enable(MTIMER_int_ID);//CLIC使能中断
- SYS_Interrupt_Enable();//CLIC开总中断
- ///---- Chapter 8 IWDG Test Init -------------------------------------------------------------------------------------
- //IWDG_Init(9000); //配置看门狗计数值(时钟频率3K)
- //Delay32M_ms(1000);
- //IWDG_Start(); //启动看门狗
- //IWDG_Refresh(); //喂狗
- ///---- Chapter 9 Timer Test Init ------------------------------------------------------------------------------------
- //GPIO_MODE_Init(GPIOB,PIN11,GPIO_MODE_OUTPUT); //GPIO 模式
- //GPIO_MODE_Init(GPIOA,PIN9,GPIO_MODE_OUTPUT);
- //GPIO_MODE_Init(GPIOA,PIN11,GPIO_MODE_OUTPUT);
- //GPIO_MODE_Init(GPIOA,PIN13,GPIO_MODE_OUTPUT);
- //外设配置
- //Timer1_UpCounting_Mode_Init();//向上计数
- //Timer1_6StepPWM_Mode_Init();//6stepPWM输出
- //Timer2_UpCounting_Mode_Init();//向上计数
- //Timer2_DownCounting_Mode_Init();//向下计数
- //Timer2_ExternalClock_Mode_Init();//外部时钟
- //Timer2_InputCapture_Mode_Init();//输入捕获
- //Timer2_PWM_InputCapture_Mode_Init();//PWM输入捕获
- //Timer2_Input_XOR_Mode_Init();//输入异或
- //Timer2_PWM_Mode_Init();//PWM输出
- //Timer2_6StepPWM_Mode_Init();//6stepPWM输出
- //设置中断优先级
- //Interrupt_Level(TIMER1_updata_int_ID, INT_LEVEL1);//CLIC设置中断抢占级别
- //使能外设中断
- //Interrupt_Enable(TIMER1_break_int_ID);//CLIC使能中断
- //Interrupt_Enable(TIMER1_updata_int_ID);//CLIC使能中断
- //Interrupt_Enable(TIMER1_capture_compare_int_ID);//CLIC使能中断
- //Interrupt_Enable(TIMER1_trigger_comm_int_ID);//CLIC使能中断
- //Interrupt_Enable(TIMER2_break_int_ID);//CLIC使能中断
- //Interrupt_Enable(TIMER2_updata_int_ID);//CLIC使能中断
- //Interrupt_Enable(TIMER2_capture_compare_int_ID);//CLIC使能中断
- //Interrupt_Enable(TIMER2_trigger_comm_int_ID);//CLIC使能中断
- //使能系统总中断
- //SYS_Interrupt_Enable();//CLIC开总中断
- ///---- Chapter 10 WUP Test Init -------------------------------------------------------------------------------------
- //GPIO_MODE_Init(GPIOA,PIN2,GPIO_MODE_OUTPUT);
- //GPIO_MODE_Init(GPIOA,PIN3,GPIO_MODE_OUTPUT);
- //WUP_Init_case1(9000);//设置中断周期,使能WUP中断
- //Interrupt_Enable(WUP_int_ID);//CLIC使能中断
- //SYS_Interrupt_Enable();//CLIC开总中断
- //配置不同低功耗模式
- //System_Halt();//待机模式 halt1
- //System_Sleep();//睡眠模式 halt2
- //System_Powerdown();//掉电模式 powerdown1
- //System_DeepPwd();//掉电模式 powerdown2
- ///---- Chapter 11 ADC Test Init -------------------------------------------------------------------------------------
- uint32_t adc_result;
- uint32_t adc_pack[16];
- uint32_t adc_sum;
- uint32_t adc_count;
- uint32_t adc_avr;
- uint32_t voltage_avr;
- ADC_Init_case1();//内部基准,测PA4
- //ADC_Init_case2();//外部基准,测PA4
- ///---- Chapter 12 I2C Test Init -------------------------------------------------------------------------------------
- uint8_t i2c_data;
- I2C_Init_case1();//非中断模式
- //I2C_Init_case2();//ready中断模式
- //I2C_Init_case3();//error中断模式
- //I2C_Init_case4();//ready & error中断模式
- //Interrupt_Enable(I2C_ready_int_ID);//CLIC使能i2c_ready中断
- //Interrupt_Enable(I2C_error_int_ID);//CLIC使能i2c_error中断
- //SYS_Interrupt_Enable();//CLIC开总中断
- OLED_Init();
- ///---- Chapter 13 SPI1 Test Init ------------------------------------------------------------------------------------
- //uint8_t sTxpack[10] = {0,1,2,3,4,5,6,7,8,9};
- //uint8_t sRxpack[10] = {0,1,2,3,4,5,6,7,8,9};
- //uint8_t REG_Data;
- //SPI1 Init Test
- //SPI_Init_case1(SPI1);//非中断模式
- //SPI1_CSN_Init_case1();//CFG: CE-GPIO7,CSN-GPIO8
- //SPI_Init_case2(SPI1);//中断模式
- //Interrupt_Enable(SPI1_int_ID);//CLIC使能单个中断
- //SPI2 Init Test
- //SPI_Init_case1(SPI2);//非中断模式
- //SPI2_CSN_Init_case1();//CFG: CE-GPIO7,CSN-GPIO8
- //SPI_Init_case2(SPI2);//中断模式
- //Interrupt_Enable(SPI2_int_ID);//CLIC使能单个中断
- ///---- Chapter 15 UART Test Init -------------------------------------------------------------------------------
- //uint8_t upack1[20] = {0,1,2,3,4,5,6,7,8,9};
- //uint8_t upack2[20] = {0,1,2,3,4,5,6,7,8,9};
- //uint8_t upack3[20] = {0,1,2,3,4,5,6,7,8,9};
- //uint8_t upack4[20] = {10,1,2,3,4,5,6,7,8,9};
- //UART_Init_case1(UART2);//非中断模式
- //UART_Init_case1(UART3);//非中断模式
- //UART_Init_case1(UART4);//非中断模式
- UART_Init_IT_case1(UART1);//中断模式
- //UART_Init_IT_case1(UART4);//中断模式
- Interrupt_Enable(UART1_int_ID);//CLIC使能单个中断
- UART1->CTRL |= 0x00000001U;//清除中断标志位,防止开机先进一次中断
- //Interrupt_Enable(UART4_int_ID);//CLIC使能单个中断
- SYS_Interrupt_Enable();//CLIC开总中断
- //printf("uart init:rn");
- ///---- Chapter 16 LV Test Init --------------------------------------------------------------------------------------
- //LV_Init_case1(12);//设置低压报警阈值
- //LV_Interrupt_Enable();//使能低压报警中断
- //Interrupt_Enable(LV_int_ID);//CLIC使能单个中断
- //SYS_Interrupt_Enable();//CLIC开总中断
- ///---- Chapter 17 RANDGEN Test Init ---------------------------------------------------------------------------------
- //uint32_t rand_data;
- ///---- Chapter 18 compare Test Init ---------------------------------------------------------------------------------
- //COPM1_Init();//COPM1
- //Interrupt_Enable(COMP1_int_ID);//CLIC使能单个中断
- //COPM2_Init();//COPM2
- //Interrupt_Enable(COMP2_int_ID);//CLIC使能单个中断
- //COPM3_Init();//COPM3
- //Interrupt_Enable(COMP3_int_ID);//CLIC使能单个中断
- //SYS_Interrupt_Enable();//CLIC开总中断
- ///---- Chapter 22 flash Test Init ----------------------------------------------------------------------------------
- //NVR_RW_Test();//NVR read and write test
- //Flash_RW_Test();
- ///---- 系统总中断控制 -------------------------------------------------------------------------------------------------
- //SYS_Interrupt_Enable();//CLIC开总中断
- //SYS_Interrupt_Disable();//CLIC关总中断
- adc_pack[0]=read_csr(mcycle);
- adc_pack[1]=read_csr(mcycle);
- ee_printf("nHello CSM32RV20:n");
- ee_printf("mcycle:%d n",read_csr(mcycle));//比如mcycle这一CSR用于处理器运行的时钟周期计数
- ee_printf("read_csr(mcycle):%d n",adc_pack[1]-adc_pack[0]);//比如mcycle这一CSR用于处理器运行的时钟周期计数
- ee_printf("CMU->OSC_SR:%x n",CMU->OSC_SR );
- if(CMU->OSC_SR==210 ) ee_printf("CMU->OSC_SR:210,OSC 时钟已稳定,RCOSC 时钟已稳定,:OSC 在为 MCU 提供时钟;OSC 在为外设提供时钟; n" );
- //printf("Hello CSM32RV20:rn");
- ee_printf("请输入:on 或者off (开灯/关灯)rn");
- uint32_t rt_tick1 = rt_tick_get();
- uint32_t rt_tick2 = rt_tick_get();
- OLED_Clear();
- Delay32M_ms(1000);
- // OLED_Light();
- // OLED_DrawBMP(0,0,128,8,BAD_APPLE);
- OLED_ShowString(0,0,"CSM32 TEST",16);
- while(1)
- {
- mp_receive_data(ReceiveBuff, &rlen);
- if(uart_dev.frameok==1)//如果接收到数据
- {
- ee_printf("收到数据:");
- OLED_ShowString(0,2,"in:",16);
- Uart_Send(UART1,(uint8_t *)ReceiveBuff,rlen);
- OLED_ShowString(28,2,(uint8_t *)ReceiveBuff,16);
- ee_printf("rn");
- uint8_t aton= (uint8_t)ReceiveBuff[0];
- uint32_t data=0;
- switch (aton) {
- case 111://"o"
- if(1==rlen) break;
- if(ReceiveBuff[1]=='n')
- {
- GPIO_Write(GPIOA,PIN8,GPIO_RESET);
- ee_printf("灯开了!rn");
- }
- else if((ReceiveBuff[1]=='f')&&(ReceiveBuff[2]=='f'))
- {
- GPIO_Write(GPIOA,PIN8,GPIO_SET);
- ee_printf("关灯了!rn");
- }
- else
- {
- ee_printf("请输入:on 或者off (开灯/关灯)rn");
- }
- break;
- case 48://"0"
- ee_printf("nRTC_MTIME->mtimelo:%u n",_REG32(RTC_MTIME,0));
- ee_printf("nRTC_MTIME->mtimehi:%u n",_REG32(0x0200bff8UL,4));
- // uint64_t mtime1=RTC_MTIME->mtime;
- // ee_printf("nRTC_MTIME->mtime-all:%lu n",mtime1);
- break;
- case 49://"1"
- data=DHT11_Read_Data();
- if(data==0)
- {
- OLED_ShowString(0,2,"T:",16);
- OLED_ShowNumber(20,2,Tempture/1000,2);
- OLED_ShowString(36,2,".",16);
- OLED_ShowNumber(46,2,Tempture%1000,3);
- OLED_ShowString(0,4,"H:",16);
- OLED_ShowNumber(20,4,Humi/1000,2);
- OLED_ShowString(36,4,".",16);
- OLED_ShowNumber(40,4,Humi%1000,3);
- }
- ee_printf("Tempture:%u.%u Humi:%u.%un",Tempture/1000 ,Tempture%1000,Humi/1000,Humi%1000);
- adc_pack[0]=read_csr(mcycle);
- adc_pack[1]=read_csr(mcycle);
- ee_printf("read_csr(mcycle):%d n",adc_pack[1]-adc_pack[0]);//比如mcycle这一CSR用于处理器运行的时钟周期计数
- ee_printf("mcycle:%d n",read_csr(mcycle));//比如mcycle这一CSR用于处理器运行的时钟周期计数
- Delay32M_ms(2000);
- data=DHT11_Read_Data();
- if(data==0)
- {
- OLED_ShowString(0,2,"T:",16);
- OLED_ShowNumber(20,2,Tempture/1000,2);
- OLED_ShowString(36,2,".",16);
- OLED_ShowNumber(46,2,Tempture%1000,3);
- OLED_ShowString(0,4,"H:",16);
- OLED_ShowNumber(20,4,Humi/1000,2);
- OLED_ShowString(36,4,".",16);
- OLED_ShowNumber(40,4,Humi%1000,3);
- }
- ee_printf("Tempture:%u.%u Humi:%u.%un",Tempture/1000 ,Tempture%1000,Humi/1000,Humi%1000);
- // ee_printf("type?RTC_MTIME->mtime:%lu n",type(RTC_MTIME->mtime));
- break;//
- case 50://"2"
- ADC->SEL = 0; //测量通道选择:0-PTAT,1-1/2VDD,2-PAD3,3-PAD4,4-PAD5,5-PAD6,6-PAD7,7-PAD8,8-PAD9,9-PAD10,10-NTC,11-VDD,其它-无
- Delay32M_us(20);//ADC电源开启需要时间
- //
- for(uint8_t i=0;i<16;i++)
- {
- adc_result = ADC_Conversion();//适用于非中断模式 adc_sum += adc_pack[i];
- printf("adc_val:%urn",adc_result);
- ee_printf("%d.%dmV rn",(adc_result*4*12000/32768)/10,(adc_result*4*12000/32768)%10);
- Delay32M_ms(20); }
- ADC->SEL = 3; //测量通道选择:0-PTAT,1-1/2VDD,2-PAD3,3-PAD4,4-PAD5,5-PAD6,6-PAD7,7-PAD8,8-PAD9,9-PAD10,10-NTC,11-VDD,其它-无
- Delay32M_us(20);//ADC电源开启需要时间
- GPIO_MODE_Init(GPIOA,PIN4,GPIO_MODE_ANALOG);//设置GPIO为ADC输入
- break;
- // case 49 ... 57://"1~9"
- // timeProducing[9]=rt_tick_get();
- // timeProducing[6]=timeProducing[6]*10+a;
- // timeProducing[7]++;
- // if ( timeProducing[7]==2) {
- // date[1]=timeProducing[6];
- // timeProducing[9]=rt_tick_get();
- // timeProducing[8]++;
- // timeProducing[7]=0;
- //
- // rt_kprintf("pleases input month :");
- //
- // }
- //
- // break;
- //
- //
- // case 21:
- // timeProducing[9]=rt_tick_get();
- // timeProducing[6]=timeProducing[6]*10+date_a;
- // timeProducing[7]++;
- // if ( timeProducing[7]==4) {
- // date[0]=timeProducing[6];
- // timeProducing[9]=rt_tick_get();
- // timeProducing[8]=11;
- // timeProducing[7]=0;
- //
- // rt_kprintf("year is %d,pleases input month :",date[0]);
- //
- // }
- //
- // break;
- default:
- break;
- }
- // if((ReceiveBuff[0]=='o')&&(ReceiveBuff[1]=='n'))
- // {
- // GPIO_Write(GPIOA,PIN8,GPIO_RESET);
- // ee_printf("灯开了!rn");
- // }
- // else if((ReceiveBuff[0]=='o')&&(ReceiveBuff[1]=='f')&&(ReceiveBuff[2]=='f'))
- // {
- // GPIO_Write(GPIOA,PIN8,GPIO_SET);
- // ee_printf("关灯了!rn");
- // }
- // else
- // {
- // ee_printf("请输入:on 或者off (开灯/关灯)rn");
- // }
- uart_dev.frameok=0;
- uart_dev.rxlen=0;
- }
- if( rt_tick_get()%1000==0) ee_printf("time is %u s n",rt_tick_get()/1000);
- if(!( rt_tick_get()- rt_tick1< 10000)){
- rt_tick1 = rt_tick_get() ;
- GPIO_Toggle(GPIOB,PIN8);
- GPIO_Toggle(GPIOA,PIN10); //GPIO 翻转
- // ee_printf("mcycle:%u n",read_csr(mcycle));
- ee_printf("rt_tick_get:%u n", rt_tick_get());
- ee_printf("RTC_MTIME->mtime:%lu ",RTC_MTIME->mtime);
- // ee_printf("type?RTC_MTIME->mtime:%lu n",type(RTC_MTIME->mtime));
- ee_printf("RTC_MTIME->mtime0-7B:");
- for (uint8_t i = 0; i < 8; i++)
- {
- ee_printf("%x ",_REG8(0x0200bff8UL,i));
- }
- ee_printf("nRTC_MTIME->mtime:%u n",_REG32(0x0200bff8UL,4));
- ee_printf("RTC_MTIMECMP->mtimecmp:%lu n",RTC_MTIMECMP->mtimecmp);
- // ee_printf("type?RTC_MTIME->mtime:%lu n",type(RTC_MTIMECMP->mtimecmp));
- ee_printf("->?RTC_MTIME->mtime:%p n",RTC_MTIMECMP->mtimecmp);
- ee_printf("RTC_MTIMECMP->mtimecmp0-7B:");
- for (uint8_t i = 0; i < 8; i++)
- {
- ee_printf("%x ",_REG8(0x02004000UL,i));
- }
- ee_printf(" n");
- }
- // Delay32M_ms(500);
- //Delay16M_ms(500);
- //Delay16M_us(500000);
- //GPIO_Toggle(GPIOA,PIN15);
- //printf("main:rn");
- ///---- Chapter 6 EXIT test ---------------------------------------------------------------------------------
- //delay16M_ms(500);
- //GPIO_Toggle(GPIOA,PIN15);
- ///---- Chapter 8 IWDG test ---------------------------------------------------------------------------------
- //IWDG_Refresh();
- //delay16M_ms(500);
- //GPIO_Toggle(GPIOA,PIN15);
- ///---- Chapter 9 Timer test --------------------------------------------------------------------------------
- //---- soft break --------------------------------------------------------------------------------------
- //delay16M_ms(100);
- //TIMER2->BDTR |= 1 <<15;//BDTR[15]-MOE-主输出使能:0-关闭,1-使能
- //delay16M_ms(100);
- //TIMER2->EGR |= 1 <<7;//EGR[7]-BG-产生刹车事件
- //---- soft COM ----------------------------------------------------------------------------------------
- //delay16M_ms(100);
- //TIMER2->EGR = 1 <<5;//EGR[5]-COMG-捕获/比较事件,产生控制更新
- //---- generate oxr ------------------------------------------------------------------------------------
- /*
- Delay16M_ms(10);//1
- GPIO_Write(GPIOA,PIN9,GPIO_SET);
- GPIO_Write(GPIOA,PIN11,GPIO_RESET);
- GPIO_Write(GPIOA,PIN13,GPIO_SET);
- Delay16M_ms(10);//2
- GPIO_Write(GPIOA,PIN9,GPIO_SET);
- GPIO_Write(GPIOA,PIN11,GPIO_RESET);
- GPIO_Write(GPIOA,PIN13,GPIO_RESET);
- Delay16M_ms(10);//3
- GPIO_Write(GPIOA,PIN9,GPIO_SET);
- GPIO_Write(GPIOA,PIN11,GPIO_SET);
- GPIO_Write(GPIOA,PIN13,GPIO_RESET);
- Delay16M_ms(10);//4
- GPIO_Write(GPIOA,PIN9,GPIO_RESET);
- GPIO_Write(GPIOA,PIN11,GPIO_SET);
- GPIO_Write(GPIOA,PIN13,GPIO_RESET);
- Delay16M_ms(10);//5
- GPIO_Write(GPIOA,PIN9,GPIO_RESET);
- GPIO_Write(GPIOA,PIN11,GPIO_SET);
- GPIO_Write(GPIOA,PIN13,GPIO_SET);
- Delay16M_ms(10);//6
- GPIO_Write(GPIOA,PIN9,GPIO_RESET);
- GPIO_Write(GPIOA,PIN11,GPIO_RESET);
- GPIO_Write(GPIOA,PIN13,GPIO_SET);
- */
- ///---- Chapter 11 ADC test ---------------------------------------------------------------------------------
- if(!( rt_tick_get()- rt_tick2< 15000)){
- rt_tick2 = rt_tick_get();
- adc_result = ADC_Conversion();//适用于非中断模式
- //printf("adc_val:%drn",adc_result);
- adc_pack[(adc_count++)&0xf] = adc_result;
- adc_sum=0;
- for(uint8_t i=0;i<16;i++)
- {
- adc_sum += adc_pack[i];
- }
- adc_avr = adc_sum/16;
- ee_printf("val:%davr:%d %d.%dmV %d.%dmVrn",adc_result,adc_avr,(adc_result*4*12000/32768)/10,(adc_result*4*12000/32768)%10,(adc_avr*4*12000/32768)/10,(adc_avr*4*12000/32768)%10);
- //ADC_Soft_Start();//软件触发ADC,适用于中断模式
- OLED_ShowString(0,4,"adc:",16);
- OLED_ShowNumber(40,4,(adc_avr*4*12000/32768)/10,2);
- OLED_ShowString(76,4,".",16);
- OLED_ShowNumber(80,4,(adc_avr*4*12000/32768)%10,3);
- adc_result =rt_tick_get()/1000;
- adc_sum=adc_result /60;
- adc_avr = adc_sum/60;
- ee_printf("time:%d day %d hour' %d:%dn",adc_avr/24,adc_avr%24,adc_sum%60,adc_result %60);
- OLED_ShowString(0,6,"time:",16);
- OLED_ShowNumber(40,6,adc_avr/24,2);
- OLED_ShowString(56,6,"d",16);
- OLED_ShowNumber(64,6,adc_avr%24,2);
- OLED_ShowString(80,6,":",16);
- OLED_ShowNumber(88,6,adc_sum%60,2);
- OLED_ShowString(104,6,":",16);
- OLED_ShowNumber(112,6,adc_result %60,2);
- }
- ///---- Chapter 12 I2C test ---------------------------------------------------------------------------------
- //I2C_Write(0x2d,0x55);//适用于非中断模式
- //i2c_data = I2C_Read(0x2d);//适用于非中断模式
- //printf("data:%xrn",i2c_data);
- //I2C_Write(0x2d,0xaa);//适用于非中断模式
- //i2c_data = I2C_Read(0x2d);//适用于非中断模式
- //printf("data:%xrn",i2c_data);
- //I2C_Write_IT(0x2d,0x55);//适用于中断模式
- ///---- Chapter 13 SPI test --------------------------------------------------------------------------------
- //SPI1 Test
- //SPI_Transceive(SPI1,sTxpack,sRxpack,10);//非中断模式
- //SPI1_RW_reg(WRITE_REG+0x05,0x53);//读写Si24R1寄存器
- //REG_Data = SPI1_RW_reg(READ_REG+0x05,0);//读写Si24R1寄存器
- //printf("rnREG5:%02x",REG_Data);
- //delay16M_ms(500);
- //SPI2 Test
- //SPI_Transceive(SPI2,sTxpack,sRxpack,10);//非中断模式
- //SPI2_RW_reg(WRITE_REG+0x05,0x53);//读写Si24R1寄存器
- //REG_Data = SPI2_RW_reg(READ_REG+0x05,0);//读写Si24R1寄存器
- //printf("rnREG5:%02x",REG_Data);
- //delay16M_ms(500);
- ///---- Chapter 15 UART Test ------------------------------------------------------------------------------------
- //---- 非中断模式数据回环测试 -------------------------------------------------------------------------------------
- //Uart_Reveive(UART1,upack1,10);//适用于非中断发送模式
- //Uart_Send(UART1,upack1,10);//适用于非中断发送模式
- //Uart_Reveive(UART2,upack2,10);//适用于非中断发送模式
- //Uart_Send(UART2,upack2,10);//适用于非中断发送模式
- //Uart_Reveive(UART3,upack3,10);//适用于非中断发送模式
- //Uart_Send(UART3,upack3,10);//适用于非中断发送模式
- //Uart_Reveive(UART4,upack4,10);//适用于非中断发送模式
- //Uart_Send(UART4,upack4,10);//适用于非中断发送模式
- //---- 中断模式数据回环测试 --------------------------------------------------------------------------------------
- //UART1_putbuf(UART1_getbuf());
- //---- printf测试 ----------------------------------------------------------------------------------------
- //printf("Hellow-01234568789abcdefghijklmnopqrstuvwxyzrn");
- ///---- Chapter 17 RANDGEN test -----------------------------------------------------------------------------
- //rand_data = RAND_Get();//生成随机数
- //printf("rand:0x%08x,%urn",rand_data,rand_data);
- //delay16M_ms(500);
- ///---- Chapter 18 COMPARE test -----------------------------------------------------------------------------
- //if(COMP1->irq&0x1)
- //{
- //GPIO_Toggle(GPIOA,PIN15);
- //COMP1->irq = 1;
- //}
- //delay16M_ms(10);
- }
- return 0;
- }
- //}
com:
rt_tick_get:21537
RTC_MTIME->mtime:68924127 RTC_MTIME->mtime0-7B:99 f5 1b 4 0 0 0 0
RTC_MTIME->mtime:0
RTC_MTIMECMP->mtimecmp:68960000
->?RTC_MTIME->mtime:041c6480
RTC_MTIMECMP->mtimecmp0-7B:0 a3 1c 4 0 0 0 0
time is 1478 s
rt_tick_get:1482292
RTC_MTIME->mtime:448375682 RTC_MTIME->mtime0-7B:52 ee b9 1a 1 0 0 0
RTC_MTIME->mtime:1
RTC_MTIMECMP->mtimecmp:448411904
->?RTC_MTIME->mtime:1aba5e80
RTC_MTIMECMP->mtimecmp0-7B:0 9d ba 1a 1 0 0 0
val:9231avr:4887 1352.1mV 715.8mV
time:0 day 0 hour' 24:46
收到数据:1
Tempture:0.0 Humi:0.0
read_csr(mcycle):2
mcycle:413283856
Tempture:23.808 Humi:0.0
time is 1492 s
rt_tick_get:1492301
RTC_MTIME->mtime:480404340 RTC_MTIME->mtime0-7B:44 a6 a2 1c 1 0 0 0
RTC_MTIME->mtime:1
RTC_MTIMECMP->mtimecmp:480440704
->?RTC_MTIME->mtime:1ca31700
RTC_MTIMECMP->mtimecmp0-7B:80 55 a3 1c 1 0 0 0
收到数据:2
adc_val:5430
795.4mV
adc_val:5426
794.8mV
adc_val:5430
795.4mV
adc_val:5419
793.7mV
adc_val:5417
793.5mV
adc_val:5416
793.3mV
adc_val:5427
794.9mV
adc_val:5432
795.7mV
adc_val:5421
794.0mV
adc_val:5421
794.0mV
adc_val:5428
795.1mV
adc_val:5419
793.7mV
adc_val:5424
794.5mV
adc_val:5417
793.5mV
adc_val:5420
793.9mV
adc_val:5429
795.2mV
val:9623avr:51657617 1409.6mV 4179.3mV
time:0 day 0 hour' 25:2
rt_tick_get:1502303
RTC_MTIME->mtime:512409229 RTC_MTIME->mtime0-7B:5d 1 8b 1e 1 0 0 0
RTC_MTIME->mtime:1
RTC_MTIMECMP->mtimecmp:512443904
->?RTC_MTIME->mtime:1e8b6b80
RTC_MTIMECMP->mtimecmp0-7B:0 b6 8b 1e 1 0 0 0
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。
举报投诉
-
南京中科微
+关注
关注
0文章
60浏览量
745 -
CSM32RV20
+关注
关注
0文章
40浏览量
216
发布评论请先 登录
相关推荐
《DNESP32S3使用指南-IDF版_V1.6》第三十章 DHT11数字温湿度传感器
到开发板后,可以看到LED0不停的闪烁,提示程序已经在运行了。LCD显示当前的温度值的内容如图30.4.1所示:图30.4.1 程序运行效果图至此,本章实验结束。大家可以将本章通过DHT11读取到的温度值,和前一章的通过DS18B20
发表于 12-26 09:26
追加名额丨米尔瑞芯微RK3576开发板有奖试用
米尔与瑞芯微合作发布的新品基于瑞芯微RK3576应用处理器的MYD-LR3576开发板免费试用活动加码啦~~米尔追加了2块价值849元的MYD-LR3576
常用在工业控制系统上的MCU芯片资料:CSM32RV20
CSM32RV20是一款基于RISC-V核的低功耗MCU芯片。 内置RISC-V RV32IMAC内核(2.6CoreMark/MHz); 蕞高32MHz工作频率; 内置4kB的SRAM; 内置8B
有奖丨米尔 瑞芯微RK3576开发板免费试用
米尔与瑞芯微合作发布的新品基于瑞芯微RK3576应用处理器的MYD-LR3576开发板免费试用活动来啦~~米尔提供了7块价值849元的MYD-LR3576
dht11温湿度传感器工作原理介绍
DHT11是一种常用的温湿度传感器,它能够测量温度和相对湿度。这种传感器广泛应用于智能家居、气象站、农业监控等领域。 DHT11温湿度传感器工作原理 在现代科技的发展中,环境监测变得越来越重要
dht11采用什么通信协议
DHT11是一款广泛使用的温湿度传感器,它通过简单的数字接口与微控制器或其他数字设备进行通信。DHT11使用单总线通信协议,这意味着所有的数据传输都通过单一的数据线完成。这种通信方式简单且成本低
怎么检测dht11模块有没有坏
以下是一些基本的检查步骤: 视觉检查 : 检查DHT11模块是否有任何明显的物理损伤,如裂缝、烧痕或弯曲的引脚。 检查电源 : 确保DHT11模块正确连接到电源,并且电源电压符合模块的要求(通常为
DHT11型传感器参数分析
DHT11型传感器是一款集温湿度测量于一体的数字传感器,其参数特性分析如下: 一、测量范围 温度 :DHT11的温度测量范围在多个资料中有所提及,一般公认的较宽范围是 -20℃~+60℃ 。但需要
dht11温度传感器特性的具体含义
通常为 0℃~50℃ (也有资料指出其温度测量范围为 -20℃~+60℃ ,但这一范围可能因不同批次或生产厂商而有所差异)。这意味着它适用于大多数常温环境下的温度监测。 2. 精度 温度测量精度 :DHT11的温度传感器具有±2℃的测量精度。这意味着在测量温度时,其读数与
dht11温度传感器的原理及应用
DHT11是一种广泛使用的数字温湿度传感器,它能够测量温度和相对湿度。这种传感器因其低成本、易于使用和相对较高的准确性而受到欢迎。 DHT11传感器的原理 DHT11传感器的核心是一个半导体湿度
DHT11温度传感器测量范围与精度
如下: 测量范围 DHT11的温度测量范围在不同条件下有所变化,但一般可归纳为: 基本测量范围 :温度-20°C至+60°C(或在某些资料中提及为0°C至50°C,这可能是特定条件下的范围,但更广泛认可的范围是-20°C至+60
ds18b20温度传感器和dht11的区别
DS18B20和DHT11都是常用的温度和湿度传感器,它们在许多项目和应用中都有广泛的应用。 1. 工作原理 DS18B20 DS18B20是一种数字温度传感器,它使用1-Wire通信
【龙芯2K0300蜂鸟板试用】第七篇 龙芯2K0300蜂鸟板--驱动DHT11
一下即可,如图1所示。
图1选择DTH11模块
在设备树里,修改相应说明,增加DHT11的说明(如图2),因为这里用到了引脚61(该引脚默认是SPI的,所以注释掉使其作为GPIO引脚使用,如图3所示
发表于 09-02 10:30
【先楫HPM5361EVK开发板试用体验】温湿度传感器DHT11实践
开发环境:
IDE:RT-Thread Studio 2.2.7
开发板:HPM5300EVK
1 理论分析
1.1 DHT11介绍
DHT11 数字温湿度传感器是一款含有已校准数字信
发表于 01-03 23:46
评论