AnsweredAssumed Answered

MPXY8300 example code doubts

Question asked by Nemanja Savic on Jun 19, 2015
Latest reply on Jul 6, 2015 by Nemanja Savic

Hello guys,


while waiting for my MPXY8300 chip to arrive, I am looking at the provided example code for dev KIT and reading datasheet. The example code is explained in reference manual while complete code was posted in this thread few years ago . Unfortunatelly I couldn't find if any update of the code was released meanwhile.

However I would like to ask you a few questions about the code.


So, first, at the begining of the main function, the autho of the code setup timers that will be used throughout the application:


  SRS=0x00;   //The COP timer is reset by writing any value to the address of               //SRS. This write does not affect the data in the read-only SRS. Instead, the act of writing to               //this address is decoded and sends a reset signal to the COP timer.       __RESET_WATCHDOG();       EnableInterrupts;   SOPT1=0x33;  /*****************Main Time Base for the whole application************************/    PWUSC0_WUFACK=1;      PWUDIV = 0x2F;      //    EVERY SECOND         PWUSC0 = 0x02;        //    PERIODIC WAKE-UP EVERY 2 sec.       PWUSC1 = 0x00;        //    NO PERIODIC RESET   /********************************************************************************/


As can be seen the wake up interrupt will occure every 2 sec. The rest of the code is:



     InitLF();      RF_Setup();      SPMSC1_BGBE=1;  //Enable Bandgap      Measure_P_T_V();      // Acceleration Z byte      REIMS_READ_COMP_ACCEL_Z(&Acc_Z_Array,Pressure_Array[1],1,0);      delay(10);      PACCZ=Acc_Z_Array[1]>>2;                 // Acceleration X byte      REIMS_READ_COMP_ACCEL_X(&Acc_X_Array,Pressure_Array[1],1,0);      delay(10);      PACCX=Acc_X_Array[1]>>2;      Send_RF_Datagram();      SOPT2=0x70;     //   RESET VALUES      SPMSC1=0x10;    //  0x10 :  STOP 1 MODE CONFIGURED LVDE & LVDSE = 0      SPMSC2=0x02;    // 02 ---> PDC = 1 ; PPDC = 0 STOP1      __asm STOP;


So, after the initialization, chip goes to power saving mode stop1. There it stay untill LF command was received or until wake up interrupt occures.

What I don't understand here is following: Where is 60 seconds period of transmission set? There is no counter, nothing.

ISR code for wake up timer looks like this:


void interrupt USER_4_INTERRUPT(void) {   PWUSC0_WUFACK = SET;  PWUSC1_PRFACK = SET;   Periodic_Wake_UP_Measures();   //ok passe ici d'abord // _asm cli;  //_asm rti;           //supprimer avant // _asm cli; }


It calls periodically function for measuring P, V and T. This function is:


void  Periodic_Wake_UP_Measures() { unsigned char i; EnableInterrupts;  _asm rti; }


As can be seen function Periodic_Wake_Up_Measures does nothing (I supose it was left for the user to specify) except enabling interrupt and returning from interrupt (which I also don't unterstand why it was called explicitly, hope somebody could explain this also)


On the other hand, datasheet says that device recovering from stop1 mode will take reset vector, which means that the program will start at the begining of main function, which means that there is no ISR.


Now, having all previous in mind, it looks like this code will wake up every 2 seconds and transmit data over radio.


The ost turned out quite long, but if anybody has experience with MPXY8300 I am thankfull inadvance for your help.


Best regards,