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.
Check the Project -> Build Settings -> Compiler -> Optimization and set them to 'None'. Helps debugging.
Check the pull up resistors of I2C interface.
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
0x00000000 0x278 .\CortexM3\ARM_GCC_493\Debug\protocol.o
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
0x000007c8 0xcc .\CortexM3\ARM_GCC_493\Debug\StandaloneBlinkyRevA.a(i2c_MASTER.o)
*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.
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.
1 of 1 people found this helpful
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!