rtlduino / RTL8710AF_GCC

Linux RTL8710AF below the GCC version, you can Ubuntu, CentOS, Fedora and so on the development of the SDK environment, support the compiler, debugging, running.
37 stars 19 forks source link

PWM does not work - Runtime Error: [PWM Err]pwmout_init Err! #2

Open kissste opened 7 years ago

kissste commented 7 years ago

RTLDUINO_RTL8710AF_GCC/project/realtek_ameba1_va0_example/example_sources/pwm/src/main.c

does not work on RTL8710.

I'm getting: [PWM Err]pwmout_init Err! [PWM Err]pwmout_init Err! [PWM Err]pwmout_init Err! [PWM Err]pwmout_init Err!

Must be from this loop: for (i=0; i<4; i++) { pwmout_init(&pwm_led[i], pwm_led_pin[i]); pwmout_period_us(&pwm_led[i], PWM_PERIOD); }

I wonder whether RTL8710 even supports PWM (on these pins, PC_0,1,2 and 3)

Deeper:

obj->pwm_idx = pwm_idx;
obj->pin_sel = pin_sel;
obj->period = 0;
obj->pulse = 0;
_memset((void *)&obj->pwm_hal_adp, 0, sizeof(HAL_PWM_ADAPTER));
if (HAL_OK != HAL_Pwm_Init(&obj->pwm_hal_adp, pwm_idx, pin_sel)) {
    DBG_PWM_ERR("pwmout_init Err!\n");
    return;
}

It might be a mbed/HAL integration issue.

kissste commented 7 years ago

Debugging:

It's somewhere inside hal_pinmux.c

unfortunately, no source code.

It appears to be checking something in the RAM in HALEFUSEOneByteReadRAM

unfortunately, no source code.

Dead-end

gbd: 51 if (_FALSE == FunctionChk((pPwmAdapt->pwm_id+PWM0), pPwmAdapt->sel)) { (gdb) s FunctionChk (Function=Function@entry=162, PinLocation=PinLocation@entry=1) at ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c:164 164 ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c: No such file or directory. (gdb) l 159 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c (gdb) l 159 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c (gdb) s 162 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c (gdb) s 164 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c (gdb) s HALEFUSEOneByteReadRAM (CtrlSetting=3492870396, Addr=Addr@entry=248, Data=Data@entry="", L25OutVoltage=L25OutVoltage@entry=7 '\a') at ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_efuse.c:286 286 ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_efuse.c: No such file or directory. (gdb) s 290 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_efuse.c (gdb) s 294 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_efuse.c (gdb) s FunctionChk (Function=Function@entry=162, PinLocation=PinLocation@entry=1) at ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c:168 168 ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c: No such file or directory. (gdb) s 185 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c (gdb) s FunctionChk (Function=162, PinLocation=1) at ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c:168 168 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c (gdb) s RTL8710afFunChk (Function=Function@entry=162, PinLocation=PinLocation@entry=1) at ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c:95 95 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c (gdb) s 153 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c (gdb) s 156 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c (gdb) s HAL_Pwm_Init (pPwmAdapt=pPwmAdapt@entry=, pwm_id=pwm_id@entry=2, sel=sel@entry=1) at ../../../component/soc/realtek/8195a/fwlib/src/hal_pwm.c:52 52 return HAL_ERR_HW;

kissste commented 7 years ago

I have managed to get PWM working by disabling the following check that is in the SDK:

./component/soc/realtek/8195a/fwlib/src/hal_pwm.c

if (_FALSE == FunctionChk((pPwmAdapt->pwm_id+PWM0), pPwmAdapt->sel)) { //return HAL_ERR_HW; }

This FunctionChk goes somewhere in the RAM and then determines that there is on PWM available. 164 in ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_pinmux.c calls HALEFUSEOneByteReadRAM (CtrlSetting=3492870396, Addr=Addr@entry=248, Data=Data@entry="", L25OutVoltage=L25OutVoltage@entry=7 '\a') at ../../../component/soc/realtek/8195a/fwlib/ram_lib/hal_efuse.c:286

Once you disable this check, the PWM works like a charm.