waseem said:Hi!
The problem is in ur code. It should be like this
void main()
{
Usart_Init(9600);
Usart_Write('J');
while(1)
{
//your code goes here
};
}
Now this code will write the character 'J' only once and then enter the endless while loop. If you will not use this while loop then the processor will keep on initilizing the USART and sending the character 'J'.
The point is that the microcontroller should always be executing some code, in ur previous code the controller was doing nothing after the UsartWrtie('J'); function.
Regards.
waseem said:Hi!
Check your watch dog timer. It should be disabled. If it is not disabled then it will reset the device each time it timesout. It can disabled in the configuration fuses.
Regards.
aupa said:if the watchdog is activated and the time you had set to the watchdog timer overflows, then the PIC is reset. that's why its reset.
waseem said:Hi!
The watchdog timer is a simple protection against code lockup.If your code locks in an undesireable endless loop the watchdog timer overflows and resets the device. In your PC use you would have come across a situation in which the PC "hangs" and refuses to do anything. The only solution is to press the reset switch and thus restart the processor.
The watchdog timer in a controller does exactly that in an automatic manner.
Actually the watchdog is a simple timer that runs of an internal RC oscillator and is independent of the controller's main oscillator. It has a normal overflow time which is specified in the controllers data sheet. In some cases (e.g PIC) its overflow time can be changed by using a prescaler.
If the watchdog timer is enabled then we have to clear (make its counter zero) it repeatedly from time to time to prevent it from overflowing and thus generating a reset.The PIC assembly language has a special instruction for it CLRWD(clear watchdog).
If in our normal program flow we donot clear it then it will generate a reset signal which will reset the controller and the code will be once again executed right from the start (as was happeining in your case)
Hope this helps u understand.
Regards.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?