Current threshold and Ah counter threshold sample code

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

Current threshold and Ah counter threshold sample code

Jump to solution
1,007 Views
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!

Tags (1)
0 Kudos
Reply
1 Solution
949 Views
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)

View solution in original post

3 Replies
996 Views
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 Kudos
Reply
962 Views
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 Kudos
Reply
950 Views
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)