I2C is not work when internal watchdog(COP) enable.
Could you tell me how to clear this problem?
* Watchdong Setting -
/* ### WatchDog "WDog1" init code ... */
/* CPMUPROT: ??=0,??=0,??=1,??=0,??=0,??=1,??=1,PROT=0 */
setReg8(CPMUPROT, 0x26U); /* Disable protection of clock-source register */
/* CPMUCLKS: CSAD=0,PCE=0,COPOSCSEL0=1 */
clrSetReg8Bits(CPMUCLKS, 0x24U, 0x01U);
/* CPMUPROT: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,PROT=0 */
setReg8(CPMUPROT, 0x00U); /* Re-Enable protection of clock-source register */
/* CPMURFLG: COPRF=0 */
setReg8(CPMURFLG, 0x00U); /* Clear COP reset flag */
/* CPMUCOP: WCOP=0,CR2=1,CR1=0,CR0=0 */
clrSetReg8Bits(CPMUCOP, 0x83U, 0x04U);
* I2C Setting
/* IIC0IBCR: IBEN=0,IBIE=0,MS_SL=0,TX_RX=0,TXAK=0,RSTA=0,??=0,IBSWAI=0 */
IIC0IBCR = 0U; /* Clear control register */
I2C_SerFlag = 0x80U; /* Reset all flags */
I2C_SlaveAddr = 0x10U; /* Set variable for slave address */
/* IIC0IBFD: IBC7=0,IBC6=1,IBC5=0,IBC4=1,IBC3=0,IBC2=1,IBC1=0,IBC0=0 */
IIC0IBFD = 0x54U; /* Set prescaler bits */
IIC0IBCR_IBEN = 1U; /* Enable device */
/* IIC0IBCR: IBEN=1,IBIE=1,MS_SL=0,TX_RX=0,TXAK=0,RSTA=0,??=0,IBSWAI=0 */
IIC0IBCR = 0xC0U; /* Control register settings */
Hi Seung-Tae,
When you enable watchdog, you have to trigger (feed) him, otherwise watchdog resets MCU.
I2C code typically contains several loops.
Are you sure that you trigger watchdog inside these loops?
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank you for you kind answer.
I already check watch reset is not occured.
Also I found another problem.
Below code is not I2C related part.
But It's effect to I2C communication work or not.
/* I2C is work */
WDT_Clear();
DIO_SetTestIO(big_HI);
//DIO_SetTestIO(big_LO);
/* I2C is not work */
WDT_Clear();
//DIO_SetTestIO(big_HI);
//DIO_SetTestIO(big_LO);
I think reason of this problem is CodeWarrior Setting Or Project Configuration.
But I can't find solution.
Hi Seung-Tae,
Thank you for checking watchdog.
I could see three potential issues related to your OK and NOK code:
1. I suppose that DIO_SetTestIO() function just setup some pin digital output. Correct? Is that digital pin somehow connected to I2C channel? For example: The TestIO (or any other pin on this port) may be connected to inhibit pin at I2C bus buffer IC,….
2. Comment out DIO_SetTestIO(big_HI); command may influence duration between two watchdog triggers. Since you already checked that watchdog reset is not occurred and I suppose that you don’t use window watchdog, this potential issues have low probability.
3. When you comment out one unnecessary line in code and it has some influence on code behavior, it is possible that there is some issue with code/const placing. Do you use any pointers to specific addresses in memory and data at this address could be influenced by code length?
Be aware, CW generates project where warning about memory overlap is disabled. Linker do not care about user placements like “unsigned char ADC0Command @0x001000 = 0xC1;”
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------