Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] My Device hangs and is not transimitting any data from serial Port PIC18F4550???

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
Activity points
10,591
Hello!! Everyone i am using PIC18F4550 in my device.

In this device there are two Software Serial Ports.
And One Internal Hardware UART of PIC18F4550..

My Device works okay during my testing stage but it hangs when connected physically in real environment for long time..

Till now it works perfectly for 4 Days..

But some times Hangs and it not transmit any data..

The objective of this Device is simple..
It collects Serial Data from two Units Connected to two Software UART and then combines the data and transmit it from the Hardware UART...

But after sometimes it hangs i don't know what is the problem which causes my unit to hang..

I want to know the possible reasons of hanging with PIC Micro-Controllers..

Hoping an Earliest Possible Reply..
Thanks in Advance
 

Make sure that you have interrupt handler routines defined for all possible interrupts. You might be getting a spurious interrupt somewhere for which you have no handling routine.
 
I want to know the possible reasons of hanging with PIC Micro-Controllers..


Hi,

When it hangs so infrequently its so difficult to find the cause.

It could be in your program code, only causing a problem when it has to handle certain input data values.
It could be interference affecting the circuit board, you have got it on a pcb ?
Also the power supply, how good its that ? Have you tried running it on batteries to eliminate mains problems ?

Probably worth while building software traps and logs into your code.

I created a Resets log so everytime the micro restarts it records the fact in eeprom and shows the number of such events on the lcd.

Are you using the Watchdog incase your code is getting lost /stuck somewhere ?
 
Thanks for your reply..
I am just using timer interrupt and all other interrupts are disabled...

I am having this circuit on hobbyist board (vero board or zero pcb) no professional pcb.

And i am having Meanwell 5V supply, through which i am powering my controller..

Can anyone tell me how to create log in my case because in this i have to restart the unit, it just hangs out without doing any thing..

Also tell me what is the use WDT, i had disabled that...
What i thought of watchdog timer....
it will perform a reset of controller when the unit hangs...

Please someone suggest me some solutions regarding this...
or how to record the problem..
 

Hi,

Cannot help you with the detailed coding as I think you use C ..?

Basically when you start the pic, as soon as it goes to your main code you increment a file called say COUNTER1 in EEprom.
You can then display that file on your lcd or leds etc so it shows how many times the Pic has been Reset due some problem.
Its a good way to tell if there has been a main failure or some interfence has caused a reset.
If you have not got a lcd in use, you could read back eerpom memory with your programmer to see COUNTER1s value.

The Watchdog is basically a free running timer, when it gets to the end of its count / timeout it causes a software reset of the micro and sends the program counter back to 0x0000
If activated, then within with timeout period you must regularly keep clearing the watchdog back to zero, if your program gets stuck in a loop then it will not be able to clear the watchdog so it overflows and Resets the Pic.

Just to give you an idea, I built a circuit on veroboard with hand wiring and the Resets counter showed several events in 24 hours.
A power relay was the cause, no amount of suppression overcame the problem.
I made a proper pcb and the circiut has run without any problems for weeks.

Long unshielded input leads are often a source of problems, they just act as an aerial.

hope that helps..
 
Hi,

Cannot help you with the detailed coding as I think you use C ..?

Basically when you start the pic, as soon as it goes to your main code you increment a file called say COUNTER1 in EEprom.
You can then display that file on your lcd or leds etc so it shows how many times the Pic has been Reset due some problem.
Its a good way to tell if there has been a main failure or some interfence has caused a reset.
If you have not got a lcd in use, you could read back eerpom memory with your programmer to see COUNTER1s value.

The Watchdog is basically a free running timer, when it gets to the end of its count / timeout it causes a software reset of the micro and sends the program counter back to 0x0000
If activated, then within with timeout period you must regularly keep clearing the watchdog back to zero, if your program gets stuck in a loop then it will not be able to clear the watchdog so it overflows and Resets the Pic.

Just to give you an idea, I built a circuit on veroboard with hand wiring and the Resets counter showed several events in 24 hours.
A power relay was the cause, no amount of suppression overcame the problem.
I made a proper pcb and the circiut has run without any problems for weeks.

Long unshielded input leads are often a source of problems, they just act as an aerial.

hope that helps..


Thanks it a nice suggestion...

I want to add watch dog timer into my project...
Will this restart my controller when it hangs and performs everything from the beginning...

If this is the case i will do this...

And test it..
thanks wp100..

Will report soon and will also try to implement the eeprom based log system...
 

If the hardware UART is attached to a device which logs data, you might also consider sending debug info at various points in the code.

Doing so might help narrow down exactly at what point in the code the system hangs.

You could also log various parameters related to the current state of the system which might provide a clue as to why the system hangs.


BigDog
 

Will this restart my controller when it hangs and performs everything from the beginning...


The WatchDog will restart your program code if thats where it gets stuck, don't forget you need to go though all your code refereshing the watchdog.
These tutorials might make things clearer.
https://hobbyprojects.com/pic_tutorials/tutorial13.html


As you say, if it can run for days there is a chance it might be electrical interference which stops the Pic; will the watchdog timer have any effect in that senario ?

If the software doe not clear the fault, then look at running the board on battery power and also place the whole board in a metal tin thats connected to Earth to see if either of those cures the problem.

No idea of your complete circuit but does it have any relays etc that are switching mains voltages or anything likely to create electrical interference ?

Don't forget the more obvious things like a couple of the boards wires touching and shorting or some poor soldered joint loosing contact when the board receives some movement or temperature change.
 
Thanks for your help...

Due to this problem, i thought i would be better to make one such pcb and replace that pcb with the one which creates problem..

But i make this pcb on vero board, it hangs very frequently..
I thought may be i had used another IC in place of MAX232... I used 238 having 4 ports..

But when i place 0.1uf Capacitor between Vcc and Gnd
also
10uf capacitor between MCLR and Ground it works perfectly..

Means this can also be the problem..

One thing more when i change the the configuration setting
Code:
#pragma WDT ON
My Controller gets restarted and When i use
Code:
#pragma WDT OFF

It hangs and continues to hang...
Then why should i refresh Watch Dog timer Register...
I don't know the difference between these two techniques.. are they same..

Actually i am using Timer-0 and some of its settings are associated with Timer-0 thats why don't excatly know what to do...

Please tell me the difference between watch dog timer when setting from configuration bits and when through programming..
 

I just used watch dog timer in my controller by using these lines

#pragma config WDT = ON
#pragma config WDTPS = 35768

My controller gets constant reset after 2 min approx
and when changing this value to
#pragma config WDTPS = 16384
My Controller gets constant reset after 1 min approx..

I think, that i haven't refreshed my values in code...
As i don't know how to do so in my code..
Is there any register for this...

Pls reply soon thanks in advance..
 

Code:
__asm
CLRWDT
__endasm

either use this or the following statement
ClrWDT();
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top