Other Parts Discussed in Thread: MOTORWARE
Tool/software: Code Composer Studio
Hello
Good day !
I am working with F28027F and trying to store data into eeprom(ATMEL 24C04) via I2C interface .for that I use
C:\ti\motorware_1_01_00_16\sw\solutions\instaspin_foc\boards\hvkit_rev1p1\f28x\f2802xF\projects\ccs5\Example_F2802xI2C_eeprom\Example_2802xI2C_eeprom.c
Happily It worked fairly well ,but I have some questions.
- The things that I want is, to store 32bit(float)data into EEPROM which can be sort of this
address |
Data |
0x0000 |
0x23 |
0x0001 |
0x54 |
0x0002 |
0x42 |
0x0003 |
0x26 |
0x0004 |
0x34 |
0x0005 |
0x76 |
0x0006 |
0x56 |
0x0007 |
0x45 |
As shown in table 0x0000 -0x0003 is belong to one 32bit float data and from 0x0004-0x0007 is belong to another 32bit float data and etc…
How to do it ?
2. pay attention to this code..
#define I2C_SLAVE_ADDR 0x50 #define I2C_NUMBYTES 2 #define I2C_EEPROM_HIGH_ADDR 0x00 #define I2C_EEPROM_LOW_ADDR 0x30 // 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, 0x10, // Msg Byte 1 0x20 // Msg Byte 2 }; struct I2CMSG I2cMsgIn1={ I2C_MSGSTAT_SEND_NOSTOP, I2C_SLAVE_ADDR, I2C_NUMBYTES, I2C_EEPROM_HIGH_ADDR, I2C_EEPROM_LOW_ADDR
};
a.Are those (#define I2C_EEPROM_HIGH_ADDR 0x00 and #define I2C_EEPROM_LOW_ADDR 0x30) as an EEPROM Address ?
if so,then why it (I2C_EEPROM_LOW_ADDR 0x30) did not start from 0x00?!
I would be happy if you explain more about 2C_EEPROM_HIGH_ADDR and I2C_EEPROM_LOW_ADDR .
b. I got a bit confuse about the comments in that project.(
" Two bytes will be used for the outgoing address, thus only setup 14 bytes maximum)" what that supposed to mean?
if I set I2C_NUMBYTES to more than 2 I have to also set #define I2C_MAX_BUFFER_SIZE to more than 4
which makes another problem ... take a look at code in below.
// I2C Message Structure struct I2CMSG { Uint16 MsgStatus; // Word stating what state msg is in: // I2C_MSGCMD_INACTIVE = do not send msg // I2C_MSGCMD_BUSY = msg start has been sent, // awaiting stop // I2C_MSGCMD_SEND_WITHSTOP = command to send // master trans msg complete with a stop bit // I2C_MSGCMD_SEND_NOSTOP = command to send // master trans msg without the stop bit // I2C_MSGCMD_RESTART = command to send a restart // as a master receiver with a stop bit Uint16 SlaveAddress; // I2C address of slave msg is intended for Uint16 NumOfBytes; // Num of valid bytes in (or to be put in MsgBuffer) Uint16 MemoryHighAddr; // EEPROM address of data associated with msg (high byte) Uint16 MemoryLowAddr; // EEPROM address of data associated with msg (low byte) Uint16 MsgBuffer[I2C_MAX_BUFFER_SIZE]; // Array holding msg data - max that // MAX_BUFFER_SIZE can be is 4 due to // the FIFO's };
As you can see the I2C_MAX_BUFFER_SIZE can not set to more then 4...
Uint16 MsgBuffer[I2C_MAX_BUFFER_SIZE]; // Array holding msg data - max that
// MAX_BUFFER_SIZE can be is 4 due to
// the FIFO's
please let me know how to store EEPROM byte by byte?
and does it need to be sequential(getdata(Address = 0x0000,0x0001,0x0002,0x0003,...0xFFFF)) addressing EEPROM or we can do it Random(I need random addressing)?
thanks for attention .
Best regards.
Dave.