kendryte / kendryte-standalone-sdk

Standalone SDK for kendryte K210
https://kendryte.com
Apache License 2.0
440 stars 161 forks source link

sysctl_set_power_mode does not set power mode #116

Open ThomasDebrunner opened 3 years ago

ThomasDebrunner commented 3 years ago

BUG REPORT

Power banks stay at the same voltage level, no matter what is set with sysctl_set_power_mode. For example, power bank 6 always stays at 1.8V, power bank 2 always at 3.3V

Expected behavior

High-state voltage of the GPIO outputs are the value set with sysctl_set_power_mode.

Actual behavior

High state voltages seem unaffected by sysctl_set_power_mode.

Test code

    sysctl_set_power_mode(SYSCTL_POWER_BANK2, SYSCTL_POWER_V18);

    fpioa_set_function(16, FUNC_GPIOHS16);
    gpiohs_set_drive_mode(16, GPIO_DM_OUTPUT);
    gpiohs_set_pin(16, GPIO_PV_HIGH);

Then use a multimeter and check voltage of pin 16. Pin 16 is at 3.3V. This is wrong. Should be at 1.8V.

    sysctl_set_power_mode(SYSCTL_POWER_BANK6, SYSCTL_POWER_V33);

    fpioa_set_function(36, FUNC_GPIOHS30);
    gpiohs_set_drive_mode(30, GPIO_DM_OUTPUT);
    gpiohs_set_pin(30, GPIO_PV_HIGH);

Then use a multimeter and check voltage of pin 36. It is 1.8V. This is wrong, should be at 3.3V.

Document version

Tag 0.5.6

Hardware

Maix Dock with M1 module

System

PlatformIO on macOS

cmdrf commented 3 years ago

It seems the meanings of SYSCTL_POWER_V33 and SYSCTL_POWER_V18 are reversed. If you set SYSCTL_POWER_V18, you get 3.3V, and if you set SYSCTL_POWER_V33, you get 1.8V.

EDIT: Forget it, my circuit just worked sporadically when fiddling around. sysctl_set_power_mode really doesn't do anything.

cmdrf commented 3 years ago

I investigated a bit further and I'm pretty sure the I/O voltage is not field-programmable. You "choose" the I/O voltage by supplying the desired voltage to the corresponding VCC pins. Example of a Sipeed board, where you can place 0 Ohm resistors to choose the voltage: image

Then you use sysctl_set_power_mode to tell the chip which voltage you are supplying, for whatever reason.