123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- /*******************************************************************************
- Class B Implementation Test File
- Summary:
- This file contains the test program for the
- the Class B Safety Software on PIC18 MCUs.
- ********************************************************************************
- File: SSL_Demo2.c
- Processor: PIC18
- Compiler: Microchip MPLAB® C18 v3.41 or higher
- Author: Reiling
-
- Created on 11. Juli 2012, 10:58
- ******************************************************************************/
- #include "SSL_Demo.h"
- /*******************************************************************************
- Pragmas
- ******************************************************************************/
- #pragma config XINST = OFF
- #pragma config FOSC = HS1
- #pragma config WDTEN = OFF //OFF // SWDTDIS
- #pragma config WDTPS = 256 // WD TimeOut 1024ms
- #pragma config SOSCSEL = DIG // Port C, Pin 0 & 1 => Digital
- #pragma config PLLCFG = ON
- #pragma romdata CRCID=0x1000
- rom const uint16_t crc_Result_CONST = 0x5a83; /* EE-Prom CRC result constant */
- #pragma romdata
- /*******************************************************************************
- * Main SSL Demo
- ******************************************************************************/
- void main( void )
- {
- TESTFLAG testFlag = {0,0,0,0,0,0,0};
- uint16_t crc_Result = 0; // CRC values FLASH
- /************************ CPU REGISTER TEST ***********************************/
- if (SSL_CPU_RegisterTest()==CPU_REGISTER_TEST_PASS)
- {
- // the CPU registers don't have stuck bits
- testFlag.cpuRegister_TestResult = 1;
- }
- else
- {
- testFlag.cpuRegister_TestResult = 0;
- }
- /*********************** PROGRAM COUNTER TEST *********************************/
- if (SSL_PCtest()==PROGRAM_COUNTER_TEST_PASS)
- {
- // the PC register does not have stuck bits
- testFlag.programCounter_TestResult = 1;
- }
- else
- {
- testFlag.programCounter_TestResult = 0;
- }
- /**************************** RAM TESTS ***************************************/
- /********************** Checker Board RAM test ********************************/
- // Note that this test is not destructive. It has to NOT overlap the stack space!
- if (SSL_RAMtest_CheckerBoard( )==CB_TEST_PASS)
- {
- // the test succeeded and we are confident that the RAM area can be used
- testFlag.checkerboardRam_TestResult = 1;
- }
- else
- {
- testFlag.checkerboardRam_TestResult = 0;
- }
- /************************ March B RAM Test ************************************/
- if (SSL_RAMtest_MarchB() ==MARCHB_RAM_TEST_PASS)
- {
- // the test succeeded and we can go ahead and use the allocated memory
- testFlag.marchBRam_TestResult = 1;
- }
- else
- {
- testFlag.marchBRam_TestResult = 0;
- }
- /************************ March C RAM Test ************************************/
- if (SSL_RAMtest_MarchC() == MARCHC_RAM_TEST_PASS)
- {
- testFlag.marchCRam_TestResult = 1;
- }
- else
- {
- testFlag.marchCRam_TestResult = 0;
- }
- /************************ MarchC Minus RAM test *******************************/
- if (SSL_RAMtest_MarchCMinus() == MARCHCminus_RAM_TEST_PASS)
- {
- // if both tests succeeded we can go ahead and use the allocated memory
- testFlag.marchCMinusRam_TestResult = 1;
- }
- else
- {
- testFlag.marchCMinusRam_TestResult = 0;
- }
- /*************************** FLASH CRC TEST ***********************************/
- // This function can be called periodically and the generated checksum can be
- // compared with the reference checksum. Reference must be generated after
- // compile and written into "crc_Result_CONST". See above.
- crc_Result = SSL_FLASHtest_CRC( );
- // make sure that the periodic check is equal to the reference one
- if ( crc_Result==crc_Result_CONST)
- {
- testFlag.flash_TestResult=1;
- // we are confident that the data programmed in Flash
- // has not been altered in any way
- }
- else
- {
- testFlag.flash_TestResult=0;
- }
- }
|