This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to Debug an I2C-Communication ?

Hello,
I'm just trying to get started with the development of some software for an Infineon XC161CJ using the uVision2 Toolset.
My first attempt was to get a Display via I2C running (161 master, Display Slave, just write on it), so I used Dave to generate a basic Startup-Config and simply used some of its predefines macros to set up the i2C-communication. What other did one expect than this to fail.

My problem is I do not know how to debug. I wanted to use the Memory Window of the Debugger and have a look if the Registers are set properly and if I get an acknowledge from the slave, but I do not get any Information from the memory area, where I expect the registers to be.

The I2C is initialized by
---
IIC_CON = 0x0008; // load I2C system control register -> 7Bit-Addr,Single-Master,Ack active, 1Byte Transmit-Buffer
IIC_ADR = 0x0000; // load I2C address control register
IIC_CFG = 0x3133; // load I2C bus control register -> 00110001(=49=baudrate prescale) 0(reserved) 011(scl10) 0(reserved) 011(sda10)
IIC_ST = 0x0000; // load I2C status register

ALTSEL0P9 |= 0x000F; // select alternate output function
ALTSEL1P9 |= 0x0001; // select alternate output function
DP9 = (DP9 & ~(uword)0x000F) | 0x000F; //set direction register
---

when I watch the Memory Window at the corresponding adresses when IIC_CON is written (#define IIC_CON (*((uword volatile *) 0xE602)) I cannot see any changes, even when I change the value by hand in the Memory Window, after the next instruction its reset to the previous value, i.e. 0x0000.
Writing and reading to the memory area of standard-io-pins works fine, so it does watching it in the Memory Window of the debugger (for example #define P9 (*((uword volatile *) 0xFF16))


Anyone a suggestion where to start searching for the problem ?
Btw. is there any book or manual suitable for beginners ?

Thanks a lot for your replys

0