Page 1 of 1
Usage of SARADC
Posted: 2024-10-24 20:03
by 14Og
Hello! Im curious about using SARADC channels at my pico-mini B board. I see that there is two of them in pinout diagram, but i found only one channel entry inside device tree. There is no option for SARADC in luckfox-config application, so i don't really understand, whether it's possible to use those adc's and if yes, is there any piece of code that shows how to do that? Thanks in advance!
Re: Usage of SARADC
Posted: 2024-10-25 1:51
by Alenwowo
14Og wrote: ↑2024-10-24 20:03
Hello! Im curious about using SARADC channels at my pico-mini B board. I see that there is two of them in pinout diagram, but i found only one channel entry inside device tree. There is no option for SARADC in luckfox-config application, so i don't really understand, whether it's possible to use those adc's and if yes, is there any piece of code that shows how to do that? Thanks in advance!
Hello, you can try this article:
https://wiki.luckfox.com/zh/Luckfox-Pic ... x-Pico-ADC. Generally, once iio is registered it is generated in the directory /sys/bus/iio/ devices/iio:device0, you can use it directly, you don't need to open it in lukfox-config.
Re: Usage of SARADC
Posted: 2024-10-26 16:19
by 14Og
Thank you very much, sorry that i didn't notice this article in your wiki, it's probably bc it's a new one. Thanks again!
Re: Usage of SARADC
Posted: 2024-10-28 1:48
by Alenwowo
14Og wrote: ↑2024-10-26 16:19
Thank you very much, sorry that i didn't notice this article in your wiki, it's probably bc it's a new one. Thanks again!
ok
Re: Usage of SARADC
Posted: 2024-10-30 11:46
by 14Og
It's working fine for me, but i'm little confused as i found out that saradc0 actually shares the same pin with boot button. This button makes no sense after linux boot in spi-nand image, but it reboots the board in sd card image. So im wondering, if it is possible to remap this functionality at another GPIO pin? I understand that boot button is responsible for bootrom fallback, but it's okay for me to have it on another pin, as i can attach another button to the board (if it's configurable for bootrom tho). The general question is: is it possible to change this boot pin location to make all adc channels free for measurements and what should i change in device tree of my board to achieve this.
UPD: so i found device-tree entry named "restart-poweroff" in my board's decompiled device-tree:
Code: Select all
/ {
adc-keys {
compatible = "adc-keys";
io-channels = <&saradc 0>;
io-channel-names = "buttons";
poll-interval = <100>;
keyup-threshold-microvolt = <1800000>;
key_volumeup-key {
label = "key_volumeup";
linux,code = <KEY_VOLUMEUP>;
press-threshold-microvolt = <0>;
};
key_volumedown-key {
label = "key_volumedown";
linux,code = <KEY_VOLUMEDOWN>;
press-threshold-microvolt = <400781>;
};
};
restart-poweroff {
compatible = "restart-poweroff";
};
};
This restart-poweroff entry is connected with POWER_RESET_RESTART driver. But the issue is that i dont understand any connection between this driver and saradc, as restart-poweroff entry is almost empty. It's located under adc-keys entry which is related to saradc0, but idk about meaning of it, sorry. One more confusing thing is that this driver is also enabled in spi-nand image, and this restart-poweroff entry is also present there, but button does not do anything there, which is weird.
I hope you'll help me get along with this confusing situation, thank you!
Re: Usage of SARADC
Posted: 2024-10-31 2:04
by Crocodile
Hello, the BOOT pin on luckfox-pico only acts as a simple input device after entering the kernel. Its function of entering Maskrom mode is enabled in uboot. I tried to use the latest spi-nand image and SD card image. Even pressing the BOOT button will not trigger it to restart. Although the "restart-poweroff" node and the adc-key node are both on the root node, they are not connected.
The only pin that can restart the system is NOR (not available on the RV1103. The RESET of the RV1106 series uses the changed pin to restart). There are two possibilities for restarting it:
1. When the button is pressed, the main chip power supply (1.8V 3.3V) is short-circuited, causing the system to restart. This may cause device damage.
2. The device is short-circuited, causing the data lines of SARADC0 and the SD card to be connected together. When the button is pressed, the SD card data line is always pulled low. The system cannot operate normally, causing a restart.
Re: Usage of SARADC
Posted: 2024-10-31 12:26
by 14Og
Ok, so what i did is i've created new image for sd card and this behaviour disappeared. Idk why it used to be like that in my older image, but now it seems fine. So the only problem now is that i need to remap this pin that causes u-boot to jump back to maskrom and enter boot mode. If i want to use another gpio pin that is not used in my project, what should i change in u-boot config? Thanks