Introduction
Debugging is a process of systematically double-checking your assumptions, because if everything was correct then it would be working. See below for some common symptoms and possible debugging remedies.
Common Issues
My PSoC port isn't working
- Try a different port
- Check that the pin is set up correctly according to the assignment instructions
- The above is correct but still not working? Check the continuity of the pins to ensure the soldering quality is not causing the problem
My program won't build (Code errors)
- Does every open curly bracket ({) have a closing partner (})?
- Does every statement (not condition or loop) have a semi-colon (;)?
- Were the functions called correctly?
- Are the loops/conditional statements written correctly?
- Read the error logs from the earliest error.
- Use the line numbers in the error logs to find out where, and the message to tell what the error might be (missing ;, {, }, incorrect function name (PIN_NAME_functionname()), missing parenthesis around the if condition, missing parenthesis to signify a function, etc.)
My program won't build (Top Design/Pin setup errors)
- Are the pins and other components set up as instructed by the assignment?
- Check the connection(s) of components and the PWM module
- Check that the port/pin is able to do PWM through the pin/port setup dropdown
- Choose a different LED/button
- Ensure components were set up in PSoC Creator as instructed by the assignment
- Did you try the onboard LEDs or the LEDs near the CapSense pads? Either should work
- Test the pieces individually/one at a time (i.e. just the LED blinking, then turn on the LED when the button is pushed/held, etc.) before combining them
- Is there power?
- Is the circuit complete?
- Are the pins set up correctly in PSoC Creator?
- Are the anode/cathode of the LED in the correct orientation? (Current flows in the direction of the arrow in an LED).
- Check that there isn't a short in the circuit
- Check the resistor(s) being used are the correct ones
- Use a different external LED
- Use a different external button
- Is a wire broken?
- Try making the onboard LED work with the external button
- Try making the external LED work without the external button
- Try making the button work on its own using an onboard LED
- If none of the above resolve the issue, create a new PSoC project from scratch and redo the part
My code doesn't work as it should
- Confirm line by line what makes sense/is supposed to be there
- Swap/flip values (trial by experimentation)
- Try isolating pieces of the code to debug it a little bit at a time (i.e. just the LED flip, then just the dot of the morse code, etc.)
- Read the code aloud to someone even if they don't understand to find tiny human mistakes (see also: rubber ducking)
- Chances are the code does exactly what you tell it. So maybe you're not telling it what to do in the right order, otherwise, check your wiring for external components
My LED on/off values are inverted?
- Make sure your LEDs are set up correctly in PSoC Creator
Nothing works/I've tried everything here
- Try starting a new project and redo everything (carefully)
Checklist
Category |
Item |
Soldering |
Is it a good solder joint? (no bubble/balls of solder, solder isn't touching anything but the pin and the pad, can't see through the other side of the pinhole, nothing is loose/wiggling, solder joints are shiny rather than dull) |
|
Do all pins have continuity? (test with multimeter) |
Coding |
Is the code readable/well formatted? (makes debugging easier) |
|
Do you know what every line of code does? Does every line of code make sense? (makes understanding behavior easier) |
|
Does every line function as it is intended? (avoid unexplainable behavior) |
|
Do the variables have datatypes (make like match with like to avoid warnings and errors) |
|
Do the loops have entry/break conditions (excluding for;;) (have conscious and complete control of loops) |
|
Use read functions as intended: read, check, or save values |
|
Use write functions as intended: write values to pins |
Circuit |
Do all components function independently (to ensure no broken/dead pieces) |
|
Are there any shorts? |
PSoC |
Configured pin names match names used in code? |
|
Using pins that can provide the intended functionality? |
|
Everything is connected where it should be (line to pin, clock to PWM) |