MM9Z1_638 sleep mode issue

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

MM9Z1_638 sleep mode issue

731 Views
baji
Contributor I

I am working with CAN transmission on MM9Z1_638 with demo board RD9Z1_638_4Li Rev 1.2, We establish CAN communication between MM9Z1_638 and MICROCHIP CAN analyzer with demo code (RD9Z1_638_12VLA_CAN_demo). The data is transmitting from MM9Z1_638 to CAN analyzer is ok and receiving data from CAN analyzer to MM9Z1_638 is also working ok. But what is the below sleep mode(CAN_IBS_Control.u16Var&0x8000), calibration mode(CAN_IBS_Control.u16Var&0x1000) & normal mode(CAN_IBS_Control.u16Var&0x2000) commands and Please help me to understanding these commands.

Here i am attching the code 

// 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

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;

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;
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();
}

0 Kudos
Reply
1 Reply

717 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @baji,

I'm not the owner of the demo and the demo is provided "as is".

But you can see what it does from the code.

For example, the Goto Sleep command puts the MSCAN do Sleep mode and the MCU into Stop mode.

The other two commands change the value of this switch:

danielmartynek_0-1642768064677.png

and so on.

Please go line by line and look into the code.

If the code accesses a register, please refer to the datasheet

 

Regards,

Daniel

0 Kudos
Reply