update for Re boundary check and device index error
authorPeter Li <peter-li@ti.com>
Tue, 10 Jan 2017 17:22:29 +0000 (01:22 +0800)
committerPeter Li <peter-li@ti.com>
Tue, 10 Jan 2017 17:22:29 +0000 (01:22 +0800)
factorytest.c
speaker_l.ftcfg [moved from speaker.ftcfg with 79% similarity]
speaker_r.ftcfg [new file with mode: 0755]
tas2557.c
tas2557.h
tas2557_ftc.h
tas2557dm_ftc.c

index 0f0f8921d1e918eba912f8785c6ea50c7b757041..350c0ee06964ac38c4a0dbccd9f628edadea018f 100755 (executable)
@@ -70,27 +70,27 @@ void InitFTCC(TFTCConfiguration *pFTCC)
        pFTCC->nTSpkCharDevA.nSpkTMax = SPK_T_MAX;
        pFTCC->nTSpkCharDevA.nSpkReTolPer = SPK_RE_TOL_PER;
        pFTCC->nTSpkCharDevA.nSpkReAlpha = SPK_RE_ALPHA;
-       
+       pFTCC->nTSpkCharDevA.nReHi = PPC3_RE0*1.15;
+       pFTCC->nTSpkCharDevA.nReLo = PPC3_RE0*0.85;
        pFTCC->nTSpkCharDevA.nPPC3_Re0 = PPC3_RE0;
        pFTCC->nTSpkCharDevA.nPPC3_RTV = PPC3_RTV;
        pFTCC->nTSpkCharDevA.nPPC3_RTM = PPC3_RTM;
        pFTCC->nTSpkCharDevA.nPPC3_RTVA = PPC3_RTVA;
        pFTCC->nTSpkCharDevA.nPPC3_SysGain = PPC3_SYSGAIN;
        pFTCC->nTSpkCharDevA.nPPC3_DevNonlinPer = PPC3_DEV_NONLIN_PER;
-       
        pFTCC->nTSpkCharDevA.nDevAddr = DEV_A_I2C_ADDR;
        
        pFTCC->nTSpkCharDevB.nSpkTMax = SPK_T_MAX;
        pFTCC->nTSpkCharDevB.nSpkReTolPer = SPK_RE_TOL_PER;
        pFTCC->nTSpkCharDevB.nSpkReAlpha = SPK_RE_ALPHA;
-       
+       pFTCC->nTSpkCharDevB.nReHi = PPC3_RE0*1.15;
+       pFTCC->nTSpkCharDevB.nReLo = PPC3_RE0*0.85;     
        pFTCC->nTSpkCharDevB.nPPC3_Re0 = PPC3_RE0;
        pFTCC->nTSpkCharDevB.nPPC3_RTV = PPC3_RTV;
        pFTCC->nTSpkCharDevB.nPPC3_RTM = PPC3_RTM;
        pFTCC->nTSpkCharDevB.nPPC3_RTVA = PPC3_RTVA;
        pFTCC->nTSpkCharDevB.nPPC3_SysGain = PPC3_SYSGAIN;
        pFTCC->nTSpkCharDevB.nPPC3_DevNonlinPer = PPC3_DEV_NONLIN_PER;
-       
        pFTCC->nTSpkCharDevB.nDevAddr = DEV_B_I2C_ADDR;
 }
 
@@ -134,6 +134,8 @@ void ReadValue(TFTCConfiguration *pFTCC, TSPKCharData *pSpk, char *pLine, char *
        if (!strcmp(pLine, "PPC3_RTVA")) {pSpk->nPPC3_RTVA = atof(pValue); return;};
        if (!strcmp(pLine, "PPC3_SYSGAIN")) {pSpk->nPPC3_SysGain = atof(pValue); return;};
        if (!strcmp(pLine, "PPC3_DEV_NONLIN_PER")) {pSpk->nPPC3_DevNonlinPer = atof(pValue); return;};
+       if (!strcmp(pLine, "RE_HI")) {pSpk->nReHi = atof(pValue); return;};
+       if (!strcmp(pLine, "RE_LO")) {pSpk->nReLo = atof(pValue); return;};
        if (!strcmp(pLine, "DEV_ADDR")) {pSpk->nDevAddr = atoi(pValue); return;};
 }
 
similarity index 79%
rename from speaker.ftcfg
rename to speaker_l.ftcfg
index 30b2e6ec814b3581a3a1dca85c8e3ca8c311428f..6510893206eff733143015a71822ebd61bf18f07 100755 (executable)
@@ -9,14 +9,17 @@
 CALIBRATION_TIME          = 6000     ; Duration (in ms) of calibration phase\r
 CONFIGURATION             = 0        ; Refer to documentation\r
 CONFIGURATION_CALIBRATION = 2        ; Refer to documentation\r
-DEV_A_ADDR                               = 98           ; I2C slave write addr for device A\r
-DEV_B_ADDR                               = 9a       ; I2C slave write addr for device B\r
+DEV_ADDR                                 = 98           ; I2C slave write addr for device A\r
 \r
 ; Obtained from Speaker Manufacturer\r
 SPK_T_MAX                 = 80       ; Speaker Maximum Temperature (C)\r
 SPK_RE_TOL_PER            = 10       ; Re +/- tolerance (%)\r
 SPK_RE_ALPHA              = 0.0039   ; Temperature coefficient alpha (1/K)\r
 \r
+; Pass/Fail Limits\r
+RE_HI                     = 7.975\r
+RE_LO                     = 6.525\r
+\r
 ; Obtained from PurePath Console 3 (PPC3)\r
 PPC3_RE0                  = 7.49     ; Re0 (ohm)\r
 PPC3_RTV                  = 44.9     ; Rtv (K/W)\r
@@ -24,6 +27,4 @@ PPC3_RTM                  = 80.7     ; Rtm  (K/W)
 PPC3_RTVA                 = 1723     ; Rtva  (K/W)\r
 PPC3_SYSGAIN              = 9.35     ; System Gain (V/FS)\r
 PPC3_DEV_NONLIN_PER       = 1.5      ; Device Non-linearity (%)\r
-PPC3_DELTA_T_LIMIT        = 60       ; Delta Thermal Limit (C)\r
-FS_RATE                   = 48000    ; TAS2555 Sample Rate\r
 \r
diff --git a/speaker_r.ftcfg b/speaker_r.ftcfg
new file mode 100755 (executable)
index 0000000..dca1df1
--- /dev/null
@@ -0,0 +1,29 @@
+\r
+; TAS2557 Factory Test and Calibration Configuration File\r
+; -----------------------------------------------------------------------------\r
+; PPC3 File: example.ppc3\r
+; DDC Name: N48M1V2\r
+; Comments: [Write Comments Here]\r
+\r
+; FTC Settings\r
+CALIBRATION_TIME          = 6000     ; Duration (in ms) of calibration phase\r
+CONFIGURATION             = 0        ; Refer to documentation\r
+CONFIGURATION_CALIBRATION = 2        ; Refer to documentation\r
+DEV_ADDR                                 = 98           ; I2C slave write addr for device B\r
+\r
+; Obtained from Speaker Manufacturer\r
+SPK_T_MAX                 = 80       ; Speaker Maximum Temperature (C)\r
+SPK_RE_TOL_PER            = 10       ; Re +/- tolerance (%)\r
+SPK_RE_ALPHA              = 0.0039   ; Temperature coefficient alpha (1/K)\r
+\r
+; Pass/Fail Limits\r
+RE_HI                     = 7.975\r
+RE_LO                     = 6.525\r
+\r
+; Obtained from PurePath Console 3 (PPC3)\r
+PPC3_RE0                  = 7.49     ; Re0 (ohm)\r
+PPC3_RTV                  = 44.9     ; Rtv (K/W)\r
+PPC3_RTM                  = 80.7     ; Rtm  (K/W)\r
+PPC3_RTVA                 = 1723     ; Rtva  (K/W)\r
+PPC3_SYSGAIN              = 9.35     ; System Gain (V/FS)\r
+PPC3_DEV_NONLIN_PER       = 1.5      ; Device Non-linearity (%)
\ No newline at end of file
index 946a9f1ecc33ea2d3cc650d47622b5524f9f897e..a2eceba2b780b39936844c9784251fdcb95f04ca 100755 (executable)
--- a/tas2557.c
+++ b/tas2557.c
@@ -207,18 +207,36 @@ void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data)
        }
 }
 
-void tas2557_save_cal(double dev_a_re, uint32_t dev_a_rms_pow, uint32_t dev_a_t_limit, 
+void tas2557_save_cal(TFTCConfiguration *pFTCC, 
+       double dev_a_re, uint32_t dev_a_rms_pow, uint32_t dev_a_t_limit, 
        double dev_b_re, uint32_t dev_b_rms_pow, uint32_t dev_b_t_limit, 
-       double t_cal,  char * pFileName)
+       double t_cal,  uint32_t nResult, char * pFileName)
 {
        printf("TAS2557 calibration values:\n\r");
-       
        printf("    DevA Re = %1.2f Ohm\n\r", dev_a_re);
        printf("    DevA rms_pow       = 0x%08X\n\r", dev_a_rms_pow);
        printf("    DevA t_limit       = 0x%08X\n\r", dev_a_t_limit);
        printf("    DevB Re = %1.2f Ohm\n\r", dev_b_re);
        printf("    DevB rms_pow       = 0x%08X\n\r", dev_b_rms_pow);
        printf("    DevB t_limit       = 0x%08X\n\r", dev_b_t_limit);
+
+       if((nResult & RE1_CHK_MSK) == RESULT_PASS){
+               printf(" SPK A calibration success! \n\r");
+       }else {
+               if(nResult & RE1_FAIL_HI)
+                       printf(" SPK A Calibration fail : Re is too high (limit: %1.2f).\n\r", pFTCC->nTSpkCharDevA.nReHi);
+               else
+                       printf(" SPK A Calibration fail : Re is too low (limit: %1.2f).\n\r", pFTCC->nTSpkCharDevA.nReLo);
+       }
+       
+       if((nResult & RE2_CHK_MSK) == RESULT_PASS){
+               printf(" SPK B calibration success! \n\r");
+       }else {
+               if(nResult & RE2_FAIL_HI)
+                       printf(" SPK B Calibration fail : Re is too high (limit: %1.2f).\n\r", pFTCC->nTSpkCharDevB.nReHi);
+               else
+                       printf(" SPK B Calibration fail : Re is too low (limit: %1.2f).\n\r", pFTCC->nTSpkCharDevB.nReLo);
+       }
        
        FILE *pFile = fopen(pFileName, "w+");
        
@@ -229,6 +247,7 @@ void tas2557_save_cal(double dev_a_re, uint32_t dev_a_rms_pow, uint32_t dev_a_t_
        fprintf(pFile, "DevB rms_pow       = 0x%08X\n\r", dev_b_rms_pow);
        fprintf(pFile, "DevB t_limit       = 0x%08X\n\r", dev_b_t_limit);       
        fprintf(pFile, "Ambient temperature = %2.2f\n\r\n\r", t_cal);
+       fprintf(pFile, "Result = 0x%x\n\r\n\r", nResult);
 
        fclose(pFile);
 }
@@ -256,10 +275,15 @@ void tas2557_open_bin(char * pFileName, unsigned int nConfiguration,
        strcpy(&gpBin[24 + 64], "Calibration Data File for TAS2555");
 
        gnBinIndex += 24 + 64 + strlen(&gpBin[24 + 64]) + 1;
+
+       gnBinIndex += 4; //device family index
        
+       gpBin[gnBinIndex++] = 0; //device index
+       gpBin[gnBinIndex++] = 0; //device index
+       gpBin[gnBinIndex++] = 0; //device index
+       gpBin[gnBinIndex++] = 3; //device index, TAS2557 Dual Mono
+               
        gnBinIndex +=
-               4 +     //device family index
-               4 +     //device index
                2 +     //num PLL index
                0 +     //array PLL index
                2 +     //num programs index
@@ -335,3 +359,26 @@ void tas2557_close_bin(void)
 
        gBinFile = 0;
 }
+
+// ----------------------------------------------------------------------------- 
+// check_spk_bounds 
+// ----------------------------------------------------------------------------- 
+// Description: 
+//      Checks if speaker paramters are within bounds. 
+// ----------------------------------------------------------------------------- 
+uint32_t check_spk_bounds(TFTCConfiguration *pFTCC, double re1, double re2) 
+{ 
+    uint32_t result = RESULT_PASS; 
+    if(re1>pFTCC->nTSpkCharDevA.nReHi) 
+        result |= RE1_FAIL_HI; 
+    if(re1<pFTCC->nTSpkCharDevA.nReLo) 
+        result |= RE1_FAIL_LO; 
+   
+    if(re2>pFTCC->nTSpkCharDevB.nReHi) 
+        result |= RE2_FAIL_HI; 
+    if(re2<pFTCC->nTSpkCharDevB.nReLo) 
+        result |= RE2_FAIL_LO; 
+       
+    return result; 
+} 
index c1433366abf7220d3aaefc61261ef2cf25d4941e..fafdefb8701a35672717bb1311afc32c50c036cb 100755 (executable)
--- a/tas2557.h
+++ b/tas2557.h
@@ -27,6 +27,7 @@
 #define TAS2557_H_\r
 \r
 #include <stdint.h>\r
+#include "tas2557_ftc.h"\r
 \r
 #define TILOAD_IOC_MAGIC   0xE0\r
 \r
 #define TILOAD_IOCTL_SET_CONFIG                _IOW(TILOAD_IOC_MAGIC, 6, int)\r
 #define TILOAD_IOCTL_SET_CALIBRATION   _IOW(TILOAD_IOC_MAGIC, 7, int)\r
 \r
-extern void tas2557_load_configuration(int nConfiguration);\r
-extern void tas2557_load_calibration(int nCalibration);\r
-extern uint32_t tas2557_switch_device(uint8_t i2cslave);\r
-extern uint32_t tas2557_coeff_read(uint8_t book, uint8_t page, uint8_t reg);\r
-extern void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data);\r
-extern void tas2557_save_cal(double dev_a_re, uint32_t dev_a_rms_pow, uint32_t dev_a_t_limit, \r
+#define RESULT_PASS                    0x00000000 \r
+#define RE1_FAIL_HI         0x00000001 \r
+#define RE1_FAIL_LO         0x00000010 \r
+#define RE1_CHK_MSK         0x00000011 \r
+#define RE2_FAIL_HI         0x00000100 \r
+#define RE2_FAIL_LO         0x00001000 \r
+#define RE2_CHK_MSK         0x00001100\r
+\r
+void tas2557_load_configuration(int nConfiguration);\r
+void tas2557_load_calibration(int nCalibration);\r
+uint32_t tas2557_switch_device(uint8_t i2cslave);\r
+uint32_t tas2557_coeff_read(uint8_t book, uint8_t page, uint8_t reg);\r
+void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data);\r
+void tas2557_save_cal(TFTCConfiguration *pFTCC, \r
+       double dev_a_re, uint32_t dev_a_rms_pow, uint32_t dev_a_t_limit, \r
        double dev_b_re, uint32_t dev_b_rms_pow, uint32_t dev_b_t_limit, \r
-       double t_cal,  char * pFileName);\r
-extern void tas2557_open_bin(char * pFileName, unsigned int nConfiguration, \r
+       double t_cal, uint32_t,char * pFileName);\r
+uint32_t check_spk_bounds(TFTCConfiguration *pFTCC, double re1, double re2);   \r
+void tas2557_open_bin(char * pFileName, unsigned int nConfiguration, \r
        unsigned char dev_a, unsigned char dev_b);\r
-extern void tas2557_close_bin(void);\r
+void tas2557_close_bin(void);\r
 \r
 #endif /* TAS2557_H_ */\r
index 9b345c936141008c814875edf4fd49e1107febae..578b3844241657b5fc4b209b3e9d45088f3a383f 100755 (executable)
@@ -42,6 +42,9 @@ typedef struct
        double nPPC3_SysGain;\r
        double nPPC3_DevNonlinPer;\r
        \r
+       double nReHi;\r
+       double nReLo;\r
+       \r
        unsigned char nDevAddr;\r
 } TSPKCharData;\r
 \r
@@ -59,6 +62,6 @@ typedef struct
        \r
 } TFTCConfiguration;\r
 \r
-extern uint32_t tas2557_ftc(double t_cal, TFTCConfiguration *pFTCC);\r
+uint32_t tas2557_ftc(double t_cal, TFTCConfiguration *pFTCC);\r
 \r
 #endif /* TAS2557_FTC_H_ */\r
index 2f5ab4b4b2af763da6bbfcbbcd63c43bfb478f79..0a3725595eba5db452c577e720f69da512e79142 100755 (executable)
@@ -46,6 +46,7 @@ TFTCConfiguration *gpFTCC;
 // -----------------------------------------------------------------------------\r
 uint32_t tas2557_ftc(double t_cal, TFTCConfiguration *pFTCC)\r
 {\r
+       int nResult = 0;\r
     double dev_a_re = pFTCC->nTSpkCharDevA.nPPC3_Re0;   // Default Re\r
     uint32_t dev_a_prm_pow = 0;           // Total RMS power coefficient\r
     uint32_t dev_a_prm_tlimit = 0;        // Delta temperature limit coefficient\r
@@ -80,53 +81,70 @@ uint32_t tas2557_ftc(double t_cal, TFTCConfiguration *pFTCC)
        tas2557_switch_device(gpFTCC->nTSpkCharDevB.nDevAddr);\r
        dev_b_re = get_re(gpFTCC->nTSpkCharDevB.nPPC3_Re0);\r
 \r
-    // STEP 6: Set temperature limit to target TMAX\r
-       tas2557_switch_device(gpFTCC->nTSpkCharDevA.nDevAddr);\r
-    dev_a_prm_pow = calc_prm_pow (dev_a_re, \r
-               gpFTCC->nTSpkCharDevA.nSpkTMax - t_cal, \r
-               gpFTCC->nTSpkCharDevA.nPPC3_RTV, \r
-               gpFTCC->nTSpkCharDevA.nPPC3_RTM, \r
-               gpFTCC->nTSpkCharDevA.nPPC3_RTVA, \r
-               gpFTCC->nTSpkCharDevA.nPPC3_SysGain);\r
-    dev_a_prm_tlimit = calc_prm_tlimit(gpFTCC->nTSpkCharDevA.nSpkTMax - t_cal, \r
-               gpFTCC->nTSpkCharDevA.nSpkReAlpha, \r
-               gpFTCC->nTSpkCharDevA.nPPC3_DevNonlinPer, \r
-               gpFTCC->nTSpkCharDevA.nPPC3_RTV, \r
-               gpFTCC->nTSpkCharDevA.nPPC3_RTM, \r
-               gpFTCC->nTSpkCharDevA.nPPC3_RTVA);\r
-    set_re(gpFTCC->nTSpkCharDevA.nPPC3_Re0, dev_a_re, gpFTCC->nTSpkCharDevA.nSpkReAlpha);\r
-    set_temp_cal(dev_a_prm_pow, dev_a_prm_tlimit);\r
-       tas2557_switch_device(gpFTCC->nTSpkCharDevB.nDevAddr);\r
-    dev_b_prm_pow = calc_prm_pow (dev_b_re, \r
-               gpFTCC->nTSpkCharDevB.nSpkTMax - t_cal, \r
-               gpFTCC->nTSpkCharDevB.nPPC3_RTV, \r
-               gpFTCC->nTSpkCharDevB.nPPC3_RTM, \r
-               gpFTCC->nTSpkCharDevB.nPPC3_RTVA, \r
-               gpFTCC->nTSpkCharDevB.nPPC3_SysGain);\r
-    dev_b_prm_tlimit = calc_prm_tlimit(gpFTCC->nTSpkCharDevB.nSpkTMax - t_cal, \r
-               gpFTCC->nTSpkCharDevB.nSpkReAlpha, \r
-               gpFTCC->nTSpkCharDevB.nPPC3_DevNonlinPer, \r
-               gpFTCC->nTSpkCharDevB.nPPC3_RTV, \r
-               gpFTCC->nTSpkCharDevB.nPPC3_RTM, \r
-               gpFTCC->nTSpkCharDevB.nPPC3_RTVA);\r
-    set_re(gpFTCC->nTSpkCharDevB.nPPC3_Re0, dev_b_re, gpFTCC->nTSpkCharDevB.nSpkReAlpha);\r
-    set_temp_cal(dev_b_prm_pow, dev_b_prm_tlimit);     \r
+       // STEP 6: check speaker bounds\r
+       nResult = check_spk_bounds(gpFTCC, dev_a_re, dev_b_re);\r
+       \r
+       // STEP 7: Set temperature limit to target TMAX\r
+       if((nResult& RE1_CHK_MSK) == RESULT_PASS){\r
+               tas2557_switch_device(gpFTCC->nTSpkCharDevA.nDevAddr);\r
+               dev_a_prm_pow = calc_prm_pow (dev_a_re, \r
+                       gpFTCC->nTSpkCharDevA.nSpkTMax - t_cal, \r
+                       gpFTCC->nTSpkCharDevA.nPPC3_RTV, \r
+                       gpFTCC->nTSpkCharDevA.nPPC3_RTM, \r
+                       gpFTCC->nTSpkCharDevA.nPPC3_RTVA, \r
+                       gpFTCC->nTSpkCharDevA.nPPC3_SysGain);\r
+               dev_a_prm_tlimit = calc_prm_tlimit(gpFTCC->nTSpkCharDevA.nSpkTMax - t_cal, \r
+                       gpFTCC->nTSpkCharDevA.nSpkReAlpha, \r
+                       gpFTCC->nTSpkCharDevA.nPPC3_DevNonlinPer, \r
+                       gpFTCC->nTSpkCharDevA.nPPC3_RTV, \r
+                       gpFTCC->nTSpkCharDevA.nPPC3_RTM, \r
+                       gpFTCC->nTSpkCharDevA.nPPC3_RTVA);\r
+               set_re(gpFTCC->nTSpkCharDevA.nPPC3_Re0, dev_a_re, gpFTCC->nTSpkCharDevA.nSpkReAlpha);\r
+               set_temp_cal(dev_a_prm_pow, dev_a_prm_tlimit);\r
+       }\r
+       \r
+       if((nResult& RE2_CHK_MSK) == RESULT_PASS){\r
+               tas2557_switch_device(gpFTCC->nTSpkCharDevB.nDevAddr);\r
+               dev_b_prm_pow = calc_prm_pow (dev_b_re, \r
+                       gpFTCC->nTSpkCharDevB.nSpkTMax - t_cal, \r
+                       gpFTCC->nTSpkCharDevB.nPPC3_RTV, \r
+                       gpFTCC->nTSpkCharDevB.nPPC3_RTM, \r
+                       gpFTCC->nTSpkCharDevB.nPPC3_RTVA, \r
+                       gpFTCC->nTSpkCharDevB.nPPC3_SysGain);\r
+               dev_b_prm_tlimit = calc_prm_tlimit(gpFTCC->nTSpkCharDevB.nSpkTMax - t_cal, \r
+                       gpFTCC->nTSpkCharDevB.nSpkReAlpha, \r
+                       gpFTCC->nTSpkCharDevB.nPPC3_DevNonlinPer, \r
+                       gpFTCC->nTSpkCharDevB.nPPC3_RTV, \r
+                       gpFTCC->nTSpkCharDevB.nPPC3_RTM, \r
+                       gpFTCC->nTSpkCharDevB.nPPC3_RTVA);\r
+               set_re(gpFTCC->nTSpkCharDevB.nPPC3_Re0, dev_b_re, gpFTCC->nTSpkCharDevB.nSpkReAlpha);\r
+               set_temp_cal(dev_b_prm_pow, dev_b_prm_tlimit);  \r
+       }\r
+\r
     sys_stop_wav(nPlaybackProcess);\r
 \r
-    // STEP 7: Save Re, f0, Q and Cal Temp into a file\r
-    tas2557_save_cal(dev_a_re, dev_a_prm_pow, dev_a_prm_tlimit, \r
+    // STEP 8: Save Re, and Cal Temp into a file\r
+    tas2557_save_cal(gpFTCC, dev_a_re, dev_a_prm_pow, dev_a_prm_tlimit, \r
                dev_b_re, dev_b_prm_pow, dev_b_prm_tlimit, \r
-               t_cal, "tas2557_cal.txt");\r
+               t_cal, nResult, "tas2557_cal.txt");\r
 \r
-    // STEP 8: Save .bin file for TAS2555 driver\r
-       tas2557_open_bin("tas2557_cal.bin", gpFTCC->nConfiguration, gpFTCC->nTSpkCharDevA.nDevAddr, gpFTCC->nTSpkCharDevB.nDevAddr);\r
-       tas2557_switch_device(gpFTCC->nTSpkCharDevA.nDevAddr);\r
-       set_re(gpFTCC->nTSpkCharDevA.nPPC3_Re0, dev_a_re, gpFTCC->nTSpkCharDevA.nSpkReAlpha);\r
-       set_temp_cal(dev_a_prm_pow, dev_a_prm_tlimit);\r
-       tas2557_switch_device(gpFTCC->nTSpkCharDevB.nDevAddr);\r
-       set_re(gpFTCC->nTSpkCharDevB.nPPC3_Re0, dev_b_re, gpFTCC->nTSpkCharDevB.nSpkReAlpha);\r
-       set_temp_cal(dev_b_prm_pow, dev_b_prm_tlimit);  \r
-       tas2557_close_bin();\r
+    // STEP 9: Save .bin file for TAS2555 driver\r
+       if((nResult & (RE1_CHK_MSK|RE2_CHK_MSK)) == RESULT_PASS){\r
+               tas2557_open_bin("tas2557_cal.bin", gpFTCC->nConfiguration, gpFTCC->nTSpkCharDevA.nDevAddr, gpFTCC->nTSpkCharDevB.nDevAddr);\r
+               if((nResult&RE1_CHK_MSK) == RESULT_PASS){\r
+                       tas2557_switch_device(gpFTCC->nTSpkCharDevA.nDevAddr);\r
+                       set_re(gpFTCC->nTSpkCharDevA.nPPC3_Re0, dev_a_re, gpFTCC->nTSpkCharDevA.nSpkReAlpha);\r
+                       set_temp_cal(dev_a_prm_pow, dev_a_prm_tlimit);\r
+               }\r
+\r
+               if((nResult&RE2_CHK_MSK) == RESULT_PASS){\r
+                       tas2557_switch_device(gpFTCC->nTSpkCharDevB.nDevAddr);\r
+                       set_re(gpFTCC->nTSpkCharDevB.nPPC3_Re0, dev_b_re, gpFTCC->nTSpkCharDevB.nSpkReAlpha);\r
+                       set_temp_cal(dev_b_prm_pow, dev_b_prm_tlimit);  \r
+               }\r
+\r
+               tas2557_close_bin();\r
+       }\r
 \r
        if (gpFTCC->bLoadCalibration) tas2557_load_calibration(0xFF);\r
 \r