This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Interrupt is not invoking in the piccolo f28069

Other Parts Discussed in Thread: MSP430G2553

Hi every body,

I2c communication B/w (Master) Piccolo F28069 to (Slave) MSP430, is Done with out ISR.

Slave (MSP430) transmitting and Receive the data with ISR is working fine ,

But Master(Piccolo) receiving with ISR is not working.

Problems:

1.)Slave(msp430)transmitting data with ISR , Master(piccolo)  invoking  the interrupt itself with out giving any external request.

2.)Slave (MSP430) transmitting the data with ISR, in Master(Piccolo) i written a code in both modes with ISR and without ISR.
 
2.a) In without ISR mode master receives data which is send by slave

2.b) But with in ISR mode master is not receiving data
i am sending Master and Slave codes
Master program:

#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

// Note: I2C Macros used in this example can be found in the
// F2806x_I2C_defines.h file

// Prototype statements for functions found within this file.
void   I2CA_Init(void);
Uint16 I2CA_WriteData(struct I2CMSG *msg);
//Uint16 I2CA_WriteData();
Uint16 I2CA_ReadData(struct I2CMSG *msg);
__interrupt void i2c_int1a_isr(void);
void pass(void);
void fail(void);
void delay(unsigned int);

#define I2C_SLAVE_ADDR        0x48
#define I2C_NUMBYTES          0
#define I2C_EEPROM_HIGH_ADDR  0x00
#define I2C_EEPROM_LOW_ADDR   0x03
#define I2C_SUBADDR1  0x02

// Global variables
// Two bytes will be used for the outgoing address,
// thus only setup 14 bytes maximum
struct I2CMSG I2cMsgOut1={I2C_MSGSTAT_SEND_WITHSTOP,
                          I2C_SLAVE_ADDR,
                          I2C_NUMBYTES,
                          I2C_EEPROM_HIGH_ADDR,
                          I2C_EEPROM_LOW_ADDR,
                          0x00,                   // Msg Byte 1
                          0x01};                  // Msg Byte 2

struct I2CMSG I2cMsgIn1={ I2C_MSGSTAT_SEND_NOSTOP,
                          I2C_SLAVE_ADDR,
                          I2C_NUMBYTES,
                          I2C_EEPROM_HIGH_ADDR,
                          I2C_EEPROM_LOW_ADDR};

struct I2CMSG *CurrentMsgPtr;                // Used in interrupts
Uint16 PassCount;
Uint16 FailCount;
Uint16 Senddat[2]={0xFF,0x00};
Uint16 Datarry[2],Dat=0x01;
Uint16 rxData[100],count=0;

void main(void)
{
   //Uint16 Recv;
   Uint16 i;

   CurrentMsgPtr = &I2cMsgOut1;

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2806x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO:
// This example function is found in the F2806x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();
// Setup only the GP I/O only for I2C functionality
   InitI2CGpio();

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the F2806x_PieCtrl.c file.
   InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in F2806x_DefaultIsr.c.
// This function is found in F2806x_PieVect.c.
   InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
   EALLOW;    // This is needed to write to EALLOW protected registers
   PieVectTable.I2CINT1A = &i2c_int1a_isr;
   EDIS;   // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in F2806x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   I2CA_Init();

// Step 5. User specific code

   // Clear Counters
   PassCount = 0;
   FailCount = 0;

   // Clear incoming message buffer
  /* for (i = 0; i < I2C_MAX_BUFFER_SIZE; i++)
   {
       I2cMsgIn1.MsgBuffer[i] = 0x0000;
   }

   Datarry[0] = 0x00;
   Datarry[1] = 0x00;*/
// Enable interrupts required for this example

// Enable I2C interrupt 1 in the PIE: Group 8 interrupt 1
   PieCtrlRegs.PIEIER8.bit.INTx1 = 1;

// Enable CPU INT8 which is connected to PIE group 8
   IER |= M_INT8;
   EINT;
   for(i=0;i<100;i++)
               {
               rxData[i]=0x00;
               }

   // Application loop

      //////////////////////////////////
      // Write Opretion //
      //////////////////////////////////

        for(;;)

           {

/******************Read Opretation*********************************/
            I2CA_Init();
            I2caRegs.I2CCNT = 1;
            I2caRegs.I2CMDR.bit.TRX = 1;
            I2caRegs.I2CMDR.bit.MST = 1;
            I2caRegs.I2CMDR.bit.FREE = 1;
            I2caRegs.I2CMDR.bit.STP = 1;
            I2caRegs.I2CMDR.bit.STT = 1;
        //    while(I2caRegs.I2CSTR.bit.XRDY == 0){};
            I2caRegs.I2CSTR.bit.XRDY =0;
            for(i=0;i<500;i++)
            {
            //delay(500);
            I2caRegs.I2CDXR = Dat;
            }

            //DELAY_US(10);
            //delay(50);
            /*for(i=0;i<100;i++)
            {
            rxData[i]=0x00;
            }*/
           I2caRegs.I2CCNT = I2C_NUMBYTES+1;            //read byte from Msp430
           I2caRegs.I2CMDR.bit.TRX = 0;                 //Set to Recieve mode
           I2caRegs.I2CMDR.bit.MST = 1;                 //Set to Master mode
           I2caRegs.I2CMDR.bit.FREE = 1;                //Run in FREE mode
           I2caRegs.I2CMDR.bit.STP = 1;                 //Stop when internal counter becomes 0
           I2caRegs.I2CMDR.bit.STT = 1;                  //Repeated start, Reception will follow

           for(i = 0; i < I2C_NUMBYTES+1; i++){


                   while(I2caRegs.I2CSTR.bit.RRDY == 0){};     //I2CDRR not ready to read?
                   rxData[count] = I2caRegs.I2CDRR;
                   delay(100);
              count++;

           }
          // I2C_NUMBYTES++;
/***************************************************/
           Dat++;
                       if(Dat==0x09)
                       {
                       Dat=0x01;
                       }
  }   // end of for(;;)
}   // end of main

void I2CA_Init(void)
{

 /********************************************/

      I2caRegs.I2CMDR.bit.IRS  = 0;
      I2caRegs.I2CCLKL     = 19;
      I2caRegs.I2CCLKH = 5;
      I2caRegs.I2CIER.all     = 0;
      I2caRegs.I2CIER.all = 0x24;        // Enable SCD & ARDY interrupts
      I2caRegs.I2CMDR.bit.IRS = 1;
      I2caRegs.I2CSAR = I2C_SLAVE_ADDR;              //Slave Adders
     // I2caRegs.I2CSTR.bit.RRDY =1;
      //I2caRegs.I2CIER.bit.RRDY=1;
      I2caRegs.I2CFFRX.all = 0x2020;    // Enable RXFIFO, clear RXFFINT,
      return;


/******************************************/



}




__interrupt void i2c_int1a_isr(void)     // I2C-A
{
   Uint16  i=0;

              rxData[i] = I2caRegs.I2CDRR;

   PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
}



void delay(unsigned int a)
{
    unsigned int i;
    for(i=0;i<a;i++);
}

//===========================================================================
// No more.
//===========================================================================

Slave program:
#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

// Note: I2C Macros used in this example can be found in the
// F2806x_I2C_defines.h file

// Prototype statements for functions found within this file.
void   I2CA_Init(void);
Uint16 I2CA_WriteData(struct I2CMSG *msg);
//Uint16 I2CA_WriteData();
Uint16 I2CA_ReadData(struct I2CMSG *msg);
__interrupt void i2c_int1a_isr(void);
void pass(void);
void fail(void);
void delay(unsigned int);

#define I2C_SLAVE_ADDR        0x48
#define I2C_NUMBYTES          0
#define I2C_EEPROM_HIGH_ADDR  0x00
#define I2C_EEPROM_LOW_ADDR   0x03
#define I2C_SUBADDR1  0x02

// Global variables
// Two bytes will be used for the outgoing address,
// thus only setup 14 bytes maximum
struct I2CMSG I2cMsgOut1={I2C_MSGSTAT_SEND_WITHSTOP,
                          I2C_SLAVE_ADDR,
                          I2C_NUMBYTES,
                          I2C_EEPROM_HIGH_ADDR,
                          I2C_EEPROM_LOW_ADDR,
                          0x00,                   // Msg Byte 1
                          0x01};                  // Msg Byte 2

struct I2CMSG I2cMsgIn1={ I2C_MSGSTAT_SEND_NOSTOP,
                          I2C_SLAVE_ADDR,
                          I2C_NUMBYTES,
                          I2C_EEPROM_HIGH_ADDR,
                          I2C_EEPROM_LOW_ADDR};

struct I2CMSG *CurrentMsgPtr;                // Used in interrupts
Uint16 PassCount;
Uint16 FailCount;
Uint16 Senddat[2]={0xFF,0x00};
Uint16 Datarry[2],Dat=0x01;
Uint16 rxData[100],count=0;

void main(void)
{
   //Uint16 Recv;
   Uint16 i;

   CurrentMsgPtr = &I2cMsgOut1;

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2806x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO:
// This example function is found in the F2806x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();
// Setup only the GP I/O only for I2C functionality
   InitI2CGpio();

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the F2806x_PieCtrl.c file.
   InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in F2806x_DefaultIsr.c.
// This function is found in F2806x_PieVect.c.
   InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
   EALLOW;    // This is needed to write to EALLOW protected registers
   PieVectTable.I2CINT1A = &i2c_int1a_isr;
   EDIS;   // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in F2806x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   I2CA_Init();

// Step 5. User specific code

   // Clear Counters
   PassCount = 0;
   FailCount = 0;

   // Clear incoming message buffer
  /* for (i = 0; i < I2C_MAX_BUFFER_SIZE; i++)
   {
       I2cMsgIn1.MsgBuffer[i] = 0x0000;
   }

   Datarry[0] = 0x00;
   Datarry[1] = 0x00;*/
// Enable interrupts required for this example

// Enable I2C interrupt 1 in the PIE: Group 8 interrupt 1
   PieCtrlRegs.PIEIER8.bit.INTx1 = 1;

// Enable CPU INT8 which is connected to PIE group 8
   IER |= M_INT8;
   EINT;
   for(i=0;i<100;i++)
               {
               rxData[i]=0x00;
               }

   // Application loop

      //////////////////////////////////
      // Write Opretion //
      //////////////////////////////////

        for(;;)

           {

/******************Read Opretation*********************************/
            I2CA_Init();
            I2caRegs.I2CCNT = 1;
            I2caRegs.I2CMDR.bit.TRX = 1;
            I2caRegs.I2CMDR.bit.MST = 1;
            I2caRegs.I2CMDR.bit.FREE = 1;
            I2caRegs.I2CMDR.bit.STP = 1;
            I2caRegs.I2CMDR.bit.STT = 1;
        //    while(I2caRegs.I2CSTR.bit.XRDY == 0){};
            I2caRegs.I2CSTR.bit.XRDY =0;
            for(i=0;i<500;i++)
            {
            //delay(500);
            I2caRegs.I2CDXR = Dat;
            }

            //DELAY_US(10);
            //delay(50);
            /*for(i=0;i<100;i++)
            {
            rxData[i]=0x00;
            }*/
           I2caRegs.I2CCNT = I2C_NUMBYTES+1;            //read byte from Msp430
           I2caRegs.I2CMDR.bit.TRX = 0;                 //Set to Recieve mode
           I2caRegs.I2CMDR.bit.MST = 1;                 //Set to Master mode
           I2caRegs.I2CMDR.bit.FREE = 1;                //Run in FREE mode
           I2caRegs.I2CMDR.bit.STP = 1;                 //Stop when internal counter becomes 0
           I2caRegs.I2CMDR.bit.STT = 1;                  //Repeated start, Reception will follow

           for(i = 0; i < I2C_NUMBYTES+1; i++){


                   while(I2caRegs.I2CSTR.bit.RRDY == 0){};     //I2CDRR not ready to read?
                   rxData[count] = I2caRegs.I2CDRR;
                   delay(100);
              count++;

           }
          // I2C_NUMBYTES++;
/***************************************************/
           Dat++;
                       if(Dat==0x09)
                       {
                       Dat=0x01;
                       }
  }   // end of for(;;)
}   // end of main

void I2CA_Init(void)
{

 /********************************************/

      I2caRegs.I2CMDR.bit.IRS  = 0;
      I2caRegs.I2CCLKL     = 19;
      I2caRegs.I2CCLKH = 5;
      I2caRegs.I2CIER.all     = 0;
      I2caRegs.I2CIER.all = 0x24;        // Enable SCD & ARDY interrupts
      I2caRegs.I2CMDR.bit.IRS = 1;
      I2caRegs.I2CSAR = I2C_SLAVE_ADDR;              //Slave Adders
     // I2caRegs.I2CSTR.bit.RRDY =1;
      //I2caRegs.I2CIER.bit.RRDY=1;
      I2caRegs.I2CFFRX.all = 0x2020;    // Enable RXFIFO, clear RXFFINT,
      return;


/******************************************/



}




__interrupt void i2c_int1a_isr(void)     // I2C-A
{
   Uint16  i=0;

              rxData[i] = I2caRegs.I2CDRR;

   PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
}



void delay(unsigned int a)
{
    unsigned int i;
    for(i=0;i<a;i++);
}

//===========================================================================
// No more.
//===========================================================================



please help me  thanks Advancely .






























  • Hello Mahdhu,

    Did you solve your problem?

    I will try to help even though I am not sure I can help you totally. I am also still learning.

    How about you try to change your I2C init?

    (and please read the F28069 datasheet carefully and check all of your setting values)

    void I2CA_Init(void)
    {

     /********************************************/

          I2caRegs.I2CMDR.bit.IRS  = 0;
          I2caRegs.I2CCLKL     = 19;
          I2caRegs.I2CCLKH = 5;
          I2caRegs.I2CIER.all     = 0;
          I2caRegs.I2CIER.all = 0x24;        // Enable SCD & ARDY interrupts  // i think you don't need SCD and ARDY, but if you need them, combine it with RRDY bit (become 0x2C)
          I2caRegs.I2CMDR.bit.IRS = 1;
          I2caRegs.I2CSAR = I2C_SLAVE_ADDR;              //Slave Adders
         // I2caRegs.I2CSTR.bit.RRDY =1;
          I2caRegs.I2CIER.bit.RRDY=1;  // this is to enable Receive-data-ready interrupt RRDYINT
          I2caRegs.I2CFFRX.all = 0x2020;    // Enable RXFIFO, clear RXFFINT,

          return;


    /******************************************/
    }

    And in I2C interrupt:

    __interrupt void i2c_int1a_isr(void)     // I2C-A
    {
       Uint16  i=0;

    Uint16 IntSource;

       // Read interrupt source
       IntSource = I2caRegs.I2CISRC.all;

    if(IntSource = I2C_RX_ISRC) // it means the interrupt is for RRDYINT

    {
                  rxData[i] = I2caRegs.I2CDRR;

         I2caRegs.I2CSTR.bit.RRDY=1;   // Clear Interrupt flag

    }

       PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;

            PieCtrlRegs.PIEACK.all |= PIEACK_GROUP8;
    }


    Please try and let us know your result.

    Good luck!


    Best regards,

    Maria

  • thanks Maria,

    for giving replay, I solved  the problem, few days before , communicating Master(PiccoloF28069 )  and  Slave (MSP430G2553) and working fine.