Index: NVDataMgmt.c =================================================================== diff -u -rffc57967f1c97bd7d926214ef531e11dd0a22d40 -r284955146f177717e26854f0d978e461a3c6468c --- NVDataMgmt.c (.../NVDataMgmt.c) (revision ffc57967f1c97bd7d926214ef531e11dd0a22d40) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 284955146f177717e26854f0d978e461a3c6468c) @@ -905,12 +905,23 @@ // and 0 everything out since we are done writing if ( currentMessage == totalMessages ) { - U16 calcCRC = crc16 ( recordSpec.structAddressPtr, recordSpec.sizeofJob - sizeof(U16) ); + // Assume the institutional record is fine unless the record is really the institutional record + BOOL isInstRcrdValid = TRUE; + U16 calcCRC = crc16 ( recordSpec.structAddressPtr, recordSpec.sizeofJob - sizeof(U16) ); // Get the CRC of the structure without the last 16 bits which is the CRC as well as the padding values - U16 recordCRC = *(U16*)recordSpec.structCRCPtr; + U16 recordCRC = *(U16*)recordSpec.structCRCPtr; - if ( calcCRC != recordCRC ) +#ifdef _HD_ + if ( NVDATAMGMT_INTITUTIONAL_RECORD == job ) + { + isInstRcrdValid = isNVInstitutionalRecordInRange( &hdInstitutionalGroup.hdInstitutionalRecord ); + status = isInstRcrdValid; + } +#endif + + if ( ( calcCRC != recordCRC ) || ( FALSE == isInstRcrdValid ) ) { + // Institutional record has failed so do not write it into the NV memory and read back what was in the NV memory // CRC failed, request a read to read the data back from NV memory and update the structure enqueueRecordJob( NVDATAMGMT_READ, recordSpec.dataLoc, job ); @@ -919,17 +930,8 @@ } else { - // Assume the institutional record is fine unless the record is really the institutional record - BOOL isInstitutionalRecordValid = TRUE; - -#ifdef _HD_ - if ( NVDATAMGMT_INTITUTIONAL_RECORD == job ) + if ( NVDATAMGMT_EEPROM == recordSpec.dataLoc ) { - isInstitutionalRecordValid = isNVInstitutionalRecordInRange( &hdInstitutionalGroup.hdInstitutionalRecord ); - } -#endif - if ( ( NVDATAMGMT_EEPROM == recordSpec.dataLoc ) && ( TRUE == isInstitutionalRecordValid ) ) - { // CRC passed, enqueue an erase, a write of calibration data and a write of service record BOOL scheduleStatus = enqueueSector0Records();