Rebooting the system through the watchdog,I2C does not work at sometimes.

6 posts / 0 new
Last post
lizhuobin
Offline
Last seen:3 months 1 week ago
Joined:2014-08-15 05:08
Rebooting the system through the watchdog,I2C does not work at sometimes.

I do an experiment as follow.

Reboot the system by using the watchdog,

and then the I2C does not work at sometimes,

example

void i2c_write_byte(uint8_t wr_data)
{
WAIT_WHILE_I2C_FIFO_IS_FULL(); // Wait if I2C Tx FIFO is full
SEND_I2C_COMMAND(wr_data & 0xFF); // Send write data
WAIT_UNTIL_I2C_FIFO_IS_EMPTY(); // Wait until Tx FIFO is empty

WAIT_UNTIL_NO_MASTER_ACTIVITY(); // wait until no master activity
}

我想发送一个时代e, but it wait at WAIT_UNTIL_I2C_FIFO_IS_EMPTY(),

the fifo can not be empty, I check the I2C_STATUS_REG value, and the value is still 0x2,

if I poweroff and poweron the chip, it will run very well.

How to fix this issue.

WT_Dialog (not verified)
Hi LIzhuobin,

Hi LIzhuobin,

Sorry that I may missed the point, are you saying that the watch dog does not work?

BR

WT_Dialog

lizhuobin
Offline
Last seen:3 months 1 week ago
Joined:2014-08-15 05:08
HI WT_Dialog,

HI WT_Dialog,

watch dog work,
but sometimes I2C does not work after the system restart by the watch dog.

Best Regards,

muxf
Offline
Last seen:3 years 2 months ago
Joined:2016-07-25 09:15
Hi WT_Dialog,

Hi WT_Dialog,

I have also the similar problem in SDK 5.0.4:
I am interfacing DA14580 to a temperature sensor through I2C. Based on the example
peripheral_examples\i2c\i2c_eeprom
I can read/write temperature from/to the sensor. But if I ported it into the example
ble_examples\ble_app_peripheral
then it stuck at WAIT_UNTIL_I2C_FIFO_IS_EMPTY() and then goes into NMI_HandlerC() which indicates watchDog is activated.

I do the i2c initialization in the file custs1_task.c
custs1_create_db_req_handler()
{
...
if (status == ATT_ERR_NO_ERROR)
{
i2c_eeprom_init(I2C_SLAVE_ADDRESS, I2C_SPEED_MODE, I2C_ADDRESS_MODE, I2C_ADDRESS_SIZE);
}
...
}

I do the i2c R/W in the callback function for app_on_system_powered:
i2c_error_code code = i2c_eeprom_write_byte(32, 2);
...

为什么它在i2c eepm没问题,但不是在体育吗ripheral example? In the i2c eeprom example, I just put the initialization call out of the while(1) loop
It will be nice if you can help me as soon as possible, because next week I should demonstrate my peripheral application to our customer. Thanks

muxf

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
Joined:2015-06-08 11:34
Hi muxf,

Hi muxf,

I would suggest to make the initialization of the i2c module not when creating the database but whenever you would like to interface with data or in the user_app_init although this doens't affect the behaviour that you are experiencing. The fact that you stuck on that #define means that your FIFO has data and the program waits until that data are sent therefore either the data are not send at all (the i2c device is nor ready for some reason and doesn't ack the data send by the 580) or the watchdog hits before all the data from the FIFO are sent. You can try to disable the watchdog by undefining the CFG_WDOG in the da1458x_config_basic.h or try increase the time period of the watchdog by changing the WATCHDOG_DEFAULT_PERIOD to a larger value. If your code stucks in that while forever means that there is something wrong with the communication with the temperature device. Perhaps in the peripheral examples the code probes repeatedly the temperature sensor before actual data are sent but something like that doesn't affect the peripheral examples since there is no watchdog implementation.

Thanks MT_dialog

muxf
Offline
Last seen:3 years 2 months ago
Joined:2016-07-25 09:15
Hi MT_dialog,

Hi MT_dialog,

thank you very much for the support. It works now.

I tried to disable the WDOG, but the same results. You are right, it must be something wrong with the communication. I then compare the ble_peripheral with eeprom example line by line, and find out that in the ble_peripheral example there is no port and pin reservation and definition for I2C! Sorry, I am newcomer in Dialog BLE, so I am not familiar with Dialog software architecture. I thought in peripheral example all the peripherals should already be defined.

I then add such reservations and definitions for i2c, but no any changes on the results. the application always goes into NMI_HandlerC(). And I also have the feeling that sometimes it works for quite short time interval. For that I decided to check my hardware completely again. I then relocate my sensor very tight to Dialog 14580, and make the SCL and SDA cables as short as possible. Finally it works also in the ble_peripheral example, I get stable sensor data delivered from sensor!

My experience is, for such stuck at WAIT_WHILE_I2C_FIFO_IS_FULL(), one should firstly check
1. Port reservation and definition
2. Hardware connection between sensor and DA14580

thanks again.

muxf