AnsweredAssumed Answered

I2C Interrupt on EZ board 21486 not firing

Question asked by Mazerator on Jan 15, 2018
Latest reply on Jan 16, 2018 by Mazerator

Hello,

I searched this forum and studied various code samples but got stuck here. I already successfully implemented I2C handling on SC589 and I am trying to port it to the EZ board 21489 now. I renamed the registers and bit masks and added the SRU lines.

In I2C bus level the DSP seems to respond to the correct address. I can write 2 bytes to the DSP with ACK.

 

The problem: The ISR is never called. But why?

 

My code is pretty easy:

 

#define TWI_PRESCALE_VALUE   20                     //Prescale=fSCLK0/10MHz
#define slave_address (0x02)             //7-bit slave address

int main(int argc, char *argv[]) {
    adi_initComponents();

    // Configure TWI master and slave modules
    TWI_Init((PRESCALE & TWI_PRESCALE_VALUE), slave_address);

    //Initialize interrupts here
    adi_int_InstallHandler(TWI_INT, TWI0_Handler, NULL, true); //Installing the TWI0 interrupt handler

    printf("started\n");
    while (1) {
    }
}



#define TWI_IMASK5         (TWIRXINT | TWITXINT | TWISERR| TWISCOMP | TWISOVF)
#define TWI_FIFOCTL     (TWITXINT2 | TWIRXINT2)

void TWI_Init(unsigned int ControlReg, unsigned int slave_addr) {
    SRU(LOW,DPI_PB07_I);
    SRU(TWI_DATA_PBEN_O,DPI_PBEN07_I);
    SRU(DPI_PB07_O, TWI_DATA_I);

    SRU(LOW,DPI_PBEN08_I);
    SRU2(DPI_PB08_O,TWI_CLK_I) ;

    *pTWIMITR = (TWIEN | ControlReg);
    *pTWISADDR = slave_addr;    // load address of slave

    //     *pREG_TWI0_FIFOSTAT = (BITM_TWI_FIFOSTAT_RXSTAT >> 1) | (BITM_TWI_FIFOSTAT_TXSTAT >> 1);
    *pTWIFIFOCTL = TWITXFLUSH | TWIRXFLUSH;
    *pTWIFIFOCTL = TWI_FIFOCTL;        //normal operation of FIFO after flushing

    *pTXTWI16 = 0x0102;

    *pTWIIMASK = TWI_IMASK5;
    *pTWISCTL = TWISEN; // | ENUM_TWI_SLVCTL_VALID;

}

void TWI0_Handler(uint32_t iid, void* notUsed) {
    printf("foo\n");

}

 

The line "started" does appear in my output.

The line printf("foo\n"); is never called.

 

Thank you for ideas!

 

 

EDIT:

Meanwhile I stepped through the register browser. The TWI registers look like expected. After sending a byte to the DSP via I2C the input buffer contains that byte and TWIIRPTL has set the bits for TWISINIT and TWICOMP. After sending a second byte, also the bit for TWIRXINT is set. So from point of view of the TWI peripheral, the interrupt bit is set.

 

I also added  *pPICR0 = 0x17; to the main function without success.

Outcomes