??? 10/14/08 17:20 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#159061 - Misunderstanding Responding to: ???'s previous message |
Jorge, I previously mentioned that you likely cannot ready from an EEPROM with the default CA code. The reason for this is that every read must start with a write of the address, then transmit a repeated start condition. However in your latest example you are still trying to receive from the EEPROM without first writing the address to receive from. Unless your EEPROM works differently from what I expect.
As I previously suggested, your first step is to just write to the EEPROM and get that working. Don't worry about trying to read. What you are looking for is a completed transfer with no errors. I also suggested going through the CA code line by line and understand what each register does and how everything fits together. I2C is a bit different from many of the other peripherals on a microcontroller in that you must understand the operation of I2C to be able to use it, even with generated code from CA. There is so much flexibility and so many aspects to consider that this is essential. I think that Keil's uVision allows you to simulate the I2C bus. I haven't tried it but I recommend looking into it. Erik's advice of toggling a pin every time the ISR is executed is a good one and you should do that. At a minimum the ISR should execute at least once when the start condition is transmitted. If that isn't happening then put your scope on the bus and confirm you see the start condition. So what I want to know: do you see the start condition on the bus. If yes, is the ISR executed at least once? If you don't see the start condition then check interrupts are enabled. You can step through your code in the Keil uVision simulator and then go to the Debug menu and open the I2C peripheral and confirm the register and interrupt settings - no need to simulate the I2C bus for that simple check. Andy |