hello everyone i am trying to send some digital value Using I2C protocol from DSP 2833x (Master)to DAC MCP47x6A0T-E/xx (Slave). Although program isnt showing any error but when i check the data line i dont see any data on it. Below is my program. Kindly help me in this regard. Your response will be highly appreciated. #include "DSP2833x_Device.h" #include "DSP2833x_Examples.h" #include "DSP2833x_I2C_defines.h" void I2CA_Init(void); void I2CA_Write(int); void I2CA_Wait(void); interrupt void i2c_int1a_isr(void); struct FLAGREG_BITS { volatile unsigned int Rsvd:16; //bits 0-14 }; union FLAG_REG { volatile unsigned int all; struct FLAGREG_BITS bit; }Flags; Uint16 Register; Uint16 Reg[6]; Uint16 ReadReg[6] = {0,0,0,0,0,0}; Uint16 InData[3]; Uint16 OutData[3]; Uint16 I2cIndex; #define I2C_SLAVE_ADDR 0xC0 void main (void) { InitSysCtrl(); InitI2CGpio(); DINT; InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); 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 I2cIndex = 0; // Step 4. Initialize all the Device Peripherals: I2CA_Init(); // Step 5, Master I2C register initialization Reg[0] = 0x012; Reg[1] = 0x024; Reg[2] = 0x054; Reg[3] = 0x032; Reg[4] = 0x073; Reg[5] = 0x0FF; PieCtrlRegs.PIEIER8.bit.INTx1 = 1; // Enable CPU INT8 which is connected to PIE group 8 IER |= M_INT8; EINT; while(1) { I2CA_Write(0); // Transfer Register 0 contents to slave. I2CA_Wait(); // Wait for I2C bus to clear I2CA_Write(1); I2CA_Wait(); // Wait for I2C bus to clear I2CA_Write(2); I2CA_Wait(); // Wait for I2C bus to clear I2CA_Write(3); I2CA_Wait(); // Wait for I2C bus to clear I2CA_Write(4); I2CA_Wait(); // Wait for I2C bus to clear I2CA_Write(5); I2CA_Wait(); // Wait for I2C bus to clear } } void I2CA_Init(void) { // Initialize I2C I2caRegs.I2CSAR = 0x00C0; // Slave Address. I2caRegs.I2COAR = 0x002D; // address as Master. I2caRegs.I2CPSC.all = 14; // Prescaler - need 7-12 Mhz on module clk// input clk frequency is 150MHz I2caRegs.I2CCLKL = 10; // NOTE: must be non zero I2caRegs.I2CCLKH = 5; // NOTE: must be non zero I2caRegs.I2CIER.all = 0xC0; // Enable SCD & ARDY interrupts I2caRegs.I2CMDR.bit.IRS = 1; // Take I2C out of reset // Stop I2C when suspended I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO // I2caRegs.I2CFFRX.all = 0x2040; // Enable RXFIFO, clear RXFFINT, return; } void I2CA_Write(Register) { int Byte0; int Byte1; Byte0 = Reg[Register]&0x0FF; // Get low byte of selected register. Byte1 = Reg[Register]>>8; // Get high byte of selected register. // Slave Address info gets passed with Start Condition // I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO I2caRegs.I2CCNT = 3; // 3 Additional Bytes being tranferred. I2caRegs.I2CDXR = Register; // Send Register to be updated. I2caRegs.I2CDXR = Byte1; // Next is high byte of register. I2caRegs.I2CDXR = Byte0; // Next is low byte of register. I2caRegs.I2CMDR.all = 0x6E20; } void I2CA_Wait(void) { while (I2caRegs.I2CMDR.bit.STP == 1); // Wait for Stop condition bit to be zero. while (I2caRegs.I2CSTR.bit.BB == 1); // Wait for Bus Busy to be zero. } interrupt void i2c_int1a_isr(void) // I2C-A { Uint16 IntSource; // Read interrupt source IntSource = I2caRegs.I2CISRC.bit.INTCODE & 0x7; switch(IntSource) { case I2C_NO_ISRC: // =0 break; case I2C_ARB_ISRC: // =1 break; case I2C_NACK_ISRC: // =2 break; case I2C_ARDY_ISRC: // =3 break; case I2C_RX_ISRC: // =4 InData[I2cIndex++] = I2caRegs.I2CDRR; break; case I2C_TX_ISRC: // =5 break; case I2C_SCD_ISRC: // =6 break; case I2C_AAS_ISRC: // =7 break; default: asm(" ESTOP0"); // Halt on invalid number. } // Enable future I2C (PIE Group 8) interrupts PieCtrlRegs.PIEACK.all = PIEACK_GROUP8; }
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.