furbz1977
Newbie level 2
- Joined
- May 11, 2015
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 25
Hello All,
I am new to this forum and trying to get a better understanding of WDTs. I need to write a code to generate a .48 second (480 mS) WDT, but looking at all the literature concerning the PIC16 there are only 8 options to set the WDT at. I understand that a 1:32 WDT rate equates to 576 mS (Bit: 100) which is CLOSE to 480 mS, however the next rate below 1:32 WDT= 280 mS (Bit: 011), but I'm not sure how I code it to 480 mS. One thing that is required in the delay code is to call three loops (inner, middle and outer), so do I call the three loops at different rates that would equal 480 mS? I've been trying to read a variety of sources to explain this better, but can't quite get a grasp of it. One sample code I saw that is written for .48 seconds is listed below but I don't understand how this calls a .48 second delay. Why code 0X4F to execute 29 times and code 0X7E to execute 126 times?
Any help in explaining this so I can understand would be greatly appreciated!
I am new to this forum and trying to get a better understanding of WDTs. I need to write a code to generate a .48 second (480 mS) WDT, but looking at all the literature concerning the PIC16 there are only 8 options to set the WDT at. I understand that a 1:32 WDT rate equates to 576 mS (Bit: 100) which is CLOSE to 480 mS, however the next rate below 1:32 WDT= 280 mS (Bit: 011), but I'm not sure how I code it to 480 mS. One thing that is required in the delay code is to call three loops (inner, middle and outer), so do I call the three loops at different rates that would equal 480 mS? I've been trying to read a variety of sources to explain this better, but can't quite get a grasp of it. One sample code I saw that is written for .48 seconds is listed below but I don't understand how this calls a .48 second delay. Why code 0X4F to execute 29 times and code 0X7E to execute 126 times?
Any help in explaining this so I can understand would be greatly appreciated!
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 CLRF COUNT1 CLRF COUNT2 CLRF COUNT3 MOVLW 0X7E MOVWF COUNT3 LOOPOUT MOVLW 0X4F MOVWF COUNT2 LOOPMID MOVLW 0X4F MOVWF COUNT1 LOOPIN DECFSZ COUNT1,F GOTO LOOPIN ; This will be executed 29 times DECFSZ COUNT2,F GOTO LOOPMID ; This loop will be executed 29 times DECFSZ COUNT3,F GOTO LOOPOUT ; This loop will be executed 126 times RETURN
Last edited by a moderator: