add PIC watchdog
This commit is contained in:
		| @@ -53,6 +53,7 @@ void SYSTEM_Initialize(void) | ||||
|     PMD_Initialize(); | ||||
|     PIN_MANAGER_Initialize(); | ||||
|     OSCILLATOR_Initialize(); | ||||
|     WWDT_Initialize(); | ||||
|     TMR0_Initialize(); | ||||
|     ECAN_Initialize(); | ||||
| } | ||||
| @@ -92,6 +93,50 @@ void PMD_Initialize(void) | ||||
| } | ||||
|  | ||||
|  | ||||
| void WWDT_Initialize(void) | ||||
| { | ||||
|     // Initializes the WWDT to the default states configured in the MCC GUI | ||||
|     WDTCON0 = WDTCPS; | ||||
|     WDTCON1 = WDTCWS|WDTCCS; | ||||
|      | ||||
| } | ||||
|  | ||||
| void WWDT_SoftEnable(void) | ||||
| { | ||||
|     // WWDT software enable.  | ||||
|     WDTCON0bits.SEN=1; | ||||
| } | ||||
|  | ||||
| void WWDT_SoftDisable(void) | ||||
| { | ||||
|     // WWDT software disable. | ||||
|     WDTCON0bits.SEN=0; | ||||
| } | ||||
|  | ||||
| bool WWDT_TimeOutStatusGet(void) | ||||
| { | ||||
|     // Return the status of WWDT time out reset. | ||||
|     return (PCON0bits.nRWDT); | ||||
| } | ||||
|  | ||||
| bool WWDT_WindowViolationStatusGet(void) | ||||
| { | ||||
|    // Return the status of WWDT window violation reset. | ||||
|     return (PCON0bits.nWDTWV);  | ||||
| }   | ||||
|  | ||||
| void WWDT_TimerClear(void) | ||||
| { | ||||
|     // Disable the interrupt,read back the WDTCON0 reg for arming,  | ||||
|     // clearing the WWDT and enable the interrupt. | ||||
|     uint8_t readBack=0; | ||||
|      | ||||
|     bool state = GIE; | ||||
|     GIE = 0; | ||||
|     readBack = WDTCON0; | ||||
|     CLRWDT(); | ||||
|     GIE = state; | ||||
| } | ||||
| /** | ||||
|  End of File | ||||
| */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user