how to enter stop mode for mm912f634?

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

how to enter stop mode for mm912f634?

1,314 Views
zhou
Contributor III

The MM912F634 analog die offers three main operating modes: Normal (Run), Stop, and Sleep.

I can enter sleep mode use "B_MCR = 2",but I can enter stop mode use "B_MCR = 1".

I don't know what to do before enter stop mode.

Labels (1)
Tags (3)
4 Replies

963 Views
javiervicandi
Contributor II

Hi,

Here, two versions of a function to go to STOP, waking up by means of a timer in a case and from LIN in other one.

//--------------------------Analog Die

//MCR(0x016) Mode Control Register pag. 53 de MM912F634_V06.pdf

// --- --- --- --- --- --- MODE1 MODE0

//Para pasar a STOP ponemos MODE0 a ON

#define STOP_U8 (0x01U)

#define NORMAL_U8 (0x00U)

#define MS_ANTES_DE_STOP_U16 (50U) //Antes de pasar a STOP ''

//*****************************************************************************

//@fn          halMcuStop

//

//@brief       Pone el uC en STOP

//

//@param       _SOFT_BOOL b8dooropen. A TRUE_B8 indica que la puerta estaba abierta

// antes del bajo consumo.

//

//@return      none

//En esta función se prima la velocidad de ejecución por lo que se introduce

//código en línea en vez de usar funciones.

//*****************************************************************************

#if defined(MASTER)

void halMcuStop(_SOFT_BOOL b8dooropen)

  {

  volatile _SOFT_U8BITS u8data_read;

  u8mode_cpu = STOP_MODE_U8;

  halTIMStop(); //This method stops the TIM module

// El ADC está detenido y con la interrupción deshabilitada en este punto. No se requiere ninguna acción

  halRTIStop(b8dooropen); //Prepara el RTI para modo STOP. El timer seguirá corriendo.

  halMcuWaitMs(MS_ANTES_DE_STOP_U16);

  if (b8dooropen == FALSE_B8){

  while(u8mode_cpu == STOP_MODE_U8){

  halSPIStop(); //Desactivo el módulo SPI para reducir consumo

  MCR = STOP_U8;   // Put analog die to STOP mode

  asm ANDCC #0x6F; // enable STOP instruction

    asm STOP;         // put core to STOP mode

  asm NOP;

  //En el master el MCU despierta al Analog Die

  MCR = NORMAL_U8; //Analog die in NORMAL mode.

  u8data_read = WSR;

  halSPIStart(); //Activo el módulo SPI para leer puerta

  //En el master se escruta el estado de la puerta

  CS_INPUT = N_ON_U8; //Leemos detector de puerta

  (void)halPutchSpi(SPI_CONTROL_READ_BYTE_U8); //Cabecera preeliminar para lectura

  (void)halPutchSpi(ADDR_GPIO_U8); //Dirección registro de IOs

  u8data_read = halPutchSpi(NO_OP_U8); //Byte enviado sin importancia

  CS_INPUT = N_OFF_U8;

  if ((u8data_read & (DET_PUERTA_MASK_U8 | WATCH_DT_MASK_U8)) != (DET_PUERTA_MASK_U8 | WATCH_DT_MASK_U8)){

  u8mode_cpu = RUNNING_MODE_U8; //Puerta abierta

  // (void)SEQ_AddEvent(eDOORopen); //Puerta no cerrada.

  }//((u8data_read & WATCH_DT_MASK_U8) == INPUT_DIG_ACTIV_U8)

  }//(u8mode_cpu == STOP_MODE_U8)

  }//(b8dooropen == FALSE_B8)

  else{

  while(u8mode_cpu == STOP_MODE_U8){

  halSPIStop(); //Desactivo el módulo SPI para reducir consumo

  MCR = STOP_U8;   // Put analog die to STOP mode

  asm ANDCC #0x6F; // enable STOP instruction

    asm STOP;         // put core to STOP mode

  asm NOP;

  //En el master el MCU despierta al Analog Die

  MCR = NORMAL_U8; //Analog die in NORMAL mode.

  u8data_read = WSR;

  halSPIStart(); //Activo el módulo SPI para leer puerta

  //En el master se escruta el estado de la puerta

  CS_INPUT = N_ON_U8; //Leemos detector de puerta

  (void)halPutchSpi(SPI_CONTROL_READ_BYTE_U8); //Cabecera preeliminar para lectura

  (void)halPutchSpi(ADDR_GPIO_U8); //Dirección registro de IOs

  u8data_read = halPutchSpi(NO_OP_U8); //Byte enviado sin importancia

  CS_INPUT = N_OFF_U8;

  if (((u8data_read & (DET_BOTE_MASK_U8 | WATCH_DT_MASK_U8)) != (DET_BOTE_MASK_U8 | WATCH_DT_MASK_U8)) ||

  (u8data_read | (DET_PUERTA_MASK_U8 ^ COMP_O_EX_U8)) != (DET_PUERTA_MASK_U8 ^ COMP_O_EX_U8)){

  u8mode_cpu = RUNNING_MODE_U8; //Puerta abierta

  // (void)SEQ_AddEvent(eDOORopen); //Puerta no cerrada.

  }//((u8data_read & WATCH_DT_MASK_U8) == INPUT_DIG_ACTIV_U8)

  }//(u8mode_cpu == STOP_MODE_U8)

  }//NO (b8dooropen == FALSE_B8)

  halInitWatchdog();//20/04/2010 5:06:40 Se pone delante. Primero se configura el time-out

  //del watchdog

  halRTIStart();

  halTIMStart();

  //halInitWatchdog();

  }//Fin de halMcuStop

#endif // defined(MASTER)

#if defined(SLAVE)

void halMcuStop(void)

  {

  u8mode_cpu = STOP_MODE_U8;

  halTIMStop(); //This method stops the TIM module

// El ADC está detenido y con la interrupción deshabilitada en este punto. No se requiere ninguna acción

  halSPIStop(); //Desactivo el módulo SPI para reducir consumo

  halMcuWaitMs(MS_ANTES_DE_STOP_U16);

  MCR = STOP_U8;   // Put analog die to STOP mode

  asm ANDCC #0x6F; // enable STOP instruction

   asm STOP;         // put core to STOP mode

  asm NOP;

//En el esclavo el Analog Die (LIN) despierta al MCU

  u8mode_cpu = RUNNING_MODE_U8;

  halInitWatchdog();//20/04/2010 5:06:40 Se pone delante. Primero se configura el time-out

  //del watchdog

  halSPIStart(); //Activo el módulo SPI

  halTIMStart();

  //halInitWatchdog();

  }//Fin de halMcuStop

#endif //defined(SLAVE)

963 Views
zhou
Contributor III

Thank you very much,I Understand.

Analog Die and MCU Die need different commands.

0 Kudos

963 Views
alirezabazm
Contributor I

hi javier
i have a question about mm912 MCU (S12 family) i will be so appreciated if you help me.
you use
MCR = STOP_U8;   // Put analog die to STOP mode
asm ANDCC #0x6F; // enable STOP instruction  
  asm STOP;         // put core to STOP mode

but after asm STOP there is no clock and cpu completely stopped. how program can continue after this line?

moreover i dont know what is the effect of MCR=01  because without MCR=01 and just by ANDCC=0x6F and asm STOP . we enter in Stop mode

0 Kudos

963 Views
javiervicandi
Contributor II

Hi Alireza,

We had two cases: SLAVE and MASTER.

We needed a external source like LIN (ANALOG DIE) and another internal such as the RTI timer, keep running, to wake-up the MCU and to continue running the code. 

Best Regards

0 Kudos