Hi all,
I am working on Battary management system, in that i am established the CAN communication and by using CAN cCANommunication i put the CAN module in sleep mode but i am unable to wakeup the processor.
Please help me to wake up the processor and below is the code.
if(CAN_IBS_Control.u16Var&0x8000) { // Goto Sleep Request
// goto sleep
err_status = Sleep_CAN(CAN0, CMPTX); // request CAN channel 0 go to sleep with completing transmission scheduled
do {
err_status = 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
ADCDisable();
TsenseDisable();
B_GPIO_VSENSE = 0;
CAN_STDBY(STANDBYMODE);
PTA_PTA1 = 0;
PCREnterStopMode();
// .....zzzzzzzzzzz (stop mode)
// after wakeup the code continues to run here....
// but first the D2D Interrupt service routine will be run
B_WD_CTL = WD_OFF;
B_PCR_CTL = OPM_SET_NORMAL; /* set normal mode*/ // bb
VsenseInit(&(vList[0]), &vListEntries, &(vValues[0]));
CsenseInit(&(cList[0]), &cListEntries, &(cValues[0]));
TsenseInit(&(tList[0]), &tListEntries, &(tValues[0]));
ADCInit();
CAN_STDBY(NORMALMODE);
}
已解决! 转到解答。
Baji,
to bring the reference design to low power mode these steps are required:
// goto sleep
err_status = Sleep_CAN(CAN0, CMPTX); // request CAN channel 0 go to sleep with completing transmission scheduled
do {
err_status = 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
ADCDisable();
TsenseDisable();
B_GPIO_VSENSE = 0;
MC33879_EN(0); // disable MC33879 (Octal SWITCH)
CAN_STDBY(STANDBYMODE); // disable MC33901 (CAN PHY)
PCREnterStopMode();
// .....zzzzzzzzzzz (stop mode)
6. Enter MM9Z1_638 low power mode:
// --------------------------------------------------------------------
/*! \brief Function to enter low power STOP mode.
*
* In STOP mode the VDDX = 5V will remain powered. The uC will be powered and also has to be set into uC STOP mode.
*
* After a wakeup (interrupt) the software continues to execute after the StopEnter() routine.
* The interrupt will straight away interrupt and execute the corresponding interrupt service routine in general isrD2D().
*
*/
void PCREnterStopMode(void) {
IrqDisable();
B_INT_MSK = 0xFF3F; // disable all Analog Interrupts
B_ACQ_SRH = 0xFF; // Clear pending Flags
B_INT_MSK = 0xFF00; // enable all Analog Interrupts
B_PCR_SR = 0xFFFF; // Clear Flags
B_PCR_CTL = OPM_SET_STOP; // Goto Stop Mode
StopEnable();
StopEnter();
}
Hi Baji,
1. could you please indicate what hardware platform (KT9Z1J638EVM = "EVB", RD9Z1J638-12V-CAN, etc.) you are using?
2. how do you want to wakeup (via CAN, etc.)?
A few general comments:
1. A wakeup due to CAN communication requires that the CAN PHY is powered. For the NXP hardware platforms this means that the MM9Z1_638 is in STOP mode which keeps the VDDX (5V) powered on whilst in low power mode. The SW snippet above indicates you are using STOP mode.
2. The wakeup is using the PTB4 pin wakeup.
W.
Thank you Q_man,
1. I am working with CAN transmission on MM9Z1_638 with demo board RD9Z1_638_4Li Rev 1.2.
2. I establish CAN communication between MM9Z1_638 and MICROCHIP CAN analyzer with demo code (RD9Z1_638_12VLA_CAN_demo).
3. My aim is to work low power modes with CAN protocol, in this process i am setting MSCAN is in Sleep Mode and MCU in stop mode and according to the datasheet to wake the MCU from stop mode using PTB4 ( For Wake-up i am setting of the NWUE bit in the GPIO_IN4 register and with the Wake-up Enable Bit (WUPTB4) and the port configuration bit (PTWU) set) But i am unable wake the MCU.
4. According to the datasheet during MCU stop mode VDDH is 0v & VDDX is 5.0v but i am observing during testing these levels VDDH is in 2.5v and VDDX is in 5.0v
Can you please help me to sort of this issue and i studied below given SW pdf but it is related to KT9Z1J638EVB.
Please provide the solution for RD9Z1_638_4Li board
Baji,
From your description it looks like the MM9Z1_638 is not entering Low Power mode. So we should first find out why this is happening!
Unfortunately do I not have a hardware setup in hands to test things (due to home office).
1. Could you please check that the correct pin is used for then CAN Standby:
// PTA6 is connected to CAN PHY STB pin
#define STANDBYMODE (1)
#define NORMALMODE (0)
#define CAN_STDBY(v) {DDRA_DDRA6 = 1; PTA_PTA6 = (v);}
2. Add code to enable and disable MC33879
// PTA7 is connected to MC33879 EN pin
#define MC33879_EN(v) {DDRA_DDRA7 = 1; PTA_PTA7 = (v);}
add enable before main loop
MC33879_EN(1); // enable MC33879
for EVER {
======================================
add disable before entering Stop Mode
MC33879_EN(0); // disable MC33879
CAN_STDBY(STANDBYMODE);
PCREnterStopMode();
3. Please test and check:
Rgds
W.
Thank you Q_man,
1. I have check the CAN PHY STB pin and it is connected to PTA0 by default and according to the Transceiver datasheet i change the CAN PHY STB pin to PTA6
2. Added the code for enable and disable MC33879 by using function MC33879_EN(v)
I follow below mentioned procedure, i add the code for MC33879 enable and disable functions (MC33879_EN(1) in for loop and MC33879_EN(0) in sleep function before these functions CAN_STDBY(STANDBYMODE); )PCREnterStopMode();)
3. Check the voltages across PTA7 and VDDH & VDDX
a. During normal mode PTA7 is High, VDDX=5v & VDDH=2.5v
b. During sleep mode and before execution of MC33879_EN(0), the voltage across PTA7 is High, VDDX=5v & VDDH=2.5v
c. During sleep mode and after execution of MC33879_EN(0) the voltage across PTA7 is Low, VDDX=5v & VDDH=2.5v
I observed these voltage levels in my board, and i didnot get the 0volts across VDDH during sleep mode. Please help me to sort this issue and what is the reason and why i am not getting the 0v across VDDH.
Here i am attaching the updated code, please check the MC33879_EN(v) function and if any changes needed in the updated code, please update me according to that i will modify the code and check the code again and get back you.
// --------------------------------------------------------------------
#include "drv638.h" // driver for MM9Z1-638
#include "nvm.h" // nvm driver
#include <stdio.h> // sprintf
#include "main.h"
#include "soc.h"
#include "rd9z1_638_12vc.h"
#include "ntc.h"
#include "service.h"
#include "usercan.h"
#include "msCANdrv.h"
// For CAN bit Timing see AN1798.pdf
extern u8 wak_int;
// --------------------------------------------------------------------
// This demo software is provided "AS-IS".
// For documentation please see the folder \docu\documentation.html
// --------------------------------------------------------------------
//---------------------------------------------------------------------
/*! \brief Structure for Clock configuration for CAN demo
- use external oscillator (16.000MHz) as reference clock (divide by 16)
- target VCO clock: 50.000MHz
- target core clock: 50.000MHz
- target bus clock : 25.000MHz
- target D2D clock : 25.000MHz
*/
TYPE_CPMU_CONF const ClockConf = {
ClockSrc_EXT,
VCO_RANGE,
SYNR(CLOCK_VCO, CLOCK_REF),
REFCLK_FREQ_1_2_MHZ_RANGE, // Ref is IRC = 1.000MHz
// REFDIV(4), // Refdivider div = 4 (4MHz quarz)
REFDIV(16), // Refdivider div = 16 (16MHz quarz)
POSTDIV(CLOCK_VCO, CLOCK_BUS),
PLL_FREQ_MOD_0_PERCENT,
PCRPRE(CLOCK_D2D), // PCR prescaler
D2DDIV(CLOCK_BUS, CLOCK_D2D)
};
// --------------------------------------------------------------------
//! \brief TSENSE list of channels to convert...
TYPE_TSENSE_LIST const tList[] = {
// ch , avg
CH_TSENSE_ITS , 1, 6, //!< measure internal chip temperature
TSENSE_EXT , 1, 6 //!< measure external temperature sensor (NTC)
};
const u8 tListEntries = sizeof(tList)/sizeof(TYPE_TSENSE_LIST); //!< number of entries in the list above
static u16 tValues[sizeof(tList)/sizeof(TYPE_TSENSE_LIST)]; //!< RAM buffer for the TSENSE module
// --------------------------------------------------------------------
//! \brief VSENSE list of channels to convert...
TYPE_VSENSE_LIST const vList[] = {
// ch , avg , latency
CH_VSENSE2 , 100, 12,
};
const u8 vListEntries = sizeof(vList)/sizeof(TYPE_VSENSE_LIST); //!< number of entries in the list above
static u16 vValues[sizeof(vList)/sizeof(TYPE_VSENSE_LIST)]; //!< RAM buffer for the VSENSE module
// --------------------------------------------------------------------
//! \brief CSENSE list of channels to convert...
TYPE_CSENSE_LIST const cList[] = {
// ch , avg , latency
CH_CSENSE , 100 , 0
};
const u8 cListEntries = sizeof(cList)/sizeof(TYPE_CSENSE_LIST); //!< number of entries in the list above
static s32 cValues[sizeof(cList)/sizeof(TYPE_CSENSE_LIST)]; //!< RAM buffer for the TSENSE module
/*
// --------------------------------------------------------------------
// PTA0 is connected to MC33901 STB pin
#define STANDBYMODE (1)
#define NORMALMODE (0)
#define CAN_STDBY(v) {DDRA_DDRA0 = 1; PTA_PTA0 = (v);}
*/
// --------------------------------------------------------------------
// PTA6 is connected to MC33901 STB pin
#define STANDBYMODE (1)
#define NORMALMODE (0)
#define CAN_STDBY(v) {DDRA_DDRA6 = 1; PTA_PTA6 = (v);}
// PTA7 is connected to MC33879 EN pin
#define MC33879_EN(v) {DDRA_DDRA7 = 1; PTA_PTA7 = (v);}
// ---------------------------------------------------------------------
// private prototypes
void GPIOInit(void);
void LTCInit(void);
void asciitohexa(char* input, char* output); // Change by baji
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
void main(void) {
u16 TSensor[tListEntries];
u16 VSensor[vListEntries];
s32 CSensor[cListEntries];
TYPE_CAN_IBS_Data CAN_IBS_Data;
TYPE_CAN_IBS_Data_Ext CAN_IBS_Data_Ext;
u8 rec_data[9]={0},trans_arr[8],rec_flag;
TYPE_CAN_IBS_CONTROL CAN_IBS_Control;
MSCAN_TYPE_ERROR_CODE err_status; //To store the return value of the driver APIs.
MSCAN_TYPE_STATUS mbStat;
u8 CAN_status[3]; //CAN_status to store channel status,byte 0 store CANCTL0, byte 1 store CANCTL1, byte 2 store CANRFLG
u8 u8ModeTimer;
u32 u32Temp;
static TYPE_BATTERY Battery;
s16 s16Vdrop;
u8 u8WakeUpReason;
u8 u8ChipTemp;
u16 u16Result;
Bool WriteSystemCalibrationValues = FALSE; // do not change !!!
SYS_Init();
CPMUInit(&ClockConf);
D2DInit((TYPE_D2DCLKDIV) ClockConf.D2dDiv);
XirqEnable(); // enable XIRQ -> isrD2DErr() "write-once"
if (B_PCR_CTL_OPM & 2) { // Check if Wake Up from Sleep mode (see page RM3.0 110 Intermediate Mode)
u32Temp = B_ACQ_AHC;
B_PCR_CTL = OPM_SET_NORMAL; // set normal mode
while (!(B_PCR_SRH_WLPMF )) DO_NOTHING; // Wait for Clock Domain Change \! /todo where is this described?
}else{
if(!B_PCR_SR_HWRF) {
PCRReset(); // generate a HWR reset to ensure analog die is in defined state! E.g. debugging might cause strange effects in case bits are set from before //
}
}
B_WD_CTL = WD_OFF;
u8WakeUpReason = 0;
// evaluate wakeup reason
if(B_PCR_SR_WULINF) { // wakeup caused by LIN
u8WakeUpReason = 1;
}
if(B_PCR_SR_WUAHTHF) {
u8WakeUpReason = 2;
}
if(B_PCR_SR_WUCALF) {
u8WakeUpReason = 3;
}
if(B_PCR_SR_WUCTHF) { // current threshold
u8WakeUpReason = 4;
}
if(B_PCR_SR_WULTCF) {
u8WakeUpReason = 5;
}
B_PCR_SRH = 0xFF; // clear all flags
PCRInit(ClockConf.PCRprescaler);
SYSStartupTrimming();
//! \brief Set a breakpoint to this line and change the variable WriteSystemCalibrationValues to TRUE in the debugger to write values \ref CalibWrite
if(WriteSystemCalibrationValues) { // hook to manually write system calibration values to eeprom during sw development
CalibWriteManual();
}
if(CalibRead()==FALSE) { // reads system calibration data from EEPROM (if avaliable). needs to be before ADCInit()
CalibDefault(); // otherwise use default values
}
VsenseInit(&(vList[0]), &vListEntries, &(vValues[0]));
CsenseInit(&(cList[0]), &cListEntries, &(cValues[0]));
TsenseInit(&(tList[0]), &tListEntries, &(tValues[0]));
ADCInit();
GPIOInit();
LTCInit();
CAN_STDBY(NORMALMODE);
// IBS control frame
CAN_IBS_Control.u8Len = 2;
err_status = Init_CAN(CAN0, FAST); //Initialization msCAN channel 0, FAST means the reset won't wait until current transmit completed
do{
err_status = Check_CAN_Status(CAN0, CAN_status);
}while ((CAN_status[0] & SYNCH) == 0); //Wait for msCAN channel 0 synchronized to CAN Bus
err_status = Config_CAN_MB(CAN0, CANBUF1, TXDF, CAN_MO1); //configure the msCAN channel 0, buffer 1 to be TXDF mode (transmit dataframe) -> message object 1,see details in "MSCANID.h"
err_status = Config_CAN_MB(CAN0, CANBUF2, TXDF, CAN_MO2); //configure the msCAN channel 0, buffer 2 to be TXDF mode (transmit dataframe) -> message object 2
err_status = Config_CAN_MB(CAN0, CANBUF3, RXDF, CAN_MO3); //configure the msCAN channel 0, buffer 3 to be RXDF mode (receive dataframe) -> message object 3
Battery.tMode = BM_PARKING; // used to get an initial OCV based SoC
SoCInit();
RTIInit();
RTIEnable();
IrqEnable();
u8ModeTimer = 50; // timed mode change from parking -> driving (5*100ms)
for EVER {
MC33879_EN(1); // bb
switch(Battery.tMode) {
case BM_PARKING:
case BM_DRIVING:
// ----- measurements, voltage, current and temp ------
if(TsenseGetValue(CH_TSENSE_ITS, &TSensor[0])) { // request data
u8ChipTemp = (u8)(TSensor[0]/TSENSE_ITS_INVRES+K2C+40); // scale to deg C with offset 40
}
if(TsenseGetValue(TSENSE_EXT, &TSensor[1])) {
Battery.u16TempK = NTCRaw2Kelvin(NTCconvert, TSensor[1]);
}
if(CsenseGetValue(CH_CSENSE, &CSensor[0])) {
Battery.s32mAFilt = CSensor[0];
}
if(VsenseGetValue(CH_VSENSE2, &VSensor[0])) { // if 0 channel is converted then
#if (ISENSE_GND_REF==ISENSEL)
// ISENSEL is GND reference
s16Vdrop = (s16)(Battery.s32mAFilt/G_SHUNT); // calculated shunt drop voltage
Battery.u16mV = (VSensor[0]>>1) - s16Vdrop; // scale to mV and correct shunt drop voltage
#endif
#if (ISENSE_GND_REF==ISENSEH)
// ISENSEH is GND reference
Battery.u16mV = VSensor[0]>>1; // scale to mV and no correction
#endif
}
if(RTIEvery100ms()) {
SoCUpdate(&Battery);
TsenseHandler(); // temperature needs to be done polling (V,I interrupt driven)
if(u8ModeTimer>0) { // timed mode change from parking -> driving (5*100ms)
u8ModeTimer--;
}else{
Battery.tMode = BM_DRIVING;
}
CAN_IBS_Data.FrameLen = 8;
CAN_IBS_Data.BatVolt = u16Swap(Battery.u16mV); // scale to mV
CAN_IBS_Data.BatCurr = u32Swap(Battery.s32mAFilt);
CAN_IBS_Data.BatTemp = (u8)(Battery.u16TempK+K2C+40);
CAN_IBS_Data.BatMode = Battery.tMode;
err_status = Load_CAN_MB(CAN0, CANBUF1, CAN_IBS_Data.byte);
err_status = Transmit_CAN_MB(CAN0, CANBUF1);
}
if(RTIEvery1000ms()) {
CAN_IBS_Data_Ext.FrameLen = 6;
CAN_IBS_Data_Ext.ChipTemp = u8ChipTemp;
CAN_IBS_Data_Ext.SOC = Battery.u8SoC;
CAN_IBS_Data_Ext.Coulomb = u32Swap(Battery.u32CoulombCnt);
err_status = Load_CAN_MB(CAN0, CANBUF2, CAN_IBS_Data_Ext.byte);
err_status = Transmit_CAN_MB(CAN0, CANBUF2);
}
break;
case BM_CALIBRATION:
ServiceApp();
break;
default:
break;
}
// read message object .....
(void) Check_CAN_MB_Status(CAN0, CANBUF3, &mbStat);
if((mbStat.Status == NEWDATA) || (mbStat.Status == OVERRUN)) { //Wait for the Receive ISR to finish and change the buffer status, NEWDATA indicates that the buffer has receive a new data
if(wak_int == 10){
wak_int=1;
}
err_status = Read_CAN_MB_Data(CAN0, CANBUF3, CAN_IBS_Control.byte);//Copy the received data in msCAN channel 0 buffer 2 to data_rec;
CAN_IBS_Control.u16Var = u16Swap(CAN_IBS_Control.u16Var);
//Clear buffer_status[0]
//err_status = Read_CAN_MB_Data(CAN0, CANBUF3, rec_data);
err_status = Load_CAN_MB(CAN0, CANBUF1, CAN_IBS_Control.byte);
err_status = Transmit_CAN_MB(CAN0, CANBUF1);
mbStat.Status = NODATA;
if(CAN_IBS_Control.u16Var&0x8000) { // Goto Sleep Request
// goto sleep
err_status = Sleep_CAN(CAN0, CMPTX); // request CAN channel 0 go to sleep with completing transmission scheduled
do {
err_status = 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
ADCDisable();
TsenseDisable();
B_GPIO_VSENSE = 0;
MC33879_EN(0); // bb
CAN_STDBY(STANDBYMODE);
PTA_PTA1 = 0;
PCREnterStopMode();
// .....zzzzzzzzzzz (stop mode)
// after wakeup the code continues to run here....
// but first the D2D Interrupt service routine will be run
B_WD_CTL = WD_OFF;
//B_PCR_CTL = OPM_SET_NORMAL; /* set normal mode*/ // bb
VsenseInit(&(vList[0]), &vListEntries, &(vValues[0]));
CsenseInit(&(cList[0]), &cListEntries, &(cValues[0]));
TsenseInit(&(tList[0]), &tListEntries, &(tValues[0]));
ADCInit();
CAN_STDBY(NORMALMODE);
}
if(CAN_IBS_Control.u16Var&0x1000) { // Goto Calib mode
Battery.tMode = BM_CALIBRATION;
CAN_IBS_Data.BatMode = Battery.tMode;
err_status = Load_CAN_MB(CAN0, CANBUF1, CAN_IBS_Data.byte);
err_status = Transmit_CAN_MB(CAN0, CANBUF1);
err_status = Config_CAN_MB (CAN0, 8, RXDF, 8);
err_status = Config_CAN_MB (CAN0, 9, TXDF, 9);
}
if(CAN_IBS_Control.u16Var&0x2000) { // Goto normal mode
Battery.tMode = BM_DRIVING;
VsenseInit(&(vList[0]), &vListEntries, &(vValues[0]));
CsenseInit(&(cList[0]), &cListEntries, &(cValues[0]));
TsenseInit(&(tList[0]), &tListEntries, &(tValues[0]));
ADCInit();
}
}
} // for EVER
}
// ---------------------------------------------------------------------
/*! \brief Init GPIO
<b>Configuration used for the RD9Z1_638_12VLA_CAN_Demo:</b>
| Pin | Enabled | Direction | Routing | used for |
|:----------:|:--------:|:---------:|:-------:|------------------------------------|
| PTB0 | - | - | | analog input |
| PTB1 | disabled | n.a. | | not used |
| PTB2 | disabled | n.a. | | not used |
| PTB3 | disabled | n.a. | | not used |
| PTB4 | enabled | input | PTWU | CAN PHY wake up input |
| PTB5/GNDSW | - | - | - | GND switch for TSENSE_EXT |
*/
void GPIOInit(void) {
B_GPIO_CTL = GPIO_CTL_PTB1_DISABLE | GPIO_CTL_PTB1_INPUT;
B_GPIO_CTL = GPIO_CTL_PTB2_DISABLE | GPIO_CTL_PTB2_INPUT;
B_GPIO_CTL = GPIO_CTL_PTB3_DISABLE | GPIO_CTL_PTB3_INPUT;
// B_GPIO_PUC_PDE4 = 1; // enable pull down (missing on KT9Z1638EVM)
B_GPIO_CTL = GPIO_CTL_PTB4_ENABLE; // PTB4 is used for CAN Wakeup
B_GPIO_IN4 = IN4_PTWU|IN4_NWUE; // enable WU in low power mode, negative edge
}
// ---------------------------------------------------------------------
/*! \brief
*
*/
void LTCInit(void) {
B_LTC_CTL = B_LTC_CTL_LTCEM_MASK | B_LTC_CTL_LTCE_MASK; // LTC enable, no interrupt
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// --------------------------------------------------------------------
interrupt VectorNumber_Vcan0wkup void isrCANWakeup(void) {
CAN_Wakeup(CAN0);
}
// --------------------------------------------------------------------
interrupt VectorNumber_Vcan0err void isrCANErr(void) {
CAN_ERR(CAN0);
}
// --------------------------------------------------------------------
interrupt VectorNumber_Vcan0tx void isrCANTx(void) {
CAN_Transmit(CAN0);
}
// --------------------------------------------------------------------
interrupt VectorNumber_Vcan0rx void isrCANRx(void) {
CAN_Receive(CAN0);
}
Hi Baji,
what is the status on this issue?
One other potential problem could be a connected Debugger. It's not possible to enter STOP mode on the uC with the debugger connected! So please try without debugger!
W.
Hi,
I just tried it with the RD9Z1_638-4Li board and its works Sleep (=STOP) and Wakeup.
Trace Sleep -> Wakeup
You can see the Goto To Sleep -> PTA7 = low and VDDH = 0V and wakeup via CAN PTA7 = high and VHHD = 2.5V.
Thank you Q_man,
I got the output, please confirm what is the use of MC33879_EN(v) function and explain what is the relation between VDDH and PTA7. Is it compulsory, to add this MC33879_EN() function to my code. If MC33879_EN() function is not thier in my code what happens?
Hi Baji,
I intended to use the PTA7 for debugging (to see if Sleep is entered) and to actually control the MC33879 Power modes. Also see https://www.nxp.com/docs/en/data-sheet/MC33879.pdf datasheet.
There is no relationship to VDDH. VDDH is shut down in MM9Z1_638 STOP mode, so a indicator if the device is in STOP or not.
Thank you Q_man,
I study the datasheet of MC33879 to control the power modes but i didn't understand how the mscan module entered into sleep mode. Please explain how the mscan module enters into sleep mode?
Baji,
to bring the reference design to low power mode these steps are required:
// goto sleep
err_status = Sleep_CAN(CAN0, CMPTX); // request CAN channel 0 go to sleep with completing transmission scheduled
do {
err_status = 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
ADCDisable();
TsenseDisable();
B_GPIO_VSENSE = 0;
MC33879_EN(0); // disable MC33879 (Octal SWITCH)
CAN_STDBY(STANDBYMODE); // disable MC33901 (CAN PHY)
PCREnterStopMode();
// .....zzzzzzzzzzz (stop mode)
6. Enter MM9Z1_638 low power mode:
// --------------------------------------------------------------------
/*! \brief Function to enter low power STOP mode.
*
* In STOP mode the VDDX = 5V will remain powered. The uC will be powered and also has to be set into uC STOP mode.
*
* After a wakeup (interrupt) the software continues to execute after the StopEnter() routine.
* The interrupt will straight away interrupt and execute the corresponding interrupt service routine in general isrD2D().
*
*/
void PCREnterStopMode(void) {
IrqDisable();
B_INT_MSK = 0xFF3F; // disable all Analog Interrupts
B_ACQ_SRH = 0xFF; // Clear pending Flags
B_INT_MSK = 0xFF00; // enable all Analog Interrupts
B_PCR_SR = 0xFFFF; // Clear Flags
B_PCR_CTL = OPM_SET_STOP; // Goto Stop Mode
StopEnable();
StopEnter();
}
Thank you Q_man for helping me to sort of this wake up issue,
I intially tested the my test setup in debug mode, due to this the wake up interrupt is not happening.When i run the setup in continuous mode i got the output, unfortunately i comment the function MC33879(v) even though i can see the output and also by using sleep & wake up commands i can control the output.
During normal mode, the MC33879 En pin is high and i am getting the values like VDDX=5v, VDDH=2.5v, PTA7 is high and Current is approx 40milliAmps and CAN in normal mode
During MSCAN Module sleep mode, the MC33879 En pin is low and i observed these values VDDX=5v, VDDH=0v, PTA7 is low and Current is approx 6milliAmps and CAN in standby mode and MCU in STOP mode.
According to the datasheet of MC33879, it is showing The EN pin on the 33879 enables the device. With the EN pin high, output drivers may be activated and open/short fault detection
performed and reported. With the EN pin low, all outputs become inactive, open load detection current is disabled, and the device enters Sleep mode. The 33879 performs Power-ON Reset on the rising edge of the enable signal.
but my doubt is without using the MC33879 EN pin also i am getting the same values like
During normal mode, the MC33879 En pin is not connected and observed values like VDDX=5v, VDDH=2.5v, PTA7 is low and Current is approx 40milliAmps and CAN in normal mode
During MSCAN Module sleep mode, the MC33879 En pin is not connected and observed values are VDDX=5v, VDDH=0v, PTA7 is low and Current is approx 6milliAmps and CAN in standby mode and MCU in STOP mode.
I did not find any current deferences also, Please explain some detailed manner regards this MC33879 octal serial switch
Why am i asking this means i am planning to build one hardware setup based on EVK board, i didnot understand i have to use this IC in my design or not?
One more favour, please explain how to check the raw values of Vsense, Isense and Tsense, according to the demo code i unable to check the above Vsense, Isense and Tsense values because CAN is in Continuous mode.
Please suggest a procedure to find the values.
Baji,
what type of BMS are you working on? For Lead Acid or LiIon cells?
On the hardware platform you have the MC33879 Octal Switch was intended for the cell balancing of the 4 LiIon cells and the 4 unused switches are available as High-Side or Low-Side output for other purposes.
If I understand you correct you do NOT intend to use any of the switches, correct? In this case we do not have to use it.
The stop mode current of 6mA is to high. To measure the Stop current the debugger must be disconnected! It would be helpful if you could provide your external circuitry (what is connected where).
W.
Thank you Q_man,
Sorry for the delay response, i tested these stop mode current 6 milli amps and remaining voltages on EVK board(RD9Z1_638_4Li v1.2).
I am planning to design a hardware(BMS) with Lead acid battery, based on our discussion i understood that for LiIon cell batterys only need this MC33879 octal switch.
It means with out using this MC33879_EN(v) also CAN demo project is working? and if i add this CAN code to my design my code works as expecetd(with out using this MC33879_EN(v) function )?
Based on our discussion For lead acid battery need not necessary MC33879 octal switch, then i can proceed my design without this MC33879 octal switch
Baji,
Yes, I expect you do not need the MC33879 in your design. You also might take a look at our 12V Lead Acid Reference Design with CAN:
https://www.nxp.com/design/designs/12-v-lead-acid-battery-sensor-with-can:RD9Z1-638-12V-C
If you want I can review your designs schematics (wolfgang.bihlmayr@nxp.com)
W.
Thank you Q_man,
I understand very much the low power modes but my doubt is with out using this function (MC33789_EN(v)) also i am getting the output, in that scenerio i didn't understand the use of this MC33879 (Octal switch). Please give some more clarity on particular this MC33879 (Octal switch) only.
Hello @baji,
I see that source of the wakeup in your code is PTB4.
Please refer to the datasheet.
Please make sure it is configured as explained above before the MCU goes to the Stop mode.
And apply a wakeup signal to PTB4 according to the configuration.
Thank you,
BR, Daniel