Part Number: MSP-EXPCC430RFX
I am using msp-expcc430. Through the
/******************************************************************************* * * MspExp430F5137RxUserExperience.c - Main User Experience Application * * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ******************************************************************************/ /*---------------------------------------------------------------------------- * MSP-EXP430F5137Rx User Epxerience Code * End device, connects to Access Point MSP-EXP430F6137Rx in a star network * topology. * Transmits device's analog data (Vcc, Temp) as well as button presses to the * AP periodically. * * Version 1.0 D. Dang * * Texas Instruments, Inc. * Copyright 2011 Texas Instruments Incorporated. All rights reserved. * *---------------------------------------------------------------------------- */ #include "bsp.h" #include "mrfi.h" #include "nwk_types.h" #include "nwk_api.h" #include "bsp_leds.h" #include "bsp_buttons.h" #include "hal_leds.h" #include "hal_buttons.h" #include "hal_adc.h" #define MESSAGE_BUTTON_PRESSED 0xFF #define MESSAGE_HEART_BEAT 0xEE #define USER_EXPERIENCE_FIRMWARE_MODE 0x00 #define USER_EXPERIENCE_PRODUCTION_TEST_MODE 0xFF /*----------------------------------------------------------------------------- * * * Packet construct: * Byte 0: Message Type [HeartBeat or ButtonPressed] * Byte 1: Content Vcc MESSAGE_BUTTON_PRESSED * Byte 2: Content Temp_MSB MESSAGE_BUTTON_PRESSED * Byte 3: Content Temp_LSB MESSAGE_BUTTON_PRESSED * Byte 4: PacketID MSB * Byte 5: PacketID LSB * *---------------------------------------------------------------------------- */ unsigned char FIRMWARE_MODE = 0xFF; extern volatile unsigned char buttonsPressed; static void linkTo(void); static uint16_t sTid = 0; /* Callback handler */ static uint8_t sCB(linkID_t); static volatile uint8_t sPeerFrameSem = 0; static linkID_t sLinkID1 = 0; #define SPIN_ABOUT_A_SECOND NWK_DELAY(1000) #define SPIN_ABOUT_A_QUARTER_SECOND NWK_DELAY(250) /* How many times to try a Tx and miss an acknowledge before doing a scan */ #define MISSES_IN_A_ROW 2 void MspExp430F5137RxUserExperience (void) { addr_t lAddr; //adress BSP_Init(); //initialize // //HalAdcInit(); //HalAdcSetQuitFromISR( 1 ); //SetupRtc(); //P1DIR |= BIT0; P1DIR=0XFF; P1OUT=0; P2DIR=0XFF; P2OUT=0; P3DIR=0XFF; P3OUT=0; PJDIR=0XFF; PJOUT=0; P1REN |= BIT7; P1OUT |= BIT7; P1DIR &= ~(BIT7); P1IES |= BIT7;// P1IE |= BIT7 ; P1IFG &= ~BIT7; _EINT(); // Create a unique address based off the device's wafer ID & // X/Y coordinates lAddr.addr[0] = (*(uint8_t *)0x01A0E) ^ (*(uint8_t *)0x01A0A); lAddr.addr[1] = (*(uint8_t *)0x01A0F) ^ (*(uint8_t *)0x01A0B); lAddr.addr[2] = (*(uint8_t *)0x01A10) ^ (*(uint8_t *)0x01A0C); lAddr.addr[3] = (*(uint8_t *)0x01A11) ^ (*(uint8_t *)0x01A0D); SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr); //generate an address /* Keep trying to join (a side effect of successful initialization) until * successful. Toggle LEDS to indicate that joining has not occurred. */ while (SMPL_SUCCESS != SMPL_Init(sCB))//join //wait until smpl_init reture smpl_success, //can this change to interrupt way??? { SPIN_ABOUT_A_SECOND; } /* LEDs on solid to indicate successful join. */ /* Unconditional link to AP which is listening due to successful join. */ linkTo(); while (1) ; } static void linkTo() //linking { uint8_t msg[1]; //create a group to save message //int temperature; uint8_t misses, done; /* Keep trying to link... */ //?? while (SMPL_SUCCESS != SMPL_Link(&sLinkID1)) { SPIN_ABOUT_A_SECOND; } /* sleep until button press... */ SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0); RTCPS1CTL |= RT1PSIE; while (1) { /* Send a message when either button pressed */ __bis_SR_register(LPM3_bits + GIE); // __no_operation(); //if (buttonsPressed & 0x80) // writing message //{ //msg[0] = MESSAGE_BUTTON_PRESSED; //0xff //msg[1] = MESSAGE_BUTTON_PRESSED; //msg[2] = MESSAGE_BUTTON_PRESSED; //msg[3] = MESSAGE_BUTTON_PRESSED; //buttonsPressed = 0; //set it back to 0 //} //else // half a second heart beat //{ //HalAdcStartRead(); //quit lmp3 after done //__bis_SR_register(LPM0_bits + GIE); // HalAdcConvertTempVcc(); msg[0] = 1; //msg[1] = HalAdcGetVcc(); //temperature = HalAdcGetTempDegF(); //msg[2] = *( (unsigned char*)(&temperature) ) ; //msg[3] = *((unsigned char*)(&temperature)+1) ; // } //sTid++; //msg[4] = (unsigned char) (sTid>>8); //msg[5] = (unsigned char) (sTid & 0xFF); /* get radio ready...awakens in idle state */ SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0); /* Set TID and designate which LED to toggle */ //done = 0; //while (!done) // { //for (misses=0; misses < MISSES_IN_A_ROW; ++misses) if (SMPL_SUCCESS == SMPL_Send(sLinkID1, msg, sizeof(msg))); //send message // break; // if (misses == MISSES_IN_A_ROW) // { /* This can only happen if we are supporting Frequency Agility and we * appear not to have received an acknowledge. Do a scan. */ //ioctlScanChan_t scan; //freqEntry_t freq[NWK_FREQ_TBL_SIZE]; //scan.freq = freq; // SMPL_Ioctl(IOCTL_OBJ_FREQ, IOCTL_ACT_SCAN, &scan); /* If we now know the channel (number == 1) change to it. In any case * try it all again. If we changed channels we should get an ack now. */ // if (1 == scan.numChan) // { // SMPL_Ioctl(IOCTL_OBJ_FREQ, IOCTL_ACT_SET, freq); //} //} // else //{ /* Got the ack. We're done. */ //done = 1; //} } /* radio back to sleep */ SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0); //special void, manage the i/o } //} static uint8_t sCB(linkID_t lid) { if (lid == sLinkID1) { sPeerFrameSem++; return 0; } return 1; } /**********************************************************************//** * @brief Initializes the RTC module for interval mode * * * * @param none * * @return none * * void SetupRtc(void) { RTCCTL01 = RTCMODE + RTCBCD + RTCHOLD + RTCTEV_1; RTCCTL01 &= ~RTCHOLD; RTCPS1CTL = RT1IP_7; // Interrupt freq: .5Hz // RTCPS1CTL = RT1IP_6; // Interrupt freq: 1Hz // RTCPS1CTL = RT1IP_5; // Interrupt freq: 2Hz //RTCPS1CTL = RT1IP_4; // Interrupt freq: 4Hz //RTCPS0CTL = RT0IP_7; // Interrupt freq: 128hz //RTCCTL0 |= RTCTEVIE; // Enable interrupt } #pragma vector=RTC_VECTOR __interrupt void RTC_ISR(void) { switch (RTCIV) { default: __bic_SR_register_on_exit(LPM3_bits); } } *************************************************************************/ #pragma vector=RTC_VECTOR __interrupt void RTC_ISR(void) { P1OUT ^=BIT0; } #pragma vector = PORT1_VECTOR __interrupt void PORT_1(void) { __delay_cycles(1000); if((P1IN & BIT7) == 0){ __bic_SR_register_on_exit(LPM3_bits); } P1IFG &= ~BIT7; }
1. set the data rate to 500kbps by set the MDMCFG4(2D),3(3B) respectively, but failed. They can't communicate after I change this 2 register.
2.disable the calibration by set the MCSM0 to 0x0, but they can't communicate.
3. What can I do to the packet in order to reduce the time?
I had uploaded the codes.
many thanks