- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello this is my first post and first PSOC project that I am doing. What I am trying to do is to read the data from the mpu6050 gyroscoop with I2C.
But i am getting a error when i try to build the code. The error i am getting is Build error: undefined reference to 'gyro_WriteReg'. But when I click on go to declaration I go to the .h file I have, so I think the problem is not with the connection with the .c & .h file but somewhere else.
Can someone explain why i get this error?
See atached file for project
Solved! Go to Solution.
- Labels:
-
PSOC5 LP MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for uploading the project.
Now I could reproduce the problem.
And what I noticed was that since you have an I2C component "I2C" in your schematic,
there were file named "I2C.h" and "I2C.c" in the Generated_Source / PSoC5 / I2C
So I renamed your i2c.c and i2c.h to i2c_gyro.c and i2c_gyro.h.
And now your project could be compiled.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Your attached project contained only the project file,
it would be easier for others to see what is your problem
if you can archive the whole project and post.
I have just re-read the I2C.h automatically generated
========================
/* I2C Master functions prototypes */
#if (I2C_MODE_MASTER_ENABLED)
/* Read and Clear status functions */
uint8 I2C_MasterStatus(void) ;
uint8 I2C_MasterClearStatus(void) ;
/* Interrupt based operation functions */
uint8 I2C_MasterWriteBuf(uint8 slaveAddress, uint8 * wrData, uint8 cnt, uint8 mode) \
;
uint8 I2C_MasterReadBuf(uint8 slaveAddress, uint8 * rdData, uint8 cnt, uint8 mode) \
;
uint8 I2C_MasterGetReadBufSize(void) ;
uint8 I2C_MasterGetWriteBufSize(void) ;
void I2C_MasterClearReadBuf(void) ;
void I2C_MasterClearWriteBuf(void) ;
/* Manual operation functions */
uint8 I2C_MasterSendStart(uint8 slaveAddress, uint8 R_nW) \
;
uint8 I2C_MasterSendRestart(uint8 slaveAddress, uint8 R_nW) \
;
uint8 I2C_MasterSendStop(void) ;
uint8 I2C_MasterWriteByte(uint8 theByte) ;
uint8 I2C_MasterReadByte(uint8 acknNak) ;
#endif /* (I2C_MODE_MASTER_ENABLED) */
========================
And I could not find I2C_ReadReg() and/or I2C_WriteReg(),
So probably, the user (programmer) need to write WriteReg() function.
Your error seems that the gyro_WriteReg() is declared in the header file,
but the linker could not find the real implementation of that function.
FYI, I have written and posted some sample code for PSoC 5LP including a simple usage of I2C.
In those project, I implemented i2c_read_reg() and i2c_write_reg() functions in i2c_utils.h/i2c_utils.c,
hopefully these can be some hint for you.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
as asked i have uploaded the project and now normally it is the whole project. The files where
gyro writeReg is mentioned is a seperate .c & .h file that i wrote. (i2c.c & i2c.h)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for uploading the project.
Now I could reproduce the problem.
And what I noticed was that since you have an I2C component "I2C" in your schematic,
there were file named "I2C.h" and "I2C.c" in the Generated_Source / PSoC5 / I2C
So I renamed your i2c.c and i2c.h to i2c_gyro.c and i2c_gyro.h.
And now your project could be compiled.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank you, the errors are now gone.