milan.rajik
Banned
- Joined
- Apr 1, 2013
- Messages
- 2,524
- Helped
- 540
- Reputation
- 1,078
- Reaction score
- 524
- Trophy points
- 1,393
- Activity points
- 0
I am using PIC18F45K22 with 4 MHz external resonator. I am testing the project in both Proteus and hardware (EasyPIC 7). The code is mikroC PRO PIC code. Please see attached image. It shows my WDT configuration and the piece of code which is resetting WDT every 6 to 7 seconds.
The code of CLEAR_WDT() function is as below.
The keypad function is a non blocking function and so the program will be executing the do{ }while(!kp) loop. The program works fine in Proteus but in hardware WDT is resetting when it enters this do{...}while(!kp) loop.
I have used stop watch to check the time taken to execute this loop once and it is 160 us and WDT is cleared in this loop every 160 us but WDT is resetting the PIC.
If I disable WDT then program works fine in hardware.
Edit: Here is the latest hex file of the project. The proteus file of the project is attached here.
It works fine in Proteus. I have tested for 10 minutes in Proteus and WDT doesn't reset but in hardware WDT is resetting every 13 seconds.
The code of CLEAR_WDT() function is as below.
Code:
void CLEAR_WDT() {
_asm clrwdt;
}
The keypad function is a non blocking function and so the program will be executing the do{ }while(!kp) loop. The program works fine in Proteus but in hardware WDT is resetting when it enters this do{...}while(!kp) loop.
I have used stop watch to check the time taken to execute this loop once and it is 160 us and WDT is cleared in this loop every 160 us but WDT is resetting the PIC.
If I disable WDT then program works fine in hardware.
Edit: Here is the latest hex file of the project. The proteus file of the project is attached here.
It works fine in Proteus. I have tested for 10 minutes in Proteus and WDT doesn't reset but in hardware WDT is resetting every 13 seconds.
Attachments
Last edited: