Hello Experts,
My customer is using UCD3138 device, which is ARM7 based. The compiler used is TI Arm v5.2.5. The optimization configuration for the entire project is shown below.
In customer code, there is a inline function and it is repeated many times in the code, causing the code size to be large. To save code size, they reconstruct the code by rewritting a similar subfunction to replace the existing inline functions. The problem they are encountering is that the code size even gets larger. Attaching the detailed code.
before.c: one example code is as attached, there are about 18 cases using similar code , but with unique parameters/constant and conditional compiling flag for each case. this is why inline is used and need to be repeated many times, causing a large code size.
after.c: rewrite a general sub-function by adding some parameters and replace the conditional compiling flag with if-else branch.
Do you have any idea why this could happen? Is there any parameters about the compiler itself that may be related to this pheonmenon? Looking forward to your reply.
#pragma CODE_STATE(rail_voltage_monitor, 32) // 16 = thumb mode, 32 = ARM mode void rail_voltage_monitor(int32 adc_reading, Uint8 number) { static VMON_STATES vmon_state_ad05 = VMON_RAIL_DISABLED; switch(vmon_state_ad05) { case VMON_RAIL_DISABLED: { if(rail_para_const[number].on_off_ctrl==1) { rail[rail_para_const[number].rail_index].fault.bit.uv = 0; // Clear UV fault flag for the rail rail[rail_para_const[number].rail_index].fault.bit.ov = 0; // Clear OV fault flag for the rail } if (rail[rail_para_const[number].rail_index].enabled) { if (dc_ok_delay_counter < rail_para_const[number].rampup_blanking_cnt) { // update dc_ok_delay_counter dc_ok_delay_counter = rail_para_const[number].rampup_blanking_cnt; } vmon_state_ad05 = VMON_RAIL_RAMPUP; // next state } break; } case VMON_RAIL_RAMPUP: { // rail is coming up, ignore faults in this state if (rail[rail_para_const[number].rail_index].enabled == 0) { // rail has become disabled vmon_state_ad05 = VMON_RAIL_DISABLED; // next state } else { if (dc_ok_delay_counter == 0) { // fault blanking timer has elapsed // check Vout against OV and UV thresholds if (adc_reading > rail_para_const[number].rail_ovp_threshold) { // OV fault // monitored voltage is greater than OVP threshold rail[rail_para_const[number].rail_index].fault.bit.ov = 1; // set OV fault flag for the rail set_dc_nok_flag(rail_para_const[number].rail_id); // set DC_NOK flag for the rail // if the event log buffer is not being used (we know this if event_log_update_flag = 0), then initiate update of the event log in data flash if (event_log_update_flag == 0) { update_event_log_buffer(rail_para_const[number].rail_index); } vmon_state_ad05 = VMON_RAIL_OV_FAULT; // next state } else if (adc_reading < rail_para_const[number].rail_uvp_threshold) { // UV fault // monitored voltage is less than UVP threshold rail[AD05_RAIL_INDEX].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(rail_para_const[number].rail_id); // set DC_NOK flag for the rail // if the event log buffer is not being used (we know this if event_log_update_flag = 0), then initiate update of the event log in data flash if (event_log_update_flag == 0) { update_event_log_buffer(rail_para_const[number].rail_index); } vmon_state_ad05 = VMON_RAIL_UV_FAULT; // next state } else { // no fault, DC is OK for this rail, so clear DC_NOK flag clear_dc_nok_flag(rail_para_const[number].rail_id); vmon_state_ad05 = VMON_RAIL_DC_OK; // next state } } } break; } case VMON_RAIL_DC_OK: { // rail is enabled, and is between it's OV and UV levels if (rail[rail_para_const[number].rail_index].enabled == 0) { // rail has become disabled vmon_state_ad05 = VMON_RAIL_DISABLED; // next state } else { // check Vout against OV and UV thresholds if (adc_reading > rail_para_const[number].rail_ovp_threshold) { // OV fault // monitored voltage is greater than OVP threshold rail[rail_para_const[number].rail_index].fault.bit.ov = 1; // set OV fault flag for the rail set_dc_nok_flag(rail_para_const[number].rail_id); // set DC_NOK flag for the rail // if the event log buffer is not being used (we know this if event_log_update_flag = 0), then initiate update of the event log in data flash if (event_log_update_flag == 0) { update_event_log_buffer(rail_para_const[number].rail_index); } vmon_state_ad05 = VMON_RAIL_OV_FAULT; // next state } else if (adc_reading < rail_para_const[number].rail_uvp_threshold) { // UV fault // monitored voltage is less than UVP threshold rail[rail_para_const[number].rail_index].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(rail_para_const[number].rail_id); // set DC_NOK flag for the rail // if the event log buffer is not being used (we know this if event_log_update_flag = 0), then initiate update of the event log in data flash if (event_log_update_flag == 0) { update_event_log_buffer(rail_para_const[number].rail_index); } vmon_state_ad05 = VMON_RAIL_UV_FAULT; // next state } } break; } case VMON_RAIL_OV_FAULT: { // OV fault has occured if (rail[rail_para_const[number].rail_index].enabled == 0) { // rail has been disabled clear_dc_nok_flag(rail_para_const[number].rail_id); // clear DC_NOK flag for the rail rail[rail_para_const[number].rail_index].fault.bit.ov = 0; // clear OV fault flag for the rail vmon_state_ad05 = VMON_RAIL_DISABLED; // next state } else { // rail is still enabled // check if Vout < OV threshold if (adc_reading < rail_para_const[number].rail_ovp_threshold) { // no fault, DC is OK for this rail, so clear DC_NOK flag clear_dc_nok_flag(rail_para_const[number].rail_id); rail[rail_para_const[number].rail_index].fault.bit.ov = 0; // clear OV fault flag for the rail vmon_state_ad05 = VMON_RAIL_DC_OK; // next state } } break; } case VMON_RAIL_UV_FAULT: { // UV fault has occured if (rail[rail_para_const[number].rail_index].enabled == 0) { // rail has been disabled clear_dc_nok_flag(rail_para_const[number].rail_id); // clear DC_NOK flag for the rail rail[rail_para_const[number].rail_index].fault.bit.uv = 0; // clear UV fault flag for the rail vmon_state_ad05 = VMON_RAIL_DISABLED; // next state } else { // rail is still enabled // check if Vout > UV threshold if (adc_reading > rail_para_const[number].rail_uvp_threshold) { // no fault, DC is OK for this rail, so clear DC_NOK flag clear_dc_nok_flag(rail_para_const[number].rail_id); rail[rail_para_const[number].rail_index].fault.bit.uv = 0; // clear UV fault flag for the rail vmon_state_ad05 = VMON_RAIL_DC_OK; // next state } } break; } default: break; } }
static inline void ad00_monitor(void) { register int32 adc_reading = ADC_AD00; // multiple the ADC result by -1 if monitoring a negative voltage adc_reading = adc_reading * AD00_OVP_SIGN; static VMON_STATES vmon_state_ad00 = VMON_RAIL_DISABLED; switch(vmon_state_ad00) { case VMON_RAIL_DISABLED: { #if (find_rail_on_off_ctrl_from_id(AD00_RAIL_ID) == 1) rail[AD00_RAIL_INDEX].fault.bit.uv = 0; // Clear UV fault flag for the rail rail[AD00_RAIL_INDEX].fault.bit.ov = 0; // Clear OV fault flag for the rail if (rail[AD00_RAIL_INDEX].enabled) #endif // #if (find_rail_on_off_ctrl_from_id(AD00_RAIL_ID) == 1) { // rail has been enabled // check if dc_ok delay counter needs to be updated if (dc_ok_delay_counter < AD00_RAIL_RAMPUP_BLANKING_CNT) { // update dc_ok_delay_counter dc_ok_delay_counter = AD00_RAIL_RAMPUP_BLANKING_CNT; } vmon_state_ad00 = VMON_RAIL_RAMPUP; // next state } break; } case VMON_RAIL_RAMPUP: { // rail is coming up, ignore faults in this state #if (find_rail_on_off_ctrl_from_id(AD00_RAIL_ID) == 1) if (rail[AD00_RAIL_INDEX].enabled == 0) { #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB1 and disabled by the system set_dc_nok_sub1_flag(AD00_RAIL_ID); // set DC_NOK_SUB1 flag for the rail #endif // #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB2 and disabled by the system set_dc_nok_sub2_flag(AD00_RAIL_ID); // set DC_NOK_SUB2 flag for the rail #endif // #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // rail has become disabled vmon_state_ad00 = VMON_RAIL_DISABLED; // next state } else #endif // #if (find_rail_on_off_ctrl_from_id(AD00_RAIL_ID) == 1) { if (dc_ok_delay_counter == 0) { // fault blanking timer has elapsed // check Vout against OV and UV thresholds if (adc_reading > ad00_thres_ovp_adc) { // OV fault // monitored voltage is greater than OVP threshold rail[AD00_RAIL_INDEX].fault.bit.ov = 1; // set OV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail #if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) domain_dc_nok_flags.all = dc_nok_flags.all; #endif//#if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB1 set_dc_nok_sub1_flag(AD00_RAIL_ID); // set DC_NOK_SUB1 flag for the rail #endif // #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB2 and disabled by the system set_dc_nok_sub2_flag(AD00_RAIL_ID); // set DC_NOK_SUB2 flag for the rail #endif // #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // if the event log buffer is not being used (we know this if event_log_update_flag = 0), then initiate update of the event log in data flash if (event_log_update_flag == 0) { update_event_log_buffer(AD00_RAIL_INDEX); } vmon_state_ad00 = VMON_RAIL_OV_FAULT; // next state } else if (adc_reading < ad00_thres_uvp_adc) { #if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) #if((find_rail_dc_power_domain_a_set_from_id(AD00_RAIL_ID) == 1)) if(rail[DC_POWER_DOMAIN_A_ENA_RAIL_ID_INDEX].enable_via_spi == 1)// && (rail[DC_POWER_DOMAIN_A_ENA_RAIL_ID_INDEX].fault.bit.uv == 0)&& (rail[DC_POWER_DOMAIN_A_ENA_RAIL_ID_INDEX].fault.bit.ov == 0)) { // UV fault // monitored voltage is less than UVP threshold rail[AD00_RAIL_INDEX].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail } #elif((find_rail_dc_power_domain_b_set_from_id(AD00_RAIL_ID) == 1)) if(rail[DC_POWER_DOMAIN_B_ENA_RAIL_ID_INDEX].enable_via_spi == 1)// && (rail[DC_POWER_DOMAIN_B_ENA_RAIL_ID_INDEX].fault.bit.uv == 0)&& (rail[DC_POWER_DOMAIN_B_ENA_RAIL_ID_INDEX].fault.bit.ov == 0)) { // UV fault // monitored voltage is less than UVP threshold rail[AD00_RAIL_INDEX].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail } #elif((find_rail_dc_power_domain_c_set_from_id(AD00_RAIL_ID) == 1)) if(rail[DC_POWER_DOMAIN_C_ENA_RAIL_ID_INDEX].enable_via_spi == 1)// && (rail[DC_POWER_DOMAIN_C_ENA_RAIL_ID_INDEX].fault.bit.uv == 0)&& (rail[DC_POWER_DOMAIN_C_ENA_RAIL_ID_INDEX].fault.bit.ov == 0)) { // UV fault // monitored voltage is less than UVP threshold rail[AD00_RAIL_INDEX].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail } #else // UV fault // monitored voltage is less than UVP threshold rail[AD00_RAIL_INDEX].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail #endif//#if((find_rail_dc_power_domain_a_set_from_id(AD00_RAIL_ID) == 1)) domain_dc_nok_flags.all = dc_nok_flags.all; #else // UV fault // monitored voltage is less than UVP threshold rail[AD00_RAIL_INDEX].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail #endif//#if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB1 set_dc_nok_sub1_flag(AD00_RAIL_ID); // set DC_NOK_SUB1 flag for the rail #endif // #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB2 and disabled by the system set_dc_nok_sub2_flag(AD00_RAIL_ID); // set DC_NOK_SUB2 flag for the rail #endif // #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // if the event log buffer is not being used (we know this if event_log_update_flag = 0), then initiate update of the event log in data flash if (event_log_update_flag == 0) { update_event_log_buffer(AD00_RAIL_INDEX); } vmon_state_ad00 = VMON_RAIL_UV_FAULT; // next state } else { // no fault, DC is OK for this rail, so clear DC_NOK flag clear_dc_nok_flag(AD00_RAIL_ID); #if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) domain_dc_nok_flags.all = dc_nok_flags.all; #endif//#if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB1 clear_dc_nok_sub1_flag(AD00_RAIL_ID); // clear DC_NOK_SUB1 flag for the rail #endif // #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB2 clear_dc_nok_sub2_flag(AD00_RAIL_ID); // clear DC_NOK_SUB2 flag for the rail #endif // #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) rail[AD00_RAIL_INDEX].fault.bit.uv = 0; vmon_state_ad00 = VMON_RAIL_DC_OK; // next state } } } break; } case VMON_RAIL_DC_OK: { // rail is enabled, and is between it's OV and UV levels #if (find_rail_on_off_ctrl_from_id(AD00_RAIL_ID) == 1) if (rail[AD00_RAIL_INDEX].enabled == 0) { #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB1 and disabled by system set_dc_nok_sub1_flag(AD00_RAIL_ID); // set DC_NOK_SUB1 flag for the rail #endif // #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB2 and disabled by the system set_dc_nok_sub2_flag(AD00_RAIL_ID); // set DC_NOK_SUB2 flag for the rail #endif // #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // rail has become disabled vmon_state_ad00 = VMON_RAIL_DISABLED; // next state } else #endif // #if (find_rail_on_off_ctrl_from_id(AD00_RAIL_ID) == 1) { // check Vout against OV and UV thresholds if (adc_reading > ad00_thres_ovp_adc) { // OV fault // monitored voltage is greater than OVP threshold rail[AD00_RAIL_INDEX].fault.bit.ov = 1; // set OV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail #if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) domain_dc_nok_flags.all = dc_nok_flags.all; #endif//#if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB1 set_dc_nok_sub1_flag(AD00_RAIL_ID); // set DC_NOK_SUB1 flag for the rail #endif // #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB2 and disabled by the system set_dc_nok_sub2_flag(AD00_RAIL_ID); // set DC_NOK_SUB2 flag for the rail #endif // #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // if the event log buffer is not being used (we know this if event_log_update_flag = 0), then initiate update of the event log in data flash if (event_log_update_flag == 0) { update_event_log_buffer(AD00_RAIL_INDEX); } vmon_state_ad00 = VMON_RAIL_OV_FAULT; // next state } else if (adc_reading < ad00_thres_uvp_adc) { #if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) #if((find_rail_dc_power_domain_a_set_from_id(AD00_RAIL_ID) == 1)) if(rail[DC_POWER_DOMAIN_A_ENA_RAIL_ID_INDEX].enable_via_spi == 1)// && (rail[DC_POWER_DOMAIN_A_ENA_RAIL_ID_INDEX].fault.bit.uv == 0)&& (rail[DC_POWER_DOMAIN_A_ENA_RAIL_ID_INDEX].fault.bit.ov == 0)) { // UV fault // monitored voltage is less than UVP threshold rail[AD00_RAIL_INDEX].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail } #elif((find_rail_dc_power_domain_b_set_from_id(AD00_RAIL_ID) == 1)) if(rail[DC_POWER_DOMAIN_B_ENA_RAIL_ID_INDEX].enable_via_spi == 1)// && (rail[DC_POWER_DOMAIN_B_ENA_RAIL_ID_INDEX].fault.bit.uv == 0)&& (rail[DC_POWER_DOMAIN_B_ENA_RAIL_ID_INDEX].fault.bit.ov == 0)) { // UV fault // monitored voltage is less than UVP threshold rail[AD00_RAIL_INDEX].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail } #elif((find_rail_dc_power_domain_c_set_from_id(AD00_RAIL_ID) == 1)) if(rail[DC_POWER_DOMAIN_C_ENA_RAIL_ID_INDEX].enable_via_spi == 1)// && (rail[DC_POWER_DOMAIN_C_ENA_RAIL_ID_INDEX].fault.bit.uv == 0)&& (rail[DC_POWER_DOMAIN_C_ENA_RAIL_ID_INDEX].fault.bit.ov == 0)) { // UV fault // monitored voltage is less than UVP threshold rail[AD00_RAIL_INDEX].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail } #else // UV fault // monitored voltage is less than UVP threshold rail[AD00_RAIL_INDEX].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail #endif//#if((find_rail_dc_power_domain_a_set_from_id(AD00_RAIL_ID) == 1)) domain_dc_nok_flags.all = dc_nok_flags.all; #else // UV fault // monitored voltage is less than UVP threshold rail[AD00_RAIL_INDEX].fault.bit.uv = 1; // set UV fault flag for the rail set_dc_nok_flag(AD00_RAIL_ID); // set DC_NOK flag for the rail #endif//#if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB1 set_dc_nok_sub1_flag(AD00_RAIL_ID); // set DC_NOK_SUB1 flag for the rail #endif // #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB2 and disabled by the system set_dc_nok_sub2_flag(AD00_RAIL_ID); // set DC_NOK_SUB2 flag for the rail #endif // #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // if the event log buffer is not being used (we know this if event_log_update_flag = 0), then initiate update of the event log in data flash if (event_log_update_flag == 0) { update_event_log_buffer(AD00_RAIL_INDEX); } vmon_state_ad00 = VMON_RAIL_UV_FAULT; // next state } } break; } case VMON_RAIL_OV_FAULT: { // OV fault has occured #if (find_rail_on_off_ctrl_from_id(AD00_RAIL_ID) == 1) if (rail[AD00_RAIL_INDEX].enabled == 0) { // rail has been disabled clear_dc_nok_flag(AD00_RAIL_ID); // clear DC_NOK flag for the rail #if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) domain_dc_nok_flags.all = dc_nok_flags.all; #endif//#if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) rail[AD00_RAIL_INDEX].fault.bit.ov = 0; // clear OV fault flag for the rail vmon_state_ad00 = VMON_RAIL_DISABLED; // next state } else #endif // #if (find_rail_on_off_ctrl_from_id(AD00_RAIL_ID) == 1) { // rail is still enabled // check if Vout < OV threshold if (adc_reading < ad00_thres_ovp_adc) { clear_dc_nok_flag(AD00_RAIL_ID); // Clear DC_NOK flag for the rail #if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) domain_dc_nok_flags.all = dc_nok_flags.all; #endif//#if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB1 clear_dc_nok_sub1_flag(AD00_RAIL_ID); // clear DC_NOK_SUB1 flag for the rail #endif // #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB2 clear_dc_nok_sub2_flag(AD00_RAIL_ID); // clear DC_NOK_SUB2 flag for the rail #endif // #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) rail[AD00_RAIL_INDEX].fault.bit.ov = 0; // clear OV fault flag for the rail vmon_state_ad00 = VMON_RAIL_DC_OK; // next state } } break; } case VMON_RAIL_UV_FAULT: { // UV fault has occured #if (find_rail_on_off_ctrl_from_id(AD00_RAIL_ID) == 1) if (rail[AD00_RAIL_INDEX].enabled == 0) { // rail has been disabled clear_dc_nok_flag(AD00_RAIL_ID); // clear DC_NOK flag for the rail #if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) domain_dc_nok_flags.all = dc_nok_flags.all; #endif//#if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) rail[AD00_RAIL_INDEX].fault.bit.uv = 0; // clear UV fault flag for the rail vmon_state_ad00 = VMON_RAIL_DISABLED; // next state } else #endif // #if (find_rail_on_off_ctrl_from_id(AD00_RAIL_ID) == 1) { // rail is still enabled // check if Vout > UV threshold if (adc_reading > ad00_thres_uvp_adc) { clear_dc_nok_flag(AD00_RAIL_ID); // Clear DC_NOK flag for the rail #if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) domain_dc_nok_flags.all = dc_nok_flags.all; #endif//#if(defined(DC_POWER_DOMAIN_A_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_B_ENA_RAIL_ID) || defined(DC_POWER_DOMAIN_C_ENA_RAIL_ID)) #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB1 clear_dc_nok_sub1_flag(AD00_RAIL_ID); // clear DC_NOK_SUB1 flag for the rail #endif // #if (defined(DC_OK_SUB1_PIN) && (find_rail_dc_ok_sub1_set_from_id(AD00_RAIL_ID) == 1)) #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) // rail is monitored by DC_OK_SUB2 clear_dc_nok_sub2_flag(AD00_RAIL_ID); // clear DC_NOK_SUB2 flag for the rail #endif // #if (defined(DC_OK_SUB2_PIN) && (find_rail_dc_ok_sub2_set_from_id(AD00_RAIL_ID) == 1)) vmon_state_ad00 = VMON_RAIL_DC_OK; // next state } } break; } default: break; } }
Regards,
Xuemei