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

Executing I2C routine inside of a Timer interrupt

I am having a problem. I can't seem to execute I2C related functions inside of my Timer0 interrupt routine.

My I2C returns a failure status. If I move my I2C related function calls inside the main loop everything works fine.

My first assumption - interrupt priority?

My second assumpution - frequency of which each interrupt is occuring? This shouldn't be a problem if my interrupt priorties are setup correctly.

Below is code of setting up interrupts to Timer0 and my I2C stuff.

Timer0

  /* Enable and setup timer interrupt, start timer */
  T0MR0         = 11999990;                   //1199999;  /* 50msec */
  T0MCR         = 3;                           /* Interrupt and Reset on MR0  */
  T0TCR         = 1;                           /* Timer0 Enable               */
  VICVectAddr4  = (unsigned long)T0_IRQHandler;/* Set Interrupt Vector        */
  VICVectCntl4  = 15;                          /* use it for Timer0 Interrupt */
  VICVectPriority4 = 0x03;
  VICIntEnable  = (1  << 4);                   /* Enable Timer0 Interrupt     */

I2C

//this two line block is just for reference.
#define I2C0_INT                9
#define HIGHEST_PRIORITY        0x01

/* find first un-assigned VIC address for the handler */
vect_addr = (DWORD *)(VIC_BASE_ADDR + VECT_ADDR_INDEX + I2C0_INT*4);
vect_cntl = (DWORD *)(VIC_BASE_ADDR + VECT_CNTL_INDEX + I2C0_INT*4);
*vect_addr = (DWORD)I2C0MasterHandler;  /* set interrupt vector */
*vect_cntl = HIGHEST_PRIORITY;
VICIntEnable = 1 << IntNumber;    /* Enable Interrupt */

I've tried increasing the T0MR0 value as well but no help.
I've tried giving Timer0 higher priority (which doesn't make much sense in my opinion).

Any help would be greatly appreciated.

Thank you everyone.

0