8 years, 4 months ago.

Issues related to global variables and library updates...

Hi

I have been trying to work out SOC of a battery using a simple arithmetic equation while using global variables. The following code is evaluated within ISR, using global variables (namely I_DC_L_filt, BattSOC, LastBattSOC ), a macro (Batt_SOC_Mult), local float temp2 and GPIO (PS_Lcl_Ext). Surprisingly I cannot figure out why such a simple logic does not work. BTW these global variables BattSOC, LastBattSOC are modified only in this ISR, whereas I_DC_L_filt is modified in another ISR. Indeed both these routines would never run at same time, thus eliminating the possibility of overwriting.

        temp2 = I_DC_L_filt;
        BattSOC = LastBattSOC - (temp2*Batt_SOC_Mult);

        if(BattSOC == LastBattSOC) {
            PS_Lcl_Ext = !PS_Lcl_Ext;
        }

        LastBattSOC = BattSOC;

I tried updating all the documents, libraries of the code and Now I am getting the following error messages. Could someone please help me to resolve these issues? Thanks a lot!

Error: Undefined symbol mbed::FunctionPointer::attach(void(*)()) (referred from main.cpp.NUCLEO_F401RE.o). Error: Undefined symbol mbed::FunctionPointer::FunctionPointer(void(*)()) (referred from main.cpp.NUCLEO_F401RE.o). Error: Undefined symbol mbed::FunctionPointer::call() (referred from iQ_globals.cpp.NUCLEO_F401RE.o).

See below relevant parts of the code:

//==== Filter  related==========
#define     PWMSTEP_US          (10.0f/839.0f) //83.9 MHz internal clock
#define     PWMPER              (20.0f) // in us for a switching frequency of 80 kHz
#define     fc                  400.0f // cutoff frequency
#define     tau                 (1.0f/(2*PI_M*fc))
#define     DT                  (PWMPER*0.000001f)
#define     FilC1               (tau/(tau + DT))
#define     FilC2               (DT/(tau + DT))
#define     Batt_Capacity       20.0f // 20 Ah
#define     Batt_SOC_Mult       (DT/Batt_Capacity)
#define     ADCCurrGain1        0.00734218f

 float I_DC_L_km1;
 volatile float I_DC_L_filt;
 float I_DC_L;


//==================== ISR 1===============================
void  ADC_IRQHandler(void)
{
    // ISR at the end of conversion.
    float temp;
    int fault_type = 0;
    temp            = (float)(ADC1->JDR1);
    I_DC_L          = ( temp - ILOffset)*ADCCurrGain1;
    // ---------- Inductor current checking -------------
    if(I_DC_L >= I_DC_L_Max) {
        FaultExist = true;
        fault_type = fault_type + 1;
    }
    if(I_DC_L <= I_DC_L_Min) {
        FaultExist = true;
        fault_type = fault_type + 3;
    }
    I_DC_L_filt         =   FilC1*I_DC_L_km1 + FilC2*I_DC_L;
    I_DC_L_km1          =   I_DC_L;
// Clear the IF and the start of conversion flag:
    ADC1->SR &= ~(ADC_SR_JEOC | ADC_SR_JSTRT);
    return;
}

//==================== ISR 2===============================
void TIM1_CC_IRQHandler(void)
{
    float temp2 = I_DC_L_filt;
    BattSOC = LastBattSOC - (temp2*Batt_SOC_Mult);
    if(BattSOC == LastBattSOC) {
        PS_Lcl_Ext = !PS_Lcl_Ext;
    }
    LastBattSOC = BattSOC;
    TIM1->SR &= (~TIM_SR_UIF);  // Clear the flag:
    return;
}

Can you share the program or create a minimum viable example of the problem?

posted by Sam Grove 08 Dec 2015

Thanks. I will upload the code soon.

posted by Baljit Riar 08 Dec 2015
Be the first to answer this question.