PSoC Creator Project Corruption(?) Problems with debugger

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

cross mob
Anonymous
Not applicable

I've got something going on with PSoC Creator, not sure exactly how to describe it.

   

I have a project that starts an I2C master and does a single transaction. But, when I run the code, I don't see any traffic. When I step into i2c_MasterWriteBuf in debug mode, the source level debugger takes me to a completely different file and eventually returns.

   

I have another project with the exact same code. When I run that project, the transaction appears on the bus and the debugger works as expected.

   

I've seen this happen once before. I was able to copy the code and schematic over to a new project, where things worked as expected.

   

 

   

Any ideas? I've tried doing a clean and rebuild, deleting and re-placing the I2C component, manually deleting the Generated Source and Cortex M3 directories, and copying the schematic and source to a new project.

0 Likes
1 Solution
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received


Please check is there's an "unused" *.c file in the project, then only the debugger does not work. As soon as you used a function from the related *.c file the debugger works.
 

View solution in original post

0 Likes
5 Replies
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

Please check the .cydwr settings in PSoC Creator  .i.e. Clocks ,System and Interrupts settings are matching between the two projects which you have mentioned.

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

Check the Project -> Build Settings -> Compiler -> Optimization and set them to 'None'. Helps debugging.

   

Check the pull up resistors of I2C interface.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I checked the System tab in .cydwr, both projects are identical.

   

Build settings are all default. I tried switching to Optimize: none, but that didn't seem to have any effect

   


I discovered that I can reproduce this odd behavior in the debugger by copying a source file into the project that had been working normally. The source doesn't need to be executed or even included in the output binary, just being included in the project is enough.

   


To be more precise about the odd debugger behavior that I'm seeing, when I step into the generated function i2c_MasterWriteBuf(), the debugger takes me to process_command() in the magic source file protocol.c, with PC=0x07d0. I don't think process_command() is included in the output binary... it shows up in the .map file as discarded:

   


Discarded input sections
  .text.process_cmd
                0x00000000      0x278 .\CortexM3\ARM_GCC_493\Debug\protocol.o
 .rodata.str1.4
                0x00000000       0x4c .\CortexM3\ARM_GCC_493\Debug\protocol.o

   


What might be interesting is that protocol.o overlaps with a 0x07d0 offset from the start of the .debug_abbrev area:

   


.debug_abbrev   0x00000000     0x18b2
  .debug_abbrev  0x00000652      0x228 .\CortexM3\ARM_GCC_493\Debug\protocol.o
  .debug_abbrev  0x000014b2      0x13c .\CortexM3\ARM_GCC_493\Debug\StandaloneBlinkyRevA.a(i2c_MASTER.o)
 
.text           0x00000000      0x936
  .text.i2c_MasterWriteBuf
                0x000007c8       0xcc .\CortexM3\ARM_GCC_493\Debug\StandaloneBlinkyRevA.a(i2c_MASTER.o)
                0x000007c8                i2c_MasterWriteBuf
 *fill*         0x00000894        0x4

 
one other thing,
process_cmd() is a gigantic switch/case statement. I found that if I comment out a certain subset of the case blocks (not just one, they all need to be removed) everything works normally again. Not sure how this would be affecting the debugger... syntax is valid and I'm not doing anything funky with the preprocessor.

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received


Please check is there's an "unused" *.c file in the project, then only the debugger does not work. As soon as you used a function from the related *.c file the debugger works.
 

0 Likes
Anonymous
Not applicable

That solved it! The debugger is working normally and the I2C API functions as expected.

   

I found that setting Build Options->Linker->Optimization->Remove Unused Sections:False also solved the problem.

   

It would be great to see a warning about this behavior added to the project output, since it's possible with the default build settings for valid code to behave incorrectly.

   

Thanks for your help!