1514 views|0 replies

38

Posts

0

Resources
The OP
 

[Sipeed LicheeRV 86 Panel Review] II. GPIO pins are brought out, RGB tri-color LED flashes [Copy link]

 This post was last edited by zhang1gong on 2022-3-15 11:28

1. The core board LED lights up

The LicheeRV tutorial provides a tutorial on lighting up the LED on the core board. Lighting up or flashing an LED is often the first test program to run in an embedded system widely used in automatic control, just like the first program to run when learning a programming language on a desktop system: "Hello, world!" This is the first time I have run a lighting program under the Linux system, and it feels completely different from programming in C or assembly on a bare metal machine: basically, I don't have to worry about the hardware, it's all about file operations, which fully reflects the Linux system's "everything is a file" concept.
The GPIO port (PC1) that drives the LED on the core board conflicts with other applications on the baseboard, so the core board must be removed from the baseboard to do this lighting test. However, the USB port on the core board does not have the function of simulating a serial port, and the tutorial does not seem to clearly explain this. Several testers who have already done this experiment mentioned that ADB must be used. Although I will probably install ADB in my desktop system sooner or later to build a cross-compilation environment, I still want to see if there are other ways.
After removing the core board from the baseboard, I found that there were 4 reserved pads next to the USB port. The back of the PCB board was marked with "TRG 5V" next to the pads, which made me wonder: Is this a serial port? I checked the schematic diagram and it was true! I happened to have more than one serial port to USB board (a few dollars each on Taobao, including free shipping), so why not use this serial port? Suddenly I remembered that there was a small pocket in the development kit with a 4-pin pin, which should be used for this. I successfully soldered the 4-pin pin, but immediately found that if the core board was inserted back into the baseboard, because there was a reset button on the baseboard under the serial port pin, the soldered pin needed to be trimmed, otherwise the soldered end of the pin would hit the reset button. The soldering and trimming process is actually very simple, but I almost capsized in the gutter. After experiencing the process of the core board not working and finally recovering (the specific capsizing scene and 200 words of the recovery process are omitted here), it was finally safe!

Through the serial port on the core board, the small board converts it into USB and connects it to the simulated terminal of the desktop system. Follow the command line instructions given in the tutorial one by one, and the lighting process goes smoothly. (There is a small mistake in the command line instructions given in the tutorial: "cd /sys/class/gpio/export/gpio65")

2 pin extension, RGB tri-color LED flashing

The expansion pin area reserved on the baseboard gives people endless reverie. I always feel that if they are not brought out, it seems to be a betrayal of the designer's original intention. The main obstacle to bringing out the pins is the need to separate the display screen from the baseboard. Separation itself is not difficult, but the difficult part is to make up your mind to do such a destructive thing (I implore the manufacturer to solder the double-row sockets when leaving the factory). Use a blade to separate the connection between the display screen and the baseboard, carefully solder the sockets on the baseboard, and you can easily connect the expansion pins with Dupont wires.

According to the number of the expansion pins on the baseboard, refer to the schematic diagram, and select B2, B3, and B4 from the pins that are not occupied to drive the R, G, and B in the three-color LEB respectively.

"cat /sys/kernel/debug/pinctrl/2000000.pinctrl/pinmux-pins"

Command to query the digital number corresponding to the pin number:

Then I wrote two scripts according to the tutorial and put them in the "/mnt/SDCARD" directory so that the files will not be lost when the power is turned off:


# rgb_config.sh

echo 34 > /sys/class/gpio/export
echo 35 > /sys/class/gpio/export
echo 36 > /sys/class/gpio/export

cd /sys/class/gpio/gpio34
echo out>direction
cd /sys/class/gpio/gpio35
echo out>direction
cd /sys/class/gpio/gpio36
echo out>direction


# rgb_blink.sh

for a in $(seq 1 5)
do
cd /sys/class/gpio/gpio34
echo 1 > value
sleep 0.5
cd /sys/class/gpio/gpio35
echo 1 > value
sleep 0.5
cd /sys/class/gpio/gpio36
echo 1 > value
sleep 1

cd /sys/class/gpio/gpio34
echo 0 > value
sleep 0.5
cd /sys/class/gpio/gpio35
echo 0 > value
sleep 0.5
cd /sys/class/gpio/gpio36
echo 0 > value
sleep 1

done


The script "rgb_config.sh" is used to initialize the pins, and "rgb_blink.sh" controls the blinking of the tri-color LED.

In the Linux system, everything is a file, and you need to further understand it.

This post is from Domestic Chip Exchange
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

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