This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

System initialize sequence & I2C blocked

The original order of my system initialize step is:

/*******************************************

1.nrf_drv_power_init()

2.APP_SCHED_INIT()

3.app_timer_init()

4.APP_GPIOTE_INIT()

5.NVIC_SetPriority()

6.nrf_drv_twi_init() + nrf_drv_twi_enable()

7.nrf_drv_clock_init()

8.nrf_drv_clock_lfclk_request()

9.I2C_device_init()

*********************************************/

One day, I saw a document mentioned that clock init should be before APP_SCHED_INIT(),

so I rearrange the order to be 1-7-8-2-3-4-5-6-9.

After that, it cause following issue.

My device can't complete boot once about 10 to 20 times start-up,

It will be blocked in step 9 which I2C first time transfer data.

When it happened, It can't be recover even I update back to the original sequence image by bootloader.

Measuring I2C signal by scope, data pin(SDA) is pull-up initial by HW but is set and keep to be low during boot.

and clock pin (SCL) is always pull high by HW, no any clock generate.

After experiment, there are three method to recover,

One way is remove voltage source(battery).

Seconed method is update a image which SCL/SDA is set to be output pins before TWI initial.

The last method is measure voltage of SCL pin by multimeter. It continue and complete boot immediately once I touch SCL pin by multimeter's probe.

What could be the root cause about the issue? And what is the correct initialize sequence should be?

*SDK14.2

Parents Reply Children
No Data
Related