Other Parts Discussed in Thread: MOTORWARE
Tool/software: Code Composer Studio
Hello,
I need help with developing c2000>arduino communication via i2c. I've studied threads from this forum but i've found only scraps of information. My goal is to use launchpad as SLAVE receiver to read 4 bytes(string) from arduino, and use that in modified motorware project. I have a few questions.
1)I started by adding includes and this from this topic: Is it all i need to get things working? Or should i make some modifications in hal.c/gpio.c/whateverelse.c?:)
2)I read that other people had to do some hardware modifications, cutting some jumpers to use GPIO32 and GPIO33 pin as i2c bus. Is it nessesary? Why and what to do if so?
3)What is needed to be done in initialisation? Everything i saw on this topic included clock setting, interrupts, NACK, some InitSysCtrl() function, some InitPieCtrl(); and other refering to this Pie-thing. Do i really need all of these, since my launchpad wont be driving i2c bus, just responding to data coming from it?
I've figured out this setup:
void I2cInit(void) { EALLOW; //? GpioCtrlRegs.GPBPUD.bit.GPIO32 = 1; // Enable pull-up for GPIO32 (SDAA) GpioCtrlRegs.GPBPUD.bit.GPIO33 = 1; // Enable pull-up for GPIO33 (SCLA) GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3; // Asynch input GPIO32 (SDAA) GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3; // Asynch input GPIO33 (SCLA) GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1; //gpio 32 sda GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1; //gpio 33 scl EDIS; //? I2caRegs.I2CMDR.bit.IRS = 0; //i2c reset to setup I2caRegs.I2COAR = 9; //launchpad slave adress I2caRegs.I2CPSC.all = 9; //prescaller I2caRegs.I2CMDR.bit.MST= 0; //slave mode I2caRegs.I2CMDR.bit.TRX = 0; //receive mode I2caRegs.I2CMDR.bit.NACKMOD = 0; I2caRegs.I2CMDR.bit.FDF = 0; I2caRegs.I2CCNT = 4; //4 bytes to receive I2caRegs.I2CIER.all = 0; //no interrupts I2caRegs.I2CMDR.bit.IRS = 1; return; }
What else should i set here?
4)How does the slave-reading procedure/function look? How to spot the write-request from master and how to respond to it?
4a)Since the data register is 16bit i assume i should use FIFO buffer or just making it write to 4byte array will work? Do you have some example on it? Make master request 4 bytes is pretty straight-forward but how does it work when it comes to slave-receiver?
5)Would it be good to do interrupt if data come from the bus and write it in that interrupt? How to achieve that? Won't it spoil all the control code working in motorware project?
Thanks for any help.
Best