Hello
I am willing to put my device into extended sleep thanks to idle task of free_rtos. Up to now I am facing some issues.
My code is based on sample code from Dialog. The system is booting, freertos is starting, tasks are being loaded properly.
I am running a loop in the main task where I do blink a led to check that the system is alive and execute a 1 sec sleep.
I can trace the system until WFI is being executed properly. At that time breath timer is switched-off and led shut down.
At the exit of the WFI, breath timer does not wake-up.
Currently breath_config breath_cfg, hw_led_set_ledX_src(...), hw_breath_init(&breath_cfg); and hw_breath_enable(); are all located in prvSetupHardware. If I do put any of these in periph_init, no led light up at all even in active or idle mode.
Can you confirm to me
- what is the init sequence for breath timer ?
- that Breath timer registers are retained during sleep ?
- that Breath timer state and dependencies are being managed by current firmware ?
What are the steps to debug such case ?
Thank you in advance
Best Regards
Hi,
May I know which sample code is your code based on, and what's your modifications? Is the function you are implementing for making an automated breathing function for an external LED?
For breathing function of LED, below code shows a example:
breath_config config = {
.dc_min = dc_min,
.dc_max = dc_max,
.dc_step = dc_step,
.freq_div = freq_div,
.polarity = HW_BREATH_PWM_POL_POS
};
/*
* Setup breath timer configuration, so hardware can drive LED automatically.
*/
hw_breath_init(&config);
/*
* Setup LED1 output to be driven by timer.
*/
hw_led_set_led1_src(HW_LED_SRC1_BREATH);
hw_led_enable_led1(true);
/*
* Then start breath timer.
*/
hw_breath_enable();
More details could be found in the peripherals_demo of the SDK.
Hello
My code is based on freertos_retarget source code.
I am using exactly what you gave me
static void prvSetupHardware(void)
{
// Activate Interrupts
....
breath_config breath_cfg = {
.dc_min = 9, // light power - 1
.dc_max = 10, // light power is set to 10/255
.dc_step = 255,
.freq_div = 255,
.polarity = HW_BREATH_PWM_POL_POS
};
/* Init hardware (OTPC, Cache, ADC, DCDC, USB Pads, RF, adapters, buses, devices, watchdog) */
pm_system_init(periph_init);
// Init Interrupt Controller
hw_wkup_init(&wkup_cfg);
// configure LED1, Red
hw_led_set_led1_src(HW_LED_SRC1_BREATH);
hw_led_enable_led1(false);
// configure LED2, Green
hw_led_set_led2_src(HW_LED_SRC2_BREATH);
hw_led_enable_led2(true);
// configure LED3, Blue
hw_led_set_led3_src(HW_LED_SRC3_BREATH);
hw_led_enable_led3(false);
// configure Breath Timer required for RGB Led
hw_breath_init(&breath_cfg);
hw_breath_enable();
}
If I do put the previous code in periph_init, no led is light up.
起床后extended_sleep远离。
Thank you in advance
It seems deeper trouble than the LED.
Before sleep : 0x50000066=0x3 after WFI and after pm_system_wake_up 0x50000066=0x2.
Datasheet point out secure boot (I am testing production mode with watchdog in use but with no secure boot yet).
Other Hint 0x500030D0=0 before sleep, 0x500030D0=1 after sleep. It seems that this feature is not restored properly after wake-up.
Next Hint is 0x50000022 = 0x54B7 before sleep, 0x54B6 after sleep. The RC16 is stopped during extended sleep and not started again after it. DCDC relying on it is killed during the operation. (0x5000002A = 0x20D2 after sleep : 1V8 and 1V8P down)
I tried to put the system in dg_configUSE_DCDC = 0 to stop using DCDC.
As a result 0x50000022 = 0xE7D3 before and after sleep. I have no more crashes after sleep.
But I still have no LED
New Hint. LED_CONTROL_REG is being erased by sys_tcs. If y do set my led sources in periph_init, they are then erased by sys_tcs at boot and at wake-up.
I am not using OTP, why would this register be the only one set by sys_tcs at these 2 moments ?
While looking at Appendix H of UM-B-044, it seems that the LED_CONTROL_REG is being used during production.
Can you please check this on freertos_retarget sample code running on a DA14683 ?
Up to now I can not use sleep mode. Energy is critical for my product.
Thank you
Hi Bob,
Can you please try to implement it in any of BLE examples of the SDK which are using sleep mode? How you are testing that the device fails to sleep? Also, which are your configurations in periph_init?
Thanks, PM_Dialog
Hello
I did not had time yet to use ble with my prototype. The BSP is quite big now so this integration has been moved away because bluetooth is not in our Minimum Viable Product.
periph_init currently only have GPIOs IN/OUT configuration, GPIO high/low for some OUT that are fixed during execution and now breath timer init.
I managed to get extended sleep working:
- by disabling the DCDC
--> can you confirm to me why RC16 is stopped during sleep and not restarted ?
- by removing sys_tcs from the power management.
--> can you confirm to me how to have it stop reloading LED_CONTROL_REG from OTP with a reset value (0x80) ? (DA14683 on a custom board, OTP never used)
- by moving breath timer init / config in periph_init
--> LED are shut-down during sleep. As a result I can only use LED during execution time.
- by using a simple loop in the main task
If I do load more code than the main loop I do get various crashes / troubles:
- If I use hw_i2c
--> hard fault. (I need to move to ad_i2c to have it reload controler status after wake-up).
- If the UART receives data while the CPU is about to sleep or is sleeping (I think external modem sends clock update)
--> break in the UART Interrupt handler located in case HW_UART_INT_BUSY_DETECTED. I can see comment related to RBR_THR_DLL in the code. If you have any idea here, I would be pleased.
- the UART misses some communications with the external modem so my app does not behave properly.
--> I do need hardware flow control here but my hardware is not OK with it. If you have a reference implementation of asynchronous communication using hardware flow control over UART, I would be pleased. I am currently polling ad_uart_read in a thread to wait for data when communicating with external modem but it seems it misses some bytes.
Probably more troubles are to come with the sleep feature. Up to now I cannot use it in a reliable way.
Thank you in advance
Hello
I moved my code from hw_i2c to ad_i2c. I have no more issues on this side.
On the UART side,
- I disabled level shifters that serve my external modem during the sleep period so I have no message coming in during sleep. This does not change anything.
- I used a JTAG probe to check the context of that break. It seems that the issue is related to uart console because my code does not use async communication so no IRQ is generated on the UART I use to communicate with my external modem. The only IRQ I get are from console service.
Can you please address the following ?
- RC16 / DCDC shutdown after wake-up
- sys_tcs reloading values from OTP while no OTP is used
- console service interrupt ending in __BRK
Thank you in advance
Hi Bob,
Sorry but I am little bit confused. I would strongly recommend you to NOT modify the SDK files. The hw_i2c is the Low Level Driver (LLD) and the ad_i2c is the adapter of I2C. I would highly recommend the usage of the adapters e recommend the usage of the adapters for accessing hardware peripherals because not only provide access to the peripheral, but also make sure that other tasks which are currently accessing it, suspend their operation until the peripheral is once again released. So you don't have to worry if another task tries accessing the same peripheral at the same time. Also, in sleep mode all the peripheral blocks are powered down.
Thanks, PM_Dialog
Hello
Can you please have a look at the following ?
1. console service generating uart interrupt ending in __BRK. This issue happens as soon as I do activate extended sleep.
Hardfault Analysis:
- LR指向UART_Interrupt_Handler (HW_UART1) which is used for console service.
- PC point to CONFIG_UART_IGNORE_BUSY_DETECT case in void UART_Interrupt_Handler(HW_UART_ID uart)
I tried using no dma config for uart. no change.
2. sys_tcs reloading values from OTP while no OTP is used. This issue is to be solved to avoid modifying BSP files.
- See my previous analysis. I could figure out using a JTAG probe that LED_CONTROL_REG is the only register reloaded by sys_tcs_apply(tcs_system); functions. Reloaded value is 0x80. It clear retained state of my leds.
3. RC16 / DCDC shutdown after wake-up. LDOs can do the job until extended sleep can be used with DCDC enabled.
Here I only see that before / after sleep the RC16 bit goes to zero and never goes back to 1. In DS v3.1 spec, chapter 6, DCDC is relying on RC16 so it can't be alive after wake-up.
Thank you in advance
Hello
New hard fault: I get a new one in ad_gpadc_read() after sleep occured. I checked the GPADC registers and they are in reset state.
Can you confirm that
- all adapters have been tested after sleep mode ?
- I can have adapter "open" function in constructors ?
- I do not need to call "open" again during normal operations. (this include after wake-up) ?
Thank you in advance
Hi bob,
I am really confused for the changes that you have done.
My recommendation would be to readUM-B-044: DA1468x Software Platform ReferenceandUM-B-056: DA1468x Software Developer's Guidein order to understand the SDK architecture. You can also find “Adapter” example in the “Tutorial” section in DA1468x support portal.
Thanks, PM_Dialog
Hello
Can you launch freertos_retaget, light up a led and activate extended_sleep on a DA14683 (with printf/console redirected to a uart, dcdc and dma enabled) ?
- what is the value of LED_CONTROL_REG before sleep ? after ?
- what is the value of RC16 enable bit before sleep ? after ? is the DCDC still alive ?
Thank you for your advice of reading the manual but it looks like bugs in the SDK and I would be pleased that you check it on your side. I am getting hard faults from the board support package.
Thank you
Hello
Good news. I finally managed to get the sleep feature working without crash.
I was hitting the BOD of 3.3V because of power failure while on the retention LDO.
Things are OK after activating the Flash 1V8 switch off feature thus unloading the 3V3 RET LDO.
英航d news n°1. The system stop sleeping after several minutes. No identified fault yet.
英航d news n°2. I am still hitting the BOD of 3V3 if I do enable external peripherals.
Do you know what is the power budget for 3.3V RET LDO while in extended sleep (please don't answer 10mA there are lot of stuff attached to it) ?
I have 1.2mA on 1V8P and 300µA on 3V3 theoretical absolute maximum but when sleep is enabled I do hit BOD and end up with a Power-On reset.
Thank you
Hello
I finally managed to solve last issues
- I had to manually drive the switch to extended_sleep at a moment where I know nothing is happening on the system (and on the console !). I also had to manage a manual switch to idle mode to avoid small sleeps during normal operations (like sleeping while waiting for an adapter event).
- I had to raise up capacitors on VBAT up to 20µF to avoid BOD on 3V3 (current peak at wake-up that made the VBAT fall down).
——我的一个外部周边消耗8马on 1V8P while being in full shut-down mode. Not good with a 10mA budget ! I had to reset it after operations to make it consumes less while sleeping.
- The system was not waking-up sleeping tasks without pm_set_wakeup_mode(true) activated. Without it I ended stuck after sleep with a system stable but doing nothing.
At the end of that journey the sleeping mode seems to be working but
- I am not anymore reloading OTP values from the power manager because of sys_tcs_apply(tcs_system); reloading LED_CONTROL_REG after periph_init execution.
I am asking again for help at least on the OTP issue so I can release a version without modifying boad support package files.
Thank you