- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
1. In main.c
----
timer_start (0, VBUS_MONITOR_TIMER_ID, VBUS_MONITOR_TIMER_PERIOD, vbus_monitor_timer_cb);
while (1)
{
...
}
----
2. soft timer callback below in main.c as well
----
void vbus_monitor_timer_cb (
uint8_t port,
timer_id_t id)
{
(void)port;
(void)id;
I2CM_I2CMasterWriteBuf(....)
timer_start (0, VBUS_MONITOR_TIMER_ID, VBUS_MONITOR_TIMER_PERIOD, vbus_monitor_timer_cb);
}
--
add I2C write in soft timer callback, but occurring reboot.
My question is can not use the I2C master write in soft timer callback?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you please mention the exact return code I2CM_I2CMasterStatus() is returning when its struck in while loop?
Can you also try disabling the watchdog timer reset in config.h
/* Enable watchdog hardware reset for CPU lock-up recovery */
#define WATCHDOG_HARDWARE_RESET_ENABLE (0u)
/* Disable CCG device reset on error (watchdog expiry or hard fault). */
#define RESET_ON_ERROR_ENABLE (0u)
Above are the 2 Macros in config.h you need to disable.
Also instead of Buffer based APIs you can try using (throughout the project) byte level APIs. You can refer to Component datasheet for example implementation.
Regards,
Pranava
Pranava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Using I2C write inside a timer callback should not be an issue.
Can you please confirm whether the VBUS_MONITOR_TIMER_ID you have defined lies within 0xE0 to 0xFF.
Regards,
Pranava
Pranava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think the root cause is that I add a "while loop" code after I2CM_I2CMasterWriteBuf, so the Watch dog timer trigger the reboot?
--
I2CM_I2CMasterWriteBuf(....)
while (0u == (I2CM_I2CMasterStatus() & I2CM_I2C_MSTAT_WR_CMPLT))
{
/* Waits until master completes write transfer */
}
--
Any way to avoid the reboot? Please advise, thanks
Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you please use below code so that we can confirm I2CMasterWriteBuf() function is successful and the code is not stuck in "while loop" triggering reset,
if(I2CM_I2C_MSTR_NO_ERROR == I2CM_I2CMasterWriteBuf(....))
{
while (0u == (I2CM_I2CMasterStatus() & I2CM_I2C_MSTAT_WR_CMPLT))
{
/* Wait */
}
}
Regards,
Pranava
Pranava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Pranava,
Thanks for your help
I2CMasterWriteBuf() function is successful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Then will enter the while(1) check. The reboot problem was still occurring. Please kindly help with looking into it.
Thanks.
Best Regards
Huang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Looks like the I2C write is not getting completed successfully, can you please confirm if the slave device is ACKing the transfers?
Can you please provide logic analyzer traces of I2C lines?
Regards,
Pranava
Pranava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Thanks your help.
I Upload the code on Google drive: https://drive.google.com/file/d/1sjhMeJPofRGiAFgK4ndHmi0WjQZQyAAw/view?usp=sharing
1.
and if has line:519 in main.c while (0u == (I2CM_I2CMasterStatus() & I2CM_I2C_MSTAT_WR_CMPLT))
the waveform below, the CYPD3171 Reboot
2. if I only mark line:519 //while (0u == (I2CM_I2CMasterStatus() & I2CM_I2C_MSTAT_WR_CMPLT))
The CYPD3171 will not reboot, but the i2c reg_address and date is wrong. Becasue I set the uint8_t buffer[2]={0x05,0x14}; at line 515.
Please help to look into it.
Thanks
Best Regards
Huang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you please add
(void) I2CM_I2CMasterClearStatus(); before I2CM_I2CMasterWriteBuf() call.
if you still receive errors in data, you can add
I2CM_I2CMasterClearWriteBuf() before I2CM_I2CMasterWriteBuf() as well.
Regards,
Pranava
Pranava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I add the (void) I2CM_I2CMasterClearStatus(); before I2CM_I2CMasterWriteBuf() call. But it still happen the reboot phenomenon m. the LA Waveform same as I provide before.
Thank you very much
Best Regards
Huang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you please mention the exact return code I2CM_I2CMasterStatus() is returning when its struck in while loop?
Can you also try disabling the watchdog timer reset in config.h
/* Enable watchdog hardware reset for CPU lock-up recovery */
#define WATCHDOG_HARDWARE_RESET_ENABLE (0u)
/* Disable CCG device reset on error (watchdog expiry or hard fault). */
#define RESET_ON_ERROR_ENABLE (0u)
Above are the 2 Macros in config.h you need to disable.
Also instead of Buffer based APIs you can try using (throughout the project) byte level APIs. You can refer to Component datasheet for example implementation.
Regards,
Pranava
Pranava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
its struck in while loop
I2CM_I2CMasterStatus() always be 0x04 in while loop, the problem only on soft timer.
Thank you very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
PranavaY_81 wrote:
Hi,
Can you please mention the exact return code I2CM_I2CMasterStatus() is returning when its struck in while loop?
Can you also try disabling the watchdog timer reset in config.h
/* Enable watchdog hardware reset for CPU lock-up recovery */
#define WATCHDOG_HARDWARE_RESET_ENABLE (0u)
/* Disable CCG device reset on error (watchdog expiry or hard fault). */
#define RESET_ON_ERROR_ENABLE (0u)
Above are the 2 Macros in config.h you need to disable.
Also instead of Buffer based APIs you can try using (throughout the project) byte level APIs. You can refer to Component datasheet for example implementation.
Regards,
Pranava
Can you please try the other suggestions and provide us the I2C log for the same?
Regards
Pranava
Pranava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I don't want to close WDT, so I try the byte level API.
Byte level API works good, no see any error and reboot phenomenon. So I think the Buffer base API has bug while applying in the Soft timer.Thanks