2675 views|4 replies

1453

Posts

1

Resources
The OP
 

[GD32L233C-START Review] On-chip temperature detection and display [Copy link]

This post was last edited by jinglixixi on 2022-2-16 12:08

The GD32L233C is equipped with a corresponding temperature detection channel, and the on-chip temperature can be detected with the help of the ADC analog-to-digital converter.

With the help of serial communication, the detection effect is shown in Figure 1 .

Figure 1 On-chip temperature detection

However, this is very inconvenient to use. If this function is combined with the display function of the OLED screen, it will be more intuitive and convenient. The implementation effect is shown in Figure 2 .

Figure 2 OLED screen display effect

So how is this achieved?

Since the display works in I2C mode, the clock and digital pins of the display can be directly connected to PB10 and PB11 of the development board , and the power supply can be connected to the 3.3V power supply.

After determining the hardware connection relationship, the next step is how to implement it with software.

Among them, the key is to have the support of digital display function, the content of this function is as follows:

void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size2)
{
 uint8_t t,temp;
 uint8_t enshow=0;
 for(t=0;t<len;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);
 }
}

In order to facilitate the display and verification of the detection, the main program of the on-chip temperature detection is:

int main(void)
{
  uint32_t a,b;
 systick_config();
 rcu_config();
 adc_config();
 gd_eval_com_init(EVAL_COM);
 usart_transmit_config(EVAL_COM, USART_TRANSMIT_ENABLE);
  rcu_periph_clock_enable(RCU_GPIOB);
  gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_10 | GPIO_PIN_11);
 gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_10 | GPIO_PIN_11);
  delay_1ms(500);
  OLED_Init();
  OLED_Clear();
  OLED_ShowString(8,0,"GD32L233C_START",16);
  OLED_ShowString(8,2,"Temp= .",16);
  OLED_ShowString(8,4,"voltage= .",16);
 while(1) {
 adc_software_trigger_enable(ADC_INSERTED_CHANNEL);
 delay_1ms(2000U);
 value = (int32_t)ADC_TEMP_CALIBRATION_VALUE;
 temperature = ((float)((int32_t)ADC_IDATA0 - value) * 3.3f / 4095 * 1000 / 3.3f) + 30;
 vref_value = (ADC_IDATA1 * 3.3f / 4095);
 printf(" the Temperature data is %2.1f degrees Celsius\r\n", temperature);
 printf(" the Reference voltage data is %5.3fV \r\n", vref_value);
 printf(" \r\n");
 a=(uint32_t) (temperature);
 OLED_ShowNum(48,2,a,2,16);
 a=(uint32_t) (temperature*100)%100;
 OLED_ShowNum(72,2,a,2,16);
 b=(uint32_t) vref_value;
 OLED_ShowNum(72,4,b,1,16);
 b=(uint32_t) (vref_value*1000)% 1000;
 OLED_ShowNum(88,4,b,3,16);
 }
}

After compiling and downloading the program, the displayed value is consistent with the output content of the serial port, which means that the program is correct and valid.

This post is from GD32 MCU

Latest reply

The temperature in the film is not very accurate, it can only be used as a reference   Details Published on 2022-2-16 23:01
 

6027

Posts

6

Resources
2
 

There is no configuration for ADC acquisition. The focus of this test should be the LCD display function of IIC communication.

This post is from GD32 MCU

Comments

Because there is a routine, it is omitted  Details Published on 2022-2-17 08:47
 
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 

7422

Posts

2

Resources
3
 

The temperature in the film is not very accurate, it can only be used as a reference

This post is from GD32 MCU

Comments

Haha, that’s right!  Details Published on 2022-2-17 08:46
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

1453

Posts

1

Resources
4
 
freebsder posted on 2022-2-16 23:01 The temperature in the film is not very accurate, it can only be used as a reference

Haha, that’s right!

This post is from GD32 MCU
 
 
 

1453

Posts

1

Resources
5
 
Qintianqintian0303 posted on 2022-2-16 21:07 There is no configuration for ADC acquisition. The focus of this test should be the LCD display function of IIC communication

Because there is a routine, it is omitted

This post is from GD32 MCU
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list