What can make a code to stop running?

Status
Not open for further replies.

alphadog

Banned
I have a pcb which contains MCU (CC2430) and the MCU operates LED and Relay driver and other chips (like memory).
As long as the code runs, the LED toggles every 1sec and the relay is switched every 20sec, using 2 GPIOs that operate driver circuit.
The relay itself switches hight current loads (used today 10A loads).

For somereason, in one of the switches of the relay, the code got stucked - The led stopped toggling (one time it remined on, other time it remained off, depending when the code stopped) and relay wasnt switched anymore.

I dont understand why it happened.
Do you have any idea?

Thanks in advance.

P.S.
Its not that the MCU had a reset (like POR), because in that case the led would have kept being toggled (and relay would have kept being switched).
 
Last edited:
If its stopping like that, my first guess would be the xtal. A bad connection, or some type of interference affecting the clock.
 
I was working on a mini project, and sometimes my code would behave as you described. I thought it was a problem with the code, so I tried looking at it and trying to figure out what was wrong...but couldnt. I started playing with components, and I determined it was something to do with my xtal. I tried replacing it, and such, but it turned out to be a combination of a bad xtal and a bad breadboard that just clipping onto the leads.
 

Thanks a lot for sharing.
What do you mean by "clipping onto the leads"?

My cristal is not as close as possible to MCU (few cm distance), because that was designed by reference design on datasheet.
How could it be a problem with that?

I must say that sometimes the LED kept toggling but the relay stopped from switching, do you have any idea why? (The relay drivers require as much current as the led requires).
 
****,....... I have a hundred ideas!

1. Your code might be wrong.
2. You might have a problem with noise on the power supply lines.
3. The PC Board might have an error, or a cold solder joint.
4. You might not have accounted for the inductive kick from turning the relay off........causing a noise spike.

I could go on forever, but my time has value!

Maybe you could provide a wee bit more information so that we can perhaps narrow it down?

You know, the basic stuff......like:

1. Do you have a schematic?
2. Did you build this circuit yourself?
3. Did you write the code?
4. Do you know have an oscilloscope, and know how to use it?

We aren't Psychic here......some of us want to help. But you are going to have to try harder to describe the problem.

Troubleshooting Electronic/Electrical problems involves detective work.

But even the best detectives need facts and clues.
 

Who's thread is this?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…