【米尔电子MYC-YG2LX开发板测评】+05.温度及ADC功能测试(zmj)
MYD-YG2LX 采用瑞萨 RZ/G2L 作为核心处理器,该处理器搭载双核 Cortex-A55@1.2GHz+Cortex-M33@200MHz 处理器,其内部集成高性能 3D 加速引擎 Mail-G31 GPU(500MHz)和视频处理单元(支持 H.264 硬件编解码),16 位的 DDR4-1600 / DDR3L-1333 内存控制器、千兆以太网控制器、USB、CAN、SD 卡、MIPI-CSI 等外设接口,在工业、医疗、电力等行业都得到广泛的应用。 本章节将以米尔的 MYD-YG2LX 开发板为例进行CPU自带的芯片温度及ADC功能测试说明。 1. 芯片温度获取 CPU 温度信息 CPU 内置温度传感器作为 CPU 温度采集,可以很方便的获取 CPU 内部温度。 - //------直接查看温度值
- //---指令
- root@myir-yg2lx:~/zmj_ws/2_base_function/func_1_temp# cat /sys/class/thermal/thermal_zone0/temp
- 44500
- //---结果:44500 (单位:千分之一摄氏度)
- 这样可以监测到温度值为44500,即44.5摄氏度。
- (但是44500读起来仍旧不够直观,需要处理一下。)
复制代码
通过将读取的温度值进行浮点除法运算,即可将温度直观的转换为常用的摄氏度。 温度读取脚本“a_run_temp.sh” 内容如下: - #!/bin/bash
- # ------
- dividend=1000 ;
- while true
- do
- echo "***********************************"
- date
- # echo "Board_Temperature is :"
- # cat /sys/class/thermal/thermal_zone0/temp
- echo ""
- temp=/sys/class/thermal/thermal_zone0/temp ;
- divisor=$(cat $temp) ;
- echo "Board_Temperature is : $bd_temp"
- bd_temp= awk 'BEGIN{printf " %.4f ℃ \n",'$divisor' '/' '$dividend'}'
- sleep 1
- done
- # ------
- # cat /sys/class/thermal/thermal_zone0/temp
- # while true; do ./read_temp; sleep 1; done;
- # -----
- #while true
- #do
- #cat /sys/class/thermal/thermal_zone0/temp
- #sleep 1
- #done
- # -----
复制代码执行效果如图所示:
2. ADC功能MYD-YG2LX提供了1路12位、8通道的ADC(CPU内部集成),ADC支持的信号输入范围是0v~1.8v。 可以通过文件系统sysfs接口来实现ADC的测试。
MYD-YG2LX的ADC引脚定义:
测试结果如下: - root@myir-yg2lx:~# cd /sys/bus/iio/devices/iio\:device0/
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# ll
- total 0
- drwxr-xr-x 3 root root 0 Jan 1 00:00 ./
- drwxr-xr-x 4 root root 0 Jan 1 00:00 ../
- -r--r--r-- 1 root root 4096 Jan 1 00:32 dev
- -rw-r--r-- 1 root root 4096 Jan 1 00:32 in_voltage0_raw
- -rw-r--r-- 1 root root 4096 Jan 1 00:32 in_voltage1_raw
- -rw-r--r-- 1 root root 4096 Jan 1 00:32 in_voltage2_raw
- -rw-r--r-- 1 root root 4096 Jan 1 00:32 in_voltage3_raw
- -rw-r--r-- 1 root root 4096 Jan 1 00:32 in_voltage4_raw
- -rw-r--r-- 1 root root 4096 Jan 1 00:32 in_voltage5_raw
- -rw-r--r-- 1 root root 4096 Jan 1 00:11 in_voltage6_raw
- -rw-r--r-- 1 root root 4096 Jan 1 00:32 in_voltage7_raw
- -r--r--r-- 1 root root 4096 Jan 1 00:09 name
- lrwxrwxrwx 1 root root 0 Jan 1 00:32 of_node -> ../../../../../firmware/devicetree/base/soc/adc@10059000/
- drwxr-xr-x 2 root root 0 Jan 1 00:32 power/
- lrwxrwxrwx 1 root root 0 Jan 1 00:00 subsystem -> ../../../../../bus/iio/
- -rw-r--r-- 1 root root 4096 Jan 1 00:00 uevent
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# cat dev
- 247:0
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# cat name
- rzg2l-adc
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# cat uevent
- MAJOR=247
- MINOR=0
- DEVNAME=iio:device0
- DEVTYPE=iio_device
- OF_NAME=adc
- OF_FULLNAME=/soc/adc@10059000
- OF_COMPATIBLE_0=renesas,r9a07g044-adc
- OF_COMPATIBLE_1=renesas,rzg2l-adc
- OF_COMPATIBLE_N=2
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
- 2723
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# cat /sys/bus/iio/devices/iio\:device0/in_voltage1_raw
- 1360
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# cat /sys/bus/iio/devices/iio\:device0/in_voltage2_raw
- 2743
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# cat /sys/bus/iio/devices/iio\:device0/in_voltage3_raw
- 1357
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# cat /sys/bus/iio/devices/iio\:device0/in_voltage4_raw
- 1742
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# cat /sys/bus/iio/devices/iio\:device0/in_voltage5_raw
- 1846
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# cat /sys/bus/iio/devices/iio\:device0/in_voltage6_raw
- 1498
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0# cat /sys/bus/iio/devices/iio\:device0/in_voltage7_raw
- 2185
- root@myir-yg2lx:/sys/bus/iio/devices/iio:device0#
复制代码
//------end
|