123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- /**********************************************************************
- * © 2010 Microchip Technology Inc.
- *
- * FileName: SSL_MarchCRamTest.c
- * Dependencies: Header (.h) files if applicable, see below
- * Processor: PIC18
- * Compiler: C18 v3.41
- *
- * SOFTWARE LICENSE AGREEMENT:
- * Microchip Technology Inc. (“Microchip”) licenses this software to you
- * solely for use with Microchip PIC® microcontroller
- * products. The software is owned by Microchip and is protected under
- * applicable copyright laws. All rights reserved.
- *
- * SOFTWARE IS PROVIDED “AS IS.” MICROCHIP EXPRESSLY DISCLAIMS ANY
- * WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP
- * BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL
- * DAMAGES, LOST PROFITS OR LOST data, HARM TO YOUR EQUIPMENT, COST OF
- * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
- * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
- * ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS.
- *
- * REVISION HISTORY:
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * Author Date Comments on this revision
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * CT 09/15/2008 First release of source file
- * Mike Cahill 11/11/2010 Updated for HI-TECH v9.80
- * MVL 02/22/2011 Modified for HI-TECH v9.81 & HI-TECH v9.80
- * VR 07/11/2012 Downgrade to C18
- *
- * Version 1.03
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * ADDITIONAL NOTES:
- *
- **********************************************************************/
- #include "SSL_Class_B_Tests.h"
- #pragma idata RAMFIX2=0xE10
- uint16_t j=0;
- uint8_t *dataC = (uint8_t *)MARCHC_RAM_START_ADDRESS;
- /*******************************************************************
- * Description:
- * This function that implements the MarchC test.
- * This test is a destructive test !!!
- * Input:
- * dataC[] : pointer to an array declared in user memory
- * MAX_MEM : value indicating the number of bytes to test
- * Return Values:
- * FAIL : return value = 0
- * PASS : return value = 1
- *
- *******************************************************************/
- uint8_t SSL_RAMtest_MarchC( void )
- {
- volatile uint8_t testResult;
- //***********************************************
- for(j=0;j<=(MAX_MEM_C-1);j++)
- {
- dataC[j]=0x00;
- }
- //***********************************************
- for(j=0;j<=(MAX_MEM_C-1);j++)
- {
- testResult = ReadZeroWriteOne( );
- if(!testResult)
- return MARCHC_RAM_TEST_FAIL;
- }
- //************************************************
- for(j=0;j<=(MAX_MEM_C-1);j++)
- {
- testResult = ReadOneWriteZero( );
- if(!testResult)
- return MARCHC_RAM_TEST_FAIL;
- }
- //************************************************
- for(j=0;j<=(MAX_MEM_C-1);j++)
- {
- testResult = ReadZero( );
- if(!testResult)
- return MARCHC_RAM_TEST_FAIL;
- }
- //***********************************************
- for(j=(MAX_MEM_C-1);j>0;j--)
- {
- testResult = ReadZeroWriteOne( );
- if(!testResult)
- return MARCHC_RAM_TEST_FAIL;
- }
- // do this once more time for zero
- testResult = ReadZeroWriteOne( );
- if(!testResult)
- return MARCHC_RAM_TEST_FAIL;
- //***********************************************
- for(j=(MAX_MEM_C-1);j>0;j--)
- {
- testResult = ReadOneWriteZero( );
- if(!testResult)
- return MARCHC_RAM_TEST_FAIL;
- }
- // do this once more time for zero
- testResult = ReadOneWriteZero( );
- if(!testResult)
- return MARCHC_RAM_TEST_FAIL;
- //***********************************************
- for(j=(MAX_MEM_C-1);j>0;j--)
- {
- testResult = ReadZero( );
- if(!testResult)
- return MARCHC_RAM_TEST_FAIL;
- }
- // do this once more time for zero
- testResult = ReadZero( );
- if(!testResult)
- return MARCHC_RAM_TEST_FAIL;
- //***********************************************
- return MARCHC_RAM_TEST_PASS;
- } // End of function
- /*******************************************************************
- * Description:
- * This function tests bitwise if a bit is zero and replaces it
- * with one.
- * Input:
- * *test_dataC : pointer to the byte to test
- * Return Values:
- * FAIL : return value = 0
- * PASS : return value = 1
- *
- *******************************************************************/
- uint8_t ReadZeroWriteOne( void )
- {
- volatile uint8_t r;
- volatile uint8_t imresult;
- for(r=0;r<8;r++)
- {
- if((dataC[j] >>r) & 0x01)
- {
- return MARCHC_RAM_TEST_FAIL;
- }
- else
- {
- imresult = 1<<r;
- dataC[j] += imresult;
- }
- }
- return MARCHC_RAM_TEST_PASS;
- }
- /******************************************************************
- * Description:
- * This function tests bitwise if a bit is one and replaces it
- * with zero.
- * Input:
- * *test_dataC : pointer to the byte to test
- * Return Values:
- * FAIL : return value = 0
- * PASS : return value = 1
- *
- ******************************************************************/
- uint8_t ReadOneWriteZero( void )
- {
- volatile uint8_t r;
- volatile uint8_t imresult;
- for(r=0u;r<8u;r++)
- {
- if(((dataC[j] >>r) & 0x01) != 0x01)
- {
- return MARCHC_RAM_TEST_FAIL;
- }
- else
- {
- imresult = ~(1<<r);
- dataC[j] &= imresult;
- }
- }
- return MARCHC_RAM_TEST_PASS;
- }
- /***********************************************************
- * Description:
- * This function tests bitwise if all bits are zeros .
- * Input:
- * *test_dataC : pointer to the byte to test
- * Return Values:
- * FAIL : return value = 0
- * PASS : return value = 1
- *
- ***********************************************************/
- uint8_t ReadZero( void )
- {
- volatile uint8_t r;
- for(r=0;r<8;r++)
- {
- if(dataC[j] != 0x00)
- {
- return MARCHC_RAM_TEST_FAIL;
- }
- }
- return MARCHC_RAM_TEST_PASS;
- }
|