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 modify I2C ISR in Cypress EZ-USB lib

I have several Microchip 8K EEPROMs on my Cypress FX2LP's I2C bus. To read from these larger ROM chips, a specific I2C protocol must be followed...

* Start token
Write 2-byte mem location to I2C address
* Start token
Read n data bytes from I2C address
* Stop token

Unfortunately, using the default EXUSB.lib functions results in a "Stop" token placed on the bus after the EZUSB_WriteI2C() function is called...

* Start token
Write 2-byte mem read-location to I2C address 0xA6
* Stop token
* Start token
Read data from I2C address 0xA6
* Stop token

Looking at the EZUSB.lib source code, most of the work is done by an ISR called "i2c_isr()". Obviously, I must modify this function to omit the "Stop" token under certain conditions while writing to the I2C bus.

The problem is, I can't seem to remap the I2C interrupt vector to my new function. I've rebuilt the EZUSB library without the I2C related functions. But when I build my project, a warning message claims my "new_i2c_isr()" function is unused and will be omitted from the image. In other words, the Keil "interrupt" language extension doesn't seem to work in my code...

void new_i2c_isr (void) interrupt 9
{ // new code here
}

So how do I map my new_i2c_isr() function to the I2C interrupt vector? Has anyone ever modified the I2C behavior of the EZUSB lib?

Parents
  • As you seem to conclude this I2C EEPROM problem, this comment may be unnecessary,

    "The "Stop" token IS REQUIRED when setting the memory read location."

    The repeated START (without STOP) also works.
    But you need an another state variable (flag) to control the flow in the I2C ISR. It takes fare amount of changes from the source code of the Cypress I2C library.

    Both methods work. Then, choose one, good for you :-)

    Tsuneo

Reply
  • As you seem to conclude this I2C EEPROM problem, this comment may be unnecessary,

    "The "Stop" token IS REQUIRED when setting the memory read location."

    The repeated START (without STOP) also works.
    But you need an another state variable (flag) to control the flow in the I2C ISR. It takes fare amount of changes from the source code of the Cypress I2C library.

    Both methods work. Then, choose one, good for you :-)

    Tsuneo

Children
No data