800 V Battery Management System (BMS) BJB gpio control problems

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

800 V Battery Management System (BMS) BJB gpio control problems

17,155 Views
BillWen
Contributor III

Hi everyone:

I have a problem is that I want to control BMS BJB gpio to test isolation test, my system is 800 V Battery Management System, s32k358 platform, 33772 BJB and 33774 CMU

Software project is HVBMS Integration project from NXP example project

There is a function "HvBms_Bjb_Main_IsoMeas_GpioEnable" to set the Q1, QL1 and Opto pins, but I want to control by my self. (I even don't know how to use this function due to every functions are static)

The following is my code that I try to control these three pins in run time task

Std_ReturnType HvBms_Bjb_IsoMeas_ControlAndRead(bool enable_Q1, bool enable_QL1, bool enable_Opto, float *riso_pos, float *riso_neg)
{
Std_ReturnType RetVal = E_OK;

HvBms_Bjb_AddressInformation.ChainStart = HVBMS_BJBSENSEMON_CHAIN_ID_ISO(0);
HvBms_Bjb_AddressInformation.ChainEnd = HVBMS_BJBSENSEMON_NO_OF_CHAINS_ISO;

//control Q1
if(enable_Q1)
{
HvBms_Bjb_AddressInformation.DeviceStart = HVBMS_BJB_AFE2;
HvBms_Bjb_AddressInformation.DeviceEnd = HVBMS_BJB_AFE2;
RetVal = HVBMS_BJB_BJBIF_SETMODE(&HvBms_Bjb_AddressInformation, &HvBms_BJBConfig,(uint8)HVBMS_BJB_GPIO6_DR_HIGH);
}
else
{
HvBms_Bjb_AddressInformation.DeviceStart = HVBMS_BJB_AFE2;
HvBms_Bjb_AddressInformation.DeviceEnd = HVBMS_BJB_AFE2;
RetVal = HVBMS_BJB_BJBIF_SETMODE(&HvBms_Bjb_AddressInformation, &HvBms_BJBConfig,(uint8)HVBMS_BJB_GPIO6_DR_LOW);
}

//control QL1
if(enable_QL1)
{
HvBms_Bjb_AddressInformation.DeviceStart = HVBMS_BJB_AFE1;
HvBms_Bjb_AddressInformation.DeviceEnd = HVBMS_BJB_AFE1;
RetVal |= HVBMS_BJB_BJBIF_SETMODE(&HvBms_Bjb_AddressInformation, &HvBms_BJBConfig,(uint8)HVBMS_BJB_GPIO6_DR_HIGH);
}
else
{
HvBms_Bjb_AddressInformation.DeviceStart = HVBMS_BJB_AFE1;
HvBms_Bjb_AddressInformation.DeviceEnd = HVBMS_BJB_AFE1;
RetVal|=HVBMS_BJB_BJBIF_SETMODE(&HvBms_Bjb_AddressInformation, &HvBms_BJBConfig,(uint8)HVBMS_BJB_GPIO6_DR_LOW);
}

//control Opto
if(enable_Opto)
{
HvBms_Bjb_AddressInformation.DeviceStart = HVBMS_BJB_AFE1;
HvBms_Bjb_AddressInformation.DeviceEnd = HVBMS_BJB_AFE1;
RetVal |= HVBMS_BJB_BJBIF_SETMODE(&HvBms_Bjb_AddressInformation, &HvBms_BJBConfig,(uint8)HVBMS_BJB_GPIO5_DR_HIGH);
}
else
{
HvBms_Bjb_AddressInformation.DeviceStart = HVBMS_BJB_AFE1;
HvBms_Bjb_AddressInformation.DeviceEnd = HVBMS_BJB_AFE1;
RetVal |= HVBMS_BJB_BJBIF_SETMODE(&HvBms_Bjb_AddressInformation, &HvBms_BJBConfig,(uint8)HVBMS_BJB_GPIO5_DR_LOW);
}

 

After BJB current mode be active mode, and I try to control but doesn't work, and sometimes BJB current mode would be "HVBMS_MODE_HALT", I don't know why

Is there any experience or idea that you can suggest me? Maybe Mcal setting need modify?

 

Thanks

BR, BillWen

0 Kudos
Reply
12 Replies

17,137 Views
RafaR
NXP Employee
NXP Employee

Okay, give me a moment. I need to confirm the possibilities with a colleague. I will contact you soon.

Have a great day and best of luck.

0 Kudos
Reply

17,106 Views
BillWen
Contributor III
Hi RafaR:
Thanks for your reply, another question is mostly bjb and cmu driver code are "static", is there any method can modify to global?
p.s. Because I don't want to change the code which are generated

thanks
BR, BillWen
0 Kudos
Reply

17,091 Views
RafaR
NXP Employee
NXP Employee

Hi BillWen

Good news. I contacted a colleague to resolve the issue, but we have some questions. We're not sure what "doesn't work" means here. Could you help me answer these points to better understand your problem?

 

  • are there any DET errors reported when running the modified code?
  • are the messages controlling the isolation resistance measurement circuit sent on the TPL bus?
  • are the TDs containing successfully (i.e. their status shall be PHY_TS_FINISHED)? 
  • how/where are you calling function HvBms_Bjb_IsoMeas_ControlAndRead? In addition, the code snippet is incomplete, it's missing the return and closing bracket
  • the BjbSenseMon state machine enters HVBMS_MODE_HALT mode when a communication error occurs

I will be waiting for your response

Have a great day and best of luck.

0 Kudos
Reply

17,079 Views
BillWen
Contributor III
Hi RafaR:
First of all, thanks for your reply.
That me explain my purpose and what I want to implement.
My purpose is control Q1, QL1, Opto 3 Gpio pins in freertos means in run times, and measure Vsense or Riso
My environment is NXP HVBMS integration project. I didn't change any setting in Mcal, and the code are generated by S32DS. I think the TPL or communication is all OK. (Unless your integration project code has other problems)
The HvBms_Bjb_IsoMeas_ControlAndRead function is called every 100 ms task, I use a variable and freemaster to control it that I need to run this code or not. I think the first step is try to control these gpio pins for me.
According HvBms_BjbSenseMon.c file, the Bjb main state or sub state will run automatically, I think I need to close them first and then I can control gpio, right?
For example, HvBms_Bjb_Main_IsoMeas_GpioEnable or HvBms_Bjb_Main_IsoMeas_GpioDisable these functions will run automatically and make me can't control, that's why bjb will entry HVBMS_MODE_HALT mode, this is my opinion.
Thanks
BR, BillWen
0 Kudos
Reply

17,026 Views
BillWen
Contributor III
Hi RafaR:
I have some updated and want to discuss with you.
I modify the "HvBms_BjbSenseMon.c" file and close the "HvBms_Bjb_Main_IsoMeas_GpioDisable" function.
Add the print log inside "HvBms_Bjb_Main_IsoMeas_GpioEnable" function and make sure the process will run this function. Normally, the gpio5 of AFE1 and gpio6 of AFE2 should be at high level, but I use "Bcc_772c_MEM_ReadRegister" driver code to print "MC33772C_GPIO_STS_OFFSET" the value always be 0, this behavior was wrong I think. I also print log inside "HvBms_BjbIf.c" case AFE1 and BJB_GPIO5_DR_LOW make sure there is no other function make this gpio be low.
Is there any possibilities these code have some problems? Or I do something wrong? Sorry, because this think is a little urgent.

p.s. These gpio pins are digital output, I already check the Mcal setting and GPIO_CFG1 value
Thanks
BR, BillWen
0 Kudos
Reply

17,012 Views
RafaR
NXP Employee
NXP Employee

Hi BillWen

Okay, I'll pass the information on to the AE, but first you could check his response and confirm if it was helpful.

“””

I would advise against performing any "external" communication with the BCC/BJB devices outside of the schedule tables implemented in HvBms_CmuBjbSenseMon, as it's a bit tricky to synchronize the commands.

Instead of calling HvBms_Bjb_IsoMeas_ControlAndRead in a different task, I suggest changing the implementation of HvBms_Bjb_Main_IsoMeas_GpioEnable/HvBms_Bjb_Main_IsoMeas_GpioDisable to call the BJB IF APIs based on the value of the variable that's set in FreeMaster.

“””

Then tell me all your comments, to tell my colleague the complete information.

Have a great day and best of luck.

0 Kudos
Reply

17,006 Views
BillWen
Contributor III
Hi RafaR:
Thanks for your reply first.
Forget about the function "HvBms_Bjb_IsoMeas_ControlAndRead" which created by me. I didn't modify any code just remove "HvBms_Bjb_Main_IsoMeas_GpioDisable" from the HvBms_Bjb_Main_States and make it don't run this function then make sure the code will run "HvBms_Bjb_Main_IsoMeas_Gpioenable", but I measure the gpio5 of AFE1 and gpio6 of AFE2 always be low, this is the problem. The gpio5 of AFE1 and gpio6 of AFE2 should be high because of the function "HvBms_Bjb_Main_IsoMeas_Gpioenable".
Do you know what I mean? I suspect that use "HVBMS_BJB_BJBIF_SETMODE" to set gpio this way is not work. (If I miss any step please tell me, thanks)

Thanks
BR, BillWen
0 Kudos
Reply

16,931 Views
BillWen
Contributor III
Hi RafaR:

Is there any updated for this problem?
Sorry, because this think is a little urgent.

Thanks a lot
BR, BillWen
0 Kudos
Reply

16,898 Views
RafaR
NXP Employee
NXP Employee

Hi BillWen

Sorry for the delay, sometimes it takes a little while to get a response due to different time zones, but we are still working, the AE wants to know if it would be possible to get the original/modified files?. It would be easier to observe the differences this way.


Have a great day and best of luck.

0 Kudos
Reply

16,886 Views
BillWen
Contributor III

Hi RafaR:

Thanks for your reply. 

This is the HvBms_BjbSenseMon.c file which I modified, please check the attachment.

You can check the function "HvBms_Bjb_Main_IsoMeas_GpioEnable" & "HvBms_Bjb_Main_IsoMeas_Gpiodisable" and "HvBms_Bjb_Check_GPIO_Status" this one is create by me.

Thanks

BR, BillWen

0 Kudos
Reply

16,700 Views
RafaR
NXP Employee
NXP Employee

Hi BillWen

We are sorry for the delay, It seems very important to resolve this issue as soon as possible but unfortunately the consultation process with the AE takes some time, but good news, I have the comments of the AE, let me share their comments with you:

Just a note before I already spoke with Jozef and we are both talking to the AE so the comments from the AE comments are to the information shared by Jozef and I

------

I compared HvBms_BjbSenseMon_modify.c against HvBms_BjbSenseMon.c BMS App 2024.02 release (that seems to be the version used by the customer judging by the header of the attached files).

A few observations from my side:

  • I noticed that in function HvBms_Bjb_Check_GPIO_Status you're directly interacting with the BJB via Bcc_772c_COM_WriteRegister()Bcc_772c_MEM_ReadRegister() etc. API calls.

Generally speaking, HvBms_CmuBjbSenseMon implements the logic required to drive the BMS system (scheduling of BCC/BJB interaction), whilst HvBms_CmuBjbIf interacts with the BCC/BJB device drivers (populating TDs with commands). 

  • To read the GPIO status (i.e. HIGH/LOW), Bcc_772c_COM_ReadRegisters() API must be used. GPIO_STS register is not part of the memory mirror, so calling Bcc_772c_MEM_ReadRegister() with RegAddr == MC33772C_GPIO_STS_OFFSET will return an error.

This implies TPL communication with the MC33772C devices, so a TD will have to be used. Probably the easiest way to retrieve the GPIO status is extending the implementation of the HvBms_BjbIf_SetMode() API and reading back the register value after setting it (e.g. case BJB_GPIO5_DR_HIGH, case BJB_GPIO5_DR_LOW etc.)

  • Did you measure the logic level of pins controlling the isolation resistance circuit using a multimeter after HvBms_Bjb_Main_IsoMeas_GpioEnable() is called? This would give a clear indication whether setting the GPIOs actually worked

------

 

I hope this information has helped you, please let me know if you need help with anything else.

Have a great day and best of luck.

0 Kudos
Reply

16,638 Views
BillWen
Contributor III
Hi RafaR:
Thanks for your reply, I already find out the reason.
In NXP integration project "HvBms_Bjbif.c" file, the following code is that I modify, after I add the "Bcc_772c_Enumerate" & "Bcc_772c_GPIO_Configure", then the GPIO can be control. The problem is that I think in the "HVBMS_BJB_BJBIF_SETMODE" function there are two function need to do first just like what I add.

if(BJB_DEV_IDX_AFE1 == DevIdx)
{
Bcc_772c_Enumerate(ChainIdx, DevIdx, Bms_TDList[HvBms_Com_BjbComBufferIndex]);
Bcc_772c_GPIO_Configure(ChainIdx, DevIdx, 0, Bms_TDList[HvBms_Com_BjbComBufferIndex]);
Bjb_GpioSettingAFE1 = (Bjb_GpioSettingAFE1)|(MC33772C_GPIO_CFG2_GPIO5_DR_U16(MC33772C_GPIO_CFG2_GPIO5_DR_HIGH_ENUM_VAL)); /* enable */
retValue |= Bcc_772c_GPIO_SetOutput(ChainIdx,DevIdx,Bjb_GpioSettingAFE1, Bms_TDList[HvBms_Com_BjbComBufferIndex]);
if (E_OK == retValue)
{
/* Phy workaround */
retValue |= Bcc_772c_COM_InsertNop(ChainIdx, 1U, Bms_TDList[HvBms_Com_BjbComBufferIndex]);
}
}
Overall, I think I will not use NXP bjb whole code and function, because I think is much fixed and hard to modify it. But I learn a lesson too, thanks a lot for your help.

Thanks
BR, BillWen