Current threshold and Ah counter threshold sample code

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Current threshold and Ah counter threshold sample code

跳至解决方案
1,011 次查看
gumu
Contributor V

Hi NXP team,

I'm using RD9Z1-638 to develop BMS project.There is a demand that device can be woke up from stop mode by current threshold or Ah counter.

This is my code:

	u8 CAN_status[3];

	Sleep_CAN(CAN0, CMPTX);                           // request CAN channel 0 go to sleep with completing transmission scheduled
	do {
		Check_CAN_Status(CAN0, CAN_status);           // read the channel 0 status
	} while (!(CAN_status[1] & SLPAK));					           // wait till SLPAK bit set

	B_PCR_WUEH_WUPTB4 = 1; // enable PTB4 wakeup
	B_ACQ_CTH = 100;
	B_PCR_WUEH_WUAHTH = 1;  //Wake-up on Ah counter enabled
	B_GPIO_TSENSE = 0;
	B_GPIO_VSENSE = 0;
	ADCDisable();
	TsenseDisable();
	CAN_STDBY(STANDBYMODE);
	ApiRtcSetWakeupPeriod(RTC_PERIOD_WAKE_TIME);
	PCREnterStopMode();
......

 but it didn't work.

I'd like to know if there is sample code for this function!

Thanks!

标记 (1)
0 项奖励
回复
1 解答
953 次查看
Q_man
NXP Employee
NXP Employee

The coulomb counter (CC) simply adds up every ISENSE ADC measurement. The frequency (interval) of the measurements in low power mode can be configured with the ACQ_TCMP register.

In the example:

The frequency is 10 samples per second 10S/s. The ADC typically has a resolution of 1mA per LSB. This results in a 0.1mA*s per LSB resolution for the CC.

The threshold of 60000 equals to 6000mA*s (e.g. applying 100mA for 60s should trigger the threshold)

在原帖中查看解决方案

3 回复数
1,000 次查看
Q_man
NXP Employee
NXP Employee

To use any current sense based wakeup, the ISENSE channel must be configured and enabled in the Low Power mode. Here some example code:

ADCDisable(); 
TsenseDisable();
B_GPIO_VSENSE = 0;
IrqDisable();

// config to measure every 100ms in sleep
B_ACQ_TCMP = 100; // LP clock = 1KHz, depends on PF[1:0] setting

// config to wakeup if |I| > 500mA
B_ACQ_CTH = (500>>1);
B_ACQ_THF = 0;

// config to wakeup if Ah counter >xxx
B_ACQ_CTL = B_ACQ_CTL_AHCRM_MASK | B_ACQ_CTL_AHCR_MASK; // reset Ah counter
B_ACQ_AHTH = 60000L; // 100mA * 60s * 10S/s

ADCLpEnable();
PCREnterStopMode();


//////////////////////
//---------------------------------------------------------------------
/*! \brief Enables CSENSE channel Acquisitions for low power modes.

*/
void ADCLpEnable(void) {

B_ACQ_CTL = (B_ACQ_CTL_CMENM_MASK | B_ACQ_CTL_CMEN_MASK)//!< enable current sense measurements
}

 

0 项奖励
回复
966 次查看
gumu
Contributor V

Hi @Q_man ,

Thank you very much!

The sample code can work well. But I don't understand how to caculate the value of B_ACQ_AHTH ,

B_ACQ_AHTH = 60000L; // 100mA * 60s * 10S/s

 what's the unit of B_ACQ_AHTH.

Thanks!

0 项奖励
回复
954 次查看
Q_man
NXP Employee
NXP Employee

The coulomb counter (CC) simply adds up every ISENSE ADC measurement. The frequency (interval) of the measurements in low power mode can be configured with the ACQ_TCMP register.

In the example:

The frequency is 10 samples per second 10S/s. The ADC typically has a resolution of 1mA per LSB. This results in a 0.1mA*s per LSB resolution for the CC.

The threshold of 60000 equals to 6000mA*s (e.g. applying 100mA for 60s should trigger the threshold)