<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Current threshold and Ah counter threshold sample code in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Current-threshold-and-Ah-counter-threshold-sample-code/m-p/1690049#M19306</link>
    <description>&lt;P&gt;To use any current sense based wakeup, the ISENSE channel must be configured and &lt;STRONG&gt;enabled&lt;/STRONG&gt; in the Low Power mode. Here some example code:&lt;/P&gt;
&lt;PRE&gt;ADCDisable(); &lt;BR /&gt;TsenseDisable();&lt;BR /&gt;B_GPIO_VSENSE = 0;&lt;BR /&gt;IrqDisable();&lt;BR /&gt;&lt;BR /&gt;// config to measure every 100ms in sleep&lt;BR /&gt;B_ACQ_TCMP = 100; // LP clock = 1KHz, depends on PF[1:0] setting&lt;BR /&gt;&lt;BR /&gt;// config to wakeup if |I| &amp;gt; 500mA&lt;BR /&gt;B_ACQ_CTH = (500&amp;gt;&amp;gt;1);&lt;BR /&gt;B_ACQ_THF = 0; &lt;BR /&gt;&lt;BR /&gt;// config to wakeup if Ah counter &amp;gt;xxx&lt;BR /&gt;B_ACQ_CTL = B_ACQ_CTL_AHCRM_MASK | B_ACQ_CTL_AHCR_MASK; // reset Ah counter&lt;BR /&gt;B_ACQ_AHTH = 60000L; // 100mA * 60s * 10S/s&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;ADCLpEnable();&lt;/STRONG&gt; &lt;BR /&gt;PCREnterStopMode();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//////////////////////&lt;BR /&gt;//---------------------------------------------------------------------&lt;BR /&gt;/*! \brief Enables CSENSE channel Acquisitions for low power modes.&lt;BR /&gt;&lt;BR /&gt;*/&lt;BR /&gt;void ADCLpEnable(void) {&lt;BR /&gt;&lt;BR /&gt;B_ACQ_CTL = (B_ACQ_CTL_CMENM_MASK | B_ACQ_CTL_CMEN_MASK)//!&amp;lt; enable current sense measurements&lt;BR /&gt;}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jul 2023 06:07:46 GMT</pubDate>
    <dc:creator>Q_man</dc:creator>
    <dc:date>2023-07-21T06:07:46Z</dc:date>
    <item>
      <title>Current threshold and Ah counter threshold sample code</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Current-threshold-and-Ah-counter-threshold-sample-code/m-p/1689252#M19303</link>
      <description>&lt;P&gt;Hi NXP team,&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;This is my code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;	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] &amp;amp; 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();
......&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;but&amp;nbsp;it didn't work.&lt;/P&gt;&lt;P&gt;I'd like to know if there is sample code for this function!&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 09:25:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Current-threshold-and-Ah-counter-threshold-sample-code/m-p/1689252#M19303</guid>
      <dc:creator>gumu</dc:creator>
      <dc:date>2023-07-20T09:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Current threshold and Ah counter threshold sample code</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Current-threshold-and-Ah-counter-threshold-sample-code/m-p/1690049#M19306</link>
      <description>&lt;P&gt;To use any current sense based wakeup, the ISENSE channel must be configured and &lt;STRONG&gt;enabled&lt;/STRONG&gt; in the Low Power mode. Here some example code:&lt;/P&gt;
&lt;PRE&gt;ADCDisable(); &lt;BR /&gt;TsenseDisable();&lt;BR /&gt;B_GPIO_VSENSE = 0;&lt;BR /&gt;IrqDisable();&lt;BR /&gt;&lt;BR /&gt;// config to measure every 100ms in sleep&lt;BR /&gt;B_ACQ_TCMP = 100; // LP clock = 1KHz, depends on PF[1:0] setting&lt;BR /&gt;&lt;BR /&gt;// config to wakeup if |I| &amp;gt; 500mA&lt;BR /&gt;B_ACQ_CTH = (500&amp;gt;&amp;gt;1);&lt;BR /&gt;B_ACQ_THF = 0; &lt;BR /&gt;&lt;BR /&gt;// config to wakeup if Ah counter &amp;gt;xxx&lt;BR /&gt;B_ACQ_CTL = B_ACQ_CTL_AHCRM_MASK | B_ACQ_CTL_AHCR_MASK; // reset Ah counter&lt;BR /&gt;B_ACQ_AHTH = 60000L; // 100mA * 60s * 10S/s&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;ADCLpEnable();&lt;/STRONG&gt; &lt;BR /&gt;PCREnterStopMode();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//////////////////////&lt;BR /&gt;//---------------------------------------------------------------------&lt;BR /&gt;/*! \brief Enables CSENSE channel Acquisitions for low power modes.&lt;BR /&gt;&lt;BR /&gt;*/&lt;BR /&gt;void ADCLpEnable(void) {&lt;BR /&gt;&lt;BR /&gt;B_ACQ_CTL = (B_ACQ_CTL_CMENM_MASK | B_ACQ_CTL_CMEN_MASK)//!&amp;lt; enable current sense measurements&lt;BR /&gt;}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 06:07:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Current-threshold-and-Ah-counter-threshold-sample-code/m-p/1690049#M19306</guid>
      <dc:creator>Q_man</dc:creator>
      <dc:date>2023-07-21T06:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Current threshold and Ah counter threshold sample code</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Current-threshold-and-Ah-counter-threshold-sample-code/m-p/1692740#M19321</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/702"&gt;@Q_man&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;The sample code can work well. But I don't understand how to caculate the value of&amp;nbsp;B_ACQ_AHTH ,&lt;/P&gt;&lt;PRE&gt;B_ACQ_AHTH = 60000L; // 100mA * 60s * 10S/s&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;what's the unit of&amp;nbsp;B_ACQ_AHTH.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 06:36:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Current-threshold-and-Ah-counter-threshold-sample-code/m-p/1692740#M19321</guid>
      <dc:creator>gumu</dc:creator>
      <dc:date>2023-07-26T06:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Current threshold and Ah counter threshold sample code</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Current-threshold-and-Ah-counter-threshold-sample-code/m-p/1693873#M19328</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;In the example:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;The threshold of 60000 equals to 6000mA*s (e.g. applying 100mA for 60s should trigger the threshold)&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 06:52:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Current-threshold-and-Ah-counter-threshold-sample-code/m-p/1693873#M19328</guid>
      <dc:creator>Q_man</dc:creator>
      <dc:date>2023-07-27T06:52:59Z</dc:date>
    </item>
  </channel>
</rss>

