Hi,
I am having trouble getting my ISR up and running on the CC678. I am trying to read back from the DSP over I2C but I am not registering an interrupt and the I2C lines are driven low.
I am sure I am missing something simple but if I post some of my interrupt initialisation code is it possible if someone could point me in the right direction?
#define CSL_INTC_EVENTID_I2CINT 59
/* Intc variable declaration */
CSL_IntcContext g_intcContext;
CSL_IntcEventHandlerRecord g_EventHandler[1];
CSL_IntcObj g_intcObji2c;
CSL_IntcHandle g_hIntci2c;
CSL_IntcGlobalEnableState g_state;
CSL_IntcEventHandlerRecord g_EventRecord;
CSL_IntcParam g_vectId;
/* For the register scheme */
Uint8 g_addr_reg = 0; /* Register address, actually index of a register in g_regs[] array */
Uint8 g_write_mask = 0x80; /* If address received by the master & this is not zero then we are dealing
with a write operation */
Uint8 g_machine_state = 0; /* The I2C protocol is driven by a "state machine" this variable hold the last state */
Uint8 g_regs[] = { /* The actual registers the master can write to and read from */
0x01,
0x05,
0x06,
0x40,
0x50,
0x60,
0x70,
0x71,
0x72,
0x73
};
void init_intc()
{
int status;
CSL_Status cslstatus;
/* Intc module initialization */
g_intcContext.eventhandlerRecord = g_EventHandler;
g_intcContext.numEvtEntries = 1;
status = CSL_intcInit(&g_intcContext);
if (status != CSL_SOK) {
printf("Intc initialization failed\n");
return;
}
/* Enable NMIs */
status = CSL_intcGlobalNmiEnable();
if (status != CSL_SOK) {
printf("Intc global NMI enable failed\n");
return;
}
/* Enable global interrupts */
status = CSL_intcGlobalEnable(&g_state);
if (status != CSL_SOK) {
printf ("Intc global enable failed\n");
return;
}
/* Opening intc module */
g_vectId = CSL_INTC_VECTID_4;
g_hIntci2c = CSL_intcOpen (&g_intcObji2c, CSL_INTC_EVENTID_I2CINT,
&g_vectId , NULL);
if (g_hIntci2c == NULL) {
printf("Intc open failed\n");
return;
}
if (cslstatus != CSL_SOK) {
printf("interrupt open failed!\n");
return;
}
g_EventRecord.handler = eventI2CHandler; /* the event−handler for i2c interrupt */
g_EventRecord.arg = (void *)NULL; /* an argument to be passed to the ISR */
CSL_intcPlugEventHandler(g_hIntci2c, &g_EventRecord);
}
/* The I2C interrupt handler, the CPU arrives here each time a byte is ready to be read from the
* input read register. */
void eventI2CHandler (void *handle)
{
Uint8 buf = 0x66;
Uint32 ivr;
/* Read the interrupt code */
ivr = getI2CIVR();
/* Process interrupt */
switch(ivr) {
case I2C_IVR_ICRRDY_INTERRUPT:
/*
* An i2c data has been received serially and is available in the ICDRR register
*
*/
switch(g_machine_state%ISR_STATE_MACHINE_NUMBER_STATE) {
case ISR_STATE_MACHINE_STATE_ADDRESS:
/* Read from ICDRR register */
buf = getICDRR();
/* Figure out if the next operation is read or write operation and setup state machine
* in consequence */
if(buf&g_write_mask) {
g_machine_state = ISR_STATE_MACHINE_STATE_DATA_WRITE;
} else {
g_machine_state = ISR_STATE_MACHINE_STATE_DATA_READ;
}
/* Get rid of the directon bit in the address value */
buf &= ~g_write_mask;
/* Finally update the address value */
g_addr_reg = buf; /* Read from I2C ICDRR register and configure
address */
/* If it was a read transaction we place read transaction in the output register */
if(g_machine_state==ISR_STATE_MACHINE_STATE_DATA_READ) {
setICDXR(g_regs[g_addr_reg%(sizeof(g_regs)/sizeof(Uint8))]);
g_machine_state = ISR_STATE_MACHINE_STATE_ADDRESS;
}
break;
case ISR_STATE_MACHINE_STATE_DATA_WRITE:
/* Read from ICDRR register */
buf = getICDRR();
/* Write to register */
g_regs[g_addr_reg%(sizeof(g_regs)/sizeof(Uint8))] = buf;
/* The next byte we receive will be the address */
g_machine_state = ISR_STATE_MACHINE_STATE_ADDRESS;
break;
}
break;
}
}
I can see that the that data is being stored in the I2C receive data register but code my interrupts just aren't working. Any help would be greatly appreciated,
Thank you
Fearghal