Archived
add PIC watchdog
This commit is contained in:
1 parent
32f1bd73b4
commit
e0b94c5250
6 files changed
+169
-41
No files matched your search
@@ -9,7 +9,6 @@ void main(void)
|
||||
{
|
||||
// Initialize the device
|
||||
SYSTEM_Initialize();
|
||||
|
||||
|
||||
// Disable the Global Interrupts
|
||||
// INTERRUPT_GlobalInterruptDisable();
|
||||
@@ -21,6 +20,7 @@ void main(void)
|
||||
Factory_init();
|
||||
Factory_build();
|
||||
Factory_start();
|
||||
//WWDT_SoftEnable();
|
||||
|
||||
// let the XF timers handling become the TMR0 interrupt handler
|
||||
// this means that the XF timers are always decremented when the
|
||||
@@ -33,6 +33,7 @@ void main(void)
|
||||
while (1)
|
||||
{
|
||||
//handle the next event if there is any in the queue
|
||||
WWDT_TimerClear();
|
||||
XF_executeOnce();
|
||||
//maybe sleep a short while to save energy
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@
|
||||
#pragma config XINST = OFF // Extended Instruction Set Enable bit->Extended Instruction Set and Indexed Addressing Mode disabled
|
||||
|
||||
// CONFIG3L
|
||||
#pragma config WDTCPS = WDTCPS_31 // WDT Period selection bits->Divider ratio 1:65536; software control of WDTPS
|
||||
#pragma config WDTE = OFF // WDT operating mode->WDT Disabled; SWDTEN is ignored
|
||||
#pragma config WDTCPS = WDTCPS_6 // WDT Period selection bits->Divider ratio 1:2048
|
||||
#pragma config WDTE = SWDTEN // WDT operating mode->WDT enabled/disabled by SWDTEN bit
|
||||
|
||||
// CONFIG3H
|
||||
#pragma config WDTCWS = WDTCWS_7 // WDT Window Select bits->window always open (100%); software control; keyed access not required
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
@@ -57,6 +57,9 @@
|
||||
#include "tmr0.h"
|
||||
#include "ecan.h"
|
||||
|
||||
#define WDTCWS 7
|
||||
#define WDTCCS 48
|
||||
#define WDTCPS 12
|
||||
|
||||
|
||||
/**
|
||||
@@ -98,6 +101,84 @@ void OSCILLATOR_Initialize(void);
|
||||
*/
|
||||
void PMD_Initialize(void);
|
||||
|
||||
/**
|
||||
* @Param
|
||||
none
|
||||
* @Returns
|
||||
none
|
||||
* @Description
|
||||
Initializes the WWDT to the default states configured in the
|
||||
* MCC GUI
|
||||
* @Example
|
||||
WWDT_Initialize();
|
||||
*/
|
||||
void WWDT_Initialize(void);
|
||||
|
||||
|
||||
/**
|
||||
* @Param
|
||||
none
|
||||
* @Returns
|
||||
none
|
||||
* @Description
|
||||
Enable the WWDT by setting the SEN bit.
|
||||
* @Example
|
||||
WWDT_SoftEnable();
|
||||
*/
|
||||
void WWDT_SoftEnable(void);
|
||||
|
||||
/**
|
||||
* @Param
|
||||
none
|
||||
* @Returns
|
||||
none
|
||||
* @Description
|
||||
Disable the WWDT by clearing the SEN bit.
|
||||
* @Example
|
||||
WWDT_SoftDisable();
|
||||
*/
|
||||
void WWDT_SoftDisable(void);
|
||||
|
||||
/**
|
||||
* @Param
|
||||
none
|
||||
* @Returns
|
||||
none
|
||||
* @Description
|
||||
Disable the interrupt, arm the WWDT by reading back the WDTCON0 register
|
||||
* clear the WWDT and enable the interrupt.
|
||||
* @Example
|
||||
WWDT_TimerClear();
|
||||
*/
|
||||
void WWDT_TimerClear(void);
|
||||
|
||||
/**
|
||||
* @Param
|
||||
none
|
||||
* @Returns
|
||||
High --> WWDT reset has not occurred.
|
||||
* Low --> WWDT reset has occurred.
|
||||
* @Description
|
||||
Returns the status of whether the WWDT reset has occurred or not.
|
||||
* @Example
|
||||
if(WWDT_TimeOutStatusGet())
|
||||
*/
|
||||
bool WWDT_TimeOutStatusGet(void);
|
||||
|
||||
/**
|
||||
* @Param
|
||||
none
|
||||
* @Returns
|
||||
High --> WWDT window violation reset has not occurred.
|
||||
* Low --> WWDT window violation reset has occurred.
|
||||
* @Description
|
||||
Returns the status of, whether the WWDT window violation
|
||||
* reset has occurred or not.
|
||||
* @Example
|
||||
if(WWDT_WindowViolationStatusGet())
|
||||
*/
|
||||
bool WWDT_WindowViolationStatusGet(void);
|
||||
|
||||
|
||||
#endif /* MCC_H */
|
||||
/**
|
||||
|
||||
@@ -224,6 +224,7 @@
|
||||
<property key="debugoptions.useswbreakpoints" value="false"/>
|
||||
<property key="event.recorder.enabled" value="false"/>
|
||||
<property key="event.recorder.scvd.files" value=""/>
|
||||
<property key="firmware.download.all" value="false"/>
|
||||
<property key="hwtoolclock.frcindebug" value="false"/>
|
||||
<property key="lastid" value=""/>
|
||||
<property key="memories.aux" value="false"/>
|
||||
|
||||
@@ -1948,7 +1948,7 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<key class="com.microchip.mcc.core.tokenManager.CustomKey" moduleName="DMA Manager" name="dmaTable"/>
|
||||
<value>{"dataArray":[{"DMA Channels":{"data":{"isDisable":"true","options":"--NONE--","text":"DMA CHANNEL1","value":"false"},"id":"DMA Channels_rowCount_0"},"Src Module":{"data":{"isDisable":"true","options":"--NONE--,MEMORY,ECAN,TMR0","text":"--NONE--","value":"--NONE--"},"id":"Src Module_rowCount_0"},"Src Region":{"data":{"isDisable":"true","options":"SFR#disabled,GPR#enabled,Program Flash#enabled,Data EEPROM#enabled","text":"GPR","value":"GPR"},"id":"Src Region_rowCount_0"},"Src SFR":{"Src SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Src SFR_rowCount_0"},"Src VarName":{"data":{"isDisable":"true","options":"","text":"SrcVarName0","value":"SrcVarName0"},"Src VarName":{"isDisable":"true","options":"","text":"SrcVarName0","value":"SrcVarName0"},"id":"Src VarName_rowCount_0"},"Src VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Src VarSize_rowCount_0","Src VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Src Address":{"data":{"isDisable":"true","options":"","text":"Enter Address0","value":"Enter Address0"},"id":"Src Address_rowCount_0","Src Address":{"isDisable":"true","options":"","text":"Enter Address0","value":"Enter Address0"}},"Src Mode":{"Src Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Src Mode_rowCount_0"},"Src Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Src Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Src Message Size_rowCount_0"},"Dst Module":{"data":{"isDisable":"true","options":"--NONE--,MEMORY,ECAN,TMR0","text":"--NONE--","value":"--NONE--"},"id":"Dst Module_rowCount_0"},"Dst Region":{"data":{"isDisable":"true","options":"SFR,GPR","text":"GPR","value":"GPR"},"id":"Dst Region_rowCount_0"},"Dst SFR":{"Dst SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Dst SFR_rowCount_0"},"Dst VarName":{"data":{"isDisable":"true","options":"","text":"DstVarName0","value":"DstVarName0"},"Dst VarName":{"isDisable":"true","options":"","text":"DstVarName0","value":"DstVarName0"},"id":"Dst VarName_rowCount_0"},"Dst VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Dst VarSize_rowCount_0","Dst VarSize":{"isDisable":"true",&Line truncated
|
||||
<value>{"dataArray":[{"DMA Channels":{"data":{"isDisable":"true","options":"--NONE--","text":"DMA CHANNEL1","value":"false"},"id":"DMA Channels_rowCount_0"},"Src Module":{"data":{"isDisable":"true","options":"--NONE--,TMR0,MEMORY,ECAN","text":"--NONE--","value":"--NONE--"},"id":"Src Module_rowCount_0"},"Src Region":{"data":{"isDisable":"true","options":"SFR#disabled,GPR#enabled,Program Flash#enabled,Data EEPROM#enabled","text":"GPR","value":"GPR"},"id":"Src Region_rowCount_0"},"Src SFR":{"Src SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Src SFR_rowCount_0"},"Src VarName":{"data":{"isDisable":"true","options":"","text":"SrcVarName0","value":"SrcVarName0"},"Src VarName":{"isDisable":"true","options":"","text":"SrcVarName0","value":"SrcVarName0"},"id":"Src VarName_rowCount_0"},"Src VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Src VarSize_rowCount_0","Src VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Src Address":{"data":{"isDisable":"true","options":"","text":"Enter Address0","value":"Enter Address0"},"id":"Src Address_rowCount_0","Src Address":{"isDisable":"true","options":"","text":"Enter Address0","value":"Enter Address0"}},"Src Mode":{"Src Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Src Mode_rowCount_0"},"Src Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Src Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Src Message Size_rowCount_0"},"Dst Module":{"data":{"isDisable":"true","options":"--NONE--,TMR0,MEMORY,ECAN","text":"--NONE--","value":"--NONE--"},"id":"Dst Module_rowCount_0"},"Dst Region":{"data":{"isDisable":"true","options":"SFR,GPR","text":"GPR","value":"GPR"},"id":"Dst Region_rowCount_0"},"Dst SFR":{"Dst SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Dst SFR_rowCount_0"},"Dst VarName":{"data":{"isDisable":"true","options":"","text":"DstVarName0","value":"DstVarName0"},"Dst VarName":{"isDisable":"true","options":"","text":"DstVarName0","value":"DstVarName0"},"id":"Dst VarName_rowCount_0"},"Dst VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Dst VarSize_rowCount_0","Dst VarSize":{"isDisable":"true",&Line truncated
|
||||
</entry>
|
||||
<entry>
|
||||
<key class="com.microchip.mcc.core.tokenManager.CustomKey" moduleName="ECAN" name="ECAN_ERRIISRFunction"/>
|
||||
@@ -16508,7 +16508,7 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<key class="com.microchip.mcc.core.tokenManager.RegisterKey" moduleName="System Module" registerAlias="CONFIG3L"/>
|
||||
<value>31</value>
|
||||
<value>38</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key class="com.microchip.mcc.core.tokenManager.RegisterKey" moduleName="System Module" registerAlias="CONFIG4H"/>
|
||||
@@ -16604,11 +16604,11 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<key class="com.microchip.mcc.core.tokenManager.SettingKey" moduleName="System Module" registerAlias="CONFIG3L" settingAlias="WDTCPS"/>
|
||||
<value>WDTCPS_31</value>
|
||||
<value>WDTCPS_6</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key class="com.microchip.mcc.core.tokenManager.SettingKey" moduleName="System Module" registerAlias="CONFIG3L" settingAlias="WDTE"/>
|
||||
<value>OFF</value>
|
||||
<value>SWDTEN</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key class="com.microchip.mcc.core.tokenManager.SettingKey" moduleName="System Module" registerAlias="CONFIG4H" settingAlias="LVP"/>
|
||||
@@ -16976,7 +16976,7 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<key class="com.microchip.mcc.core.tokenManager.CustomKey" moduleName="WWDT" name="wwdtPeriod"/>
|
||||
<value>2.11406</value>
|
||||
<value>0.06606</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key class="com.microchip.mcc.core.tokenManager.OptionKey" moduleName="WWDT" registerAlias="PCON" settingAlias="nRWDT" alias="WDT reset has not occurred"/>
|
||||
@@ -17159,54 +17159,34 @@
|
||||
<value>Window delay time 87.5%</value>
|
||||
</entry>
|
||||
</tokenMap>
|
||||
<generatedFileHashHistoryMap class="java.util.TreeMap">
|
||||
<generatedFileHashHistoryMap class="java.util.HashMap">
|
||||
<entry>
|
||||
<file>main.c</file>
|
||||
<hash>cae37ae3b36cf22e97e106633433f5c00a66dd5d38ec353eb67fbbb0d88bde4d</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\device_config.c</file>
|
||||
<hash>39a6d1181ef5eab59c7dde2c52a9ea889465d4da43262200f3322abc45e77739</hash>
|
||||
<file>mcc_generated_files\mcc.h</file>
|
||||
<hash>7dd04034216f3c639fcfb88387572f995d54189bb8fb587a3401371ec2651c65</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\device_config.h</file>
|
||||
<hash>89c6172ff575ce515b93f2fbc85dcedc2978e58a8e0e1fbdc52e42511ae3bc05</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\ecan.c</file>
|
||||
<hash>ea62f50d319e1e537d7632774728ad6a779f442e896d043dbdea8066d028a6c6</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\ecan.h</file>
|
||||
<hash>aa9a50aae81bab76b876ea6123777af7d6a6d0a58fe953be27e8b88776395b2e</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\interrupt_manager.c</file>
|
||||
<hash>df04edcd2c7d85ef90a8dbe4e46f1b1c9487b872153f4f2321249a4ce0d9635f</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\interrupt_manager.h</file>
|
||||
<hash>9c2f1ae45f2ac887bb3e8b3763e1a394a6a22ffe4e9ae1c20c336fe6f12da1aa</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\mcc.c</file>
|
||||
<hash>cc9ed44843b509879e6a3f676b561ecde91e1df88d855cf7eca77e1afc8920ca</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\mcc.h</file>
|
||||
<hash>a2db7e36e878f686c2bf0c2ef586ef1c6570fa2f27119b4be7b52af6403091a4</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\memory.c</file>
|
||||
<hash>17fb4759c4719b77287f6c4be48edfbcf117b5b8398b771c434f23aceac256e0</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\memory.h</file>
|
||||
<hash>fbbca4e9d7ce92ddcc637d82b694a1f5cbefa75710a8a18bb1dc9ab5161f0924</hash>
|
||||
<file>mcc_generated_files\tmr0.h</file>
|
||||
<hash>6661ab783aae9f11e952805f9bca14209ec06551939552123056eefd5524fff8</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\pin_manager.c</file>
|
||||
<hash>04b16a3d3fcbbb333ee6fb545a405b76aba47ef3935be548bf2b8165c43c5654</hash>
|
||||
<file>main.c</file>
|
||||
<hash>cae37ae3b36cf22e97e106633433f5c00a66dd5d38ec353eb67fbbb0d88bde4d</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\device_config.c</file>
|
||||
<hash>ac2a2ad923df635be3b193de8878c95bc16cfb8c91d37b98c4c1a4a1e0e6b990</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\pin_manager.h</file>
|
||||
@@ -17217,8 +17197,28 @@
|
||||
<hash>e0b4d075e819024ae77ea60a2c01182fdca45b783980cb50358d0a614736339d</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\tmr0.h</file>
|
||||
<hash>6661ab783aae9f11e952805f9bca14209ec06551939552123056eefd5524fff8</hash>
|
||||
<file>mcc_generated_files\pin_manager.c</file>
|
||||
<hash>04b16a3d3fcbbb333ee6fb545a405b76aba47ef3935be548bf2b8165c43c5654</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\ecan.c</file>
|
||||
<hash>ea62f50d319e1e537d7632774728ad6a779f442e896d043dbdea8066d028a6c6</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\mcc.c</file>
|
||||
<hash>a1b3e2d6ddc04b8a97973fcb818a7243d9723f4763c2c496b4b2eb1aa06ad645</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\interrupt_manager.c</file>
|
||||
<hash>df04edcd2c7d85ef90a8dbe4e46f1b1c9487b872153f4f2321249a4ce0d9635f</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\memory.h</file>
|
||||
<hash>fbbca4e9d7ce92ddcc637d82b694a1f5cbefa75710a8a18bb1dc9ab5161f0924</hash>
|
||||
</entry>
|
||||
<entry>
|
||||
<file>mcc_generated_files\ecan.h</file>
|
||||
<hash>aa9a50aae81bab76b876ea6123777af7d6a6d0a58fe953be27e8b88776395b2e</hash>
|
||||
</entry>
|
||||
</generatedFileHashHistoryMap>
|
||||
</config>
|
||||
Reference in new issue
Block a user