Porting MPU-6050 I2C from Psoc4 to Psoc3 CY8CKIT-030

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Greetings!  I've not been on the forum for several years having done a fair amount with psoc1, but very little if anything with creator.  I found a cool application I want to try with this kit that has been in my closet for much too long.  I want to use the I2C MPU-6050 3 axis gyro and 3 axis accelerometer on my kid's rc toys.  I found a psoc4 project that used the same sensor and had this great header and library code from the 100 project competition for the pioneer kit and had to make some changes to the code to get this far, but I'm getting a duplicate declaration error and I have reached my patience limit.  After changing every _t declaration for all int8, uint8, int16, uint16 and uint32 in the project, I changed all the bool types to CYBIT and it still won't compile.  I've cleaned and archived the project if anyone has a second to find the super obvious thing that I can't seem to find, I would really appreciate the help.  THANKS!!

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Your error was to define variavles

   

uint8 devAddr;
uint8 bufferM[22];

   


within a .h file. Declare them as external and define them in mpu6050.c Compiles without any errors.

   

 

   

Bob

View solution in original post

0 Likes
13 Replies
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received

I think your project is not complete
not enough describe the multiple functions (IICwriteBit(...)..IICwriteBits(..))
and main.h file, etc. ..
Perhaps you are interested in this information:
Sam's Blog
http://samselectronicsprojects.blogspot.co.uk/
http://samselectronicsprojects.blogspot.ru/2014/07/processing-data-from-mpu-6050.html

   

https://github.com/EmbeddedSam/MPU-6050/tree/master/Examples

0 Likes
lock attach
Attachments are accessible only for community members.
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received

This project is not working. But without errors))
added:
empty IICwriteBits(), IICwriteBit()
uint8_t devAddr;   
#include "cytypes.h"  
MPU6050_init();

0 Likes
Anonymous
Not applicable

Thanks for the links and for taking time to respond.  I really appreciate it.  The github is where I got the code, but it is/was for psoc4.  If the project was complete I would not need help with this.  It all compiles, but this is the error during the linking/build:

   

 

   
    The code generation step is up to date.    
c51.exe .\mpu6050.c NOIV LARGE MODDP2 OMF2 VB(1) NOIP "INCDIR(., Generated_Source\PSoC3)" FF(3) DB DF(DEBUG) WL(2) PR(.\DP8051\DP8051_Keil_951\Debug/mpu6050.lst) CD OT(2 ,Size) OJ(.\DP8051\DP8051_Keil_951\Debug\mpu6050.obj)    
LIBX51.exe TRANSFER '.\DP8051\DP8051_Keil_951\Debug\cyfitter_cfg.obj', '.\DP8051\DP8051_Keil_951\Debug\I2C_MPU6050.obj', '.\DP8051\DP8051_Keil_951\Debug\I2C_MPU6050_BOOT.obj', '.\DP8051\DP8051_Keil_951\Debug\I2C_MPU6050_INT.obj', '.\DP8051\DP8051_Keil_951\Debug\I2C_MPU6050_PM.obj', '.\DP8051\DP8051_Keil_951\Debug\I2C_MPU6050_SLAVE.obj', '.\DP8051\DP8051_Keil_951\Debug\I2C_MPU6050_MASTER.obj', '.\DP8051\DP8051_Keil_951\Debug\SERIAL.obj', '.\DP8051\DP8051_Keil_951\Debug\SERIAL_PM.obj', '.\DP8051\DP8051_Keil_951\Debug\SERIAL_INT.obj', '.\DP8051\DP8051_Keil_951\Debug\SERIAL_BOOT.obj', '.\DP8051\DP8051_Keil_951\Debug\I2C_SDA.obj', '.\DP8051\DP8051_Keil_951\Debug\I2C_SCL.obj', '.\DP8051\DP8051_Keil_951\Debug\LCD.obj', '.\DP8051\DP8051_Keil_951\Debug\LCD_PM.obj', '.\DP8051\DP8051_Keil_951\Debug\SERIAL_IntClock.obj', '.\DP8051\DP8051_Keil_951\Debug\LCD_LCDPort.obj', '.\DP8051\DP8051_Keil_951\Debug\CyScBoostClk.obj', '.\DP8051\DP8051_Keil_951\Debug\CyBootAsmKeil.obj', '.\DP8051\DP8051_Keil_951\Debug\CyDmac.obj', '.\DP8051\DP8051_Keil_951\Debug\CyFlash.obj', '.\DP8051\DP8051_Keil_951\Debug\CyLib.obj', '.\DP8051\DP8051_Keil_951\Debug\cymem.obj', '.\DP8051\DP8051_Keil_951\Debug\cyPm.obj', '.\DP8051\DP8051_Keil_951\Debug\CySpc.obj', '.\DP8051\DP8051_Keil_951\Debug\cyutils.obj', '.\DP8051\DP8051_Keil_951\Debug\KeilStart.obj' TO '.\DP8051\DP8051_Keil_951\Debug\I2C_test.lib'    
LX51.exe '.\DP8051\DP8051_Keil_951\Debug\main.obj', '.\DP8051\DP8051_Keil_951\Debug\mpu6050.obj', '.\DP8051\DP8051_Keil_951\Debug\I2C_test.lib', 'C:\Program Files (x86)\Cypress\PSoC Creator\3.3\PSoC Creator\psoc\content\cycomponentlibrary\CyComponentLibrary.cylib\DP8051\DP8051_Keil_951\Debug\CyComponentLibrary.lib' TO '.\DP8051\DP8051_Keil_951\Debug\I2C_test.omf' CODE RU RC(10) DW(16) WL(2) PR(.\DP8051\DP8051_Keil_951\Debug/I2C_test.map) IX CL(XDATA(X:0x0000-X:0x1FFF)) CL(CODE(C:0x0000-C:0xFFFF)) CL(CONST(C:0x0000-C:0xFFFF))    
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS    
    SYMBOL:  bufferM    
    MODULE:  .\DP8051\DP8051_Keil_951\Debug\mpu6050.obj (MPU6050)    
   DEFINED:  .\DP8051\DP8051_Keil_951\Debug\main.obj (MAIN)    
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS    
    SYMBOL:  devAddr    
    MODULE:  .\DP8051\DP8051_Keil_951\Debug\mpu6050.obj (MPU6050)    
   DEFINED:  .\DP8051\DP8051_Keil_951\Debug\main.obj (MAIN)    
Program Size: data=17.1 xdata=1299 const=50 code=7219    
The command 'LX51.exe' failed with exit code '2'.   
   

It is complaining about multiple declarations, but I can't find the second declaration...  I just need basic functionality, so this is overkill anyway, but I was trying to not reinvent the wheel.

0 Likes
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received


Your project for CY8C4245AXI-483
I thought at first that you want to debug your project with PSoC4.
PSoC3 does not involve the use of SCB.

Anonymous
Not applicable

Thanks Pavloven for looking at the code.  I opened your response and it is for the psoc 4, similar to the original project I started with.  I'd really like to use psoc 3 for this since the CY8C3866AXI-040 chip is attached to the 030 psoc 3 kit I have.  I don't know what SCB is.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received
        The PSOC 4 doesn't need the Keil code that is for PCOC 1 the 8051 PSOC. You need to write the code using PSOC 4 code.   
0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received
        The PSOC 4 doesn't need the Keil code that is for PCOC 1 the 8051 PSOC. You need to write the code using PSOC 4 code.   
0 Likes
Anonymous
Not applicable

Thanks again for your responses.  For clarity, I don't have psoc4.  I started with a project originally written for the psoc4 but I don't intend to use psoc4.  The goal here is to get code from the psoc4 ported to work on the psoc3.  Any suggestions on how best to accomplish a working psoc3 device would be appreciated.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Orob, the first thing you have to do is to change the device to your PSoC3 you use. under the Project menu you'll fing that choice. Changing the _t to something different is not needed, there is a library for these types, <cytypes.h> will do.

   

I only saw your PSoC4 project so far. when you've got a PSoC3 one, attach it to your next post.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Wow.  I archived the project and uploaded what I thought was what I was working on, but it was the backup version before I began to make changes.  Sorry for all the confusion.  

   

So far, I changed the device in the device selector (updated posted project in first posting - again apologize for the confusion).  The uploaded version that @pavloven posted has the right device and gives the same error I am seeing.  I changed the original upload to the current version I'm noodling on, but none of them work yet and both give the error I'm seeing: duplicate declaration somewhere.  clicking on the errors does not point to any code specifically though.

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Orob: Here is a PSOC 4 program that can read an accelerometer that comes on the Psoc_044 kit. It may give you some ideals on how to read the accelerometer using the PSOC 4.

Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Your error was to define variavles

   

uint8 devAddr;
uint8 bufferM[22];

   


within a .h file. Declare them as external and define them in mpu6050.c Compiles without any errors.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thanks Bob!!  I changed them to extern in the .h file and it worked.  So the key to porting is the cytypes.h file to save from changing all the variable types.  Now I'm going to wire it up and see if it actually works.  Thanks to bobgoar and pavloven also for taking time to look into the project.  Guys, I really appreciate you helping me get past this to move forward.