Closed freetoair closed 2 years ago
Solved. If you need an infinite loop in the ULP program at the beginning of the program add: I_WR_REG_BIT (RTC_CNTL_STATE0_REG, RTC_CNTL_ULP_CP_SLP_TIMER_EN, 0)
and so you forbade the influence of the start timer on the flow of the program!
Hi @freetoair,
The problem might be here: I_BXI(LBL_LOOP)
That inadvertently means jump to PC 1, causing I_STAGE_RST()
to be skipped.
Use M_BX
with labels: M_BX(LBL_LOOP)
I_WR_REG_BIT (RTC_CNTL_STATE0_REG, RTC_CNTL_ULP_CP_SLP_TIMER_EN, 0)
This doesn't look right, the macro expects the shift (RTC_CNTL_ULP_CP_SLP_TIMER_EN_S), not a mask.
In practice, RTC_CNTL_ULP_CP_SLP_TIMER_EN == BIT(24) which is probably going to be truncated to 0, so the instruction means to clear bit 0.
I suggest using I_END()
instead, although the ULP sleep timer is irrelevant in an infinite loop.
It's okay now, thanks for the analysis. When I replaced I_BXI with M_BX it works normally and without I_END. The sampling frequency is a maximum 12.75 kHz which is more than enough.
regards.
Hi @boarchuz, I forgot to congratulate you on a great job with this library. I would have one suggestion if it is possible to add a macro that would simulate PUSH and POP commands for any form of stack work. I know that in this case it would not be the right PUSH and POP commands in terms of speed, but it would help make the program easier to follow and understand.
regards.
This is my simple program in the infinite loop that only measures the voltage from the mains and saves the value in the variable ulp_vars.pin2.val. The problem is that at some undefined intervals but certainly under one second this variable gets a value as if the shift command had not been executed. This is a simplified example from the HULP library, and in that original example, I didn't notice anything like this happening. Does anyone have any idea why this is happening?