This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using Real-Time-Clock Library with ez430-RF2500 sensor demo

Other Parts Discussed in Thread: SIMPLICITI, CC2500

Hello everybody,

I'm trying to get the Temperature sensor demo programm  (Version 1.02) of the ez430-RF2500 toolkit running with the Real-Time-clock Library (slaa290). My goal is to attach the actual time of each measurement  at the end of the transmittted datastring and then read it a out at the COM Port.I  integrated the code of one of the examples in the demo_AP file but it doesn't seem to work with this interrupt BT_1sec_wake() I think. Also the example codes of the Real-time clock library  assume that the 32768 Hz Crystal is connected to the LFXT1. In the MCU_init module

 BCSCTL3 |= LFXT1S_2;                      // LFXT1 = VLO

says that the VLO is chosen and the LFXT1 is free  (i think the comment is wrong?).Is that correct? And as XTS = 0 in BCSCTL1 , this means that LFXT1 runs in low frequency mode, eg. 32768HZ.

I really appreciate any kind of help. I know this should be a really easy problem to solve but I'm pretty new to the microncontroller programming thing

 heres the code important stuff in bold.

Thanks a lot

Chris

 

#include "bsp.h"
#include "mrfi.h"
#include "bsp_leds.h"
#include "bsp_buttons.h"
#include "nwk_types.h"
#include "nwk_api.h"
#include "nwk_frame.h"
#include "nwk.h"
#include "msp430x22x4.h"
#include "vlo_rand.h"

#include  "RTC.h"
#include  "RTC_BT.h"

#define MESSAGE_LENGTH 3

void TXString( char* string, int length );
void MCU_Init(void);
void transmitData(int addr, signed char rssi,  char msg[MESSAGE_LENGTH]);
void transmitDataString(char addr[4],char rssi[3], char msg[MESSAGE_LENGTH]);
void createRandomAddress();
//void changeSamplerate (char* Herz);


//data for terminal output
const char splash[] = {"\r\n--------------------------------------------------\r\n     ****\r\n     ****           eZ430-RF2500\r\n     ******o****    Temperature Sensor Network\r\n********_///_****   Copyright 2007\r\n ******/_//_/*****  Texas Instruments Incorporated\r\n  ** ***(__/*****   All rights reserved.\r\n      *********     Version 1.02\r\n       *****\r\n        ***\r\n--------------------------------------------------\r\n"};

__no_init volatile int tempOffset @ 0x10F4; // Temperature offset set at production
__no_init volatile char Flash_Addr[4] @ 0x10F0; // Flash address set randomly

// reserve space for the maximum possible peer Link IDs
static linkID_t sLID[NUM_CONNECTIONS];
static uint8_t  sNumCurrentPeers;

// callback handler
static uint8_t sCB(linkID_t);

// work loop semaphores
static uint8_t sPeerFrameSem;
static uint8_t sJoinSem;
static uint8_t sSelfMeasureSem;

// mode data verbose = default, deg F = default
char verboseMode = 1;
char degCMode = 1;
char Health = 1;

void main (void)
{
  addr_t lAddr;
  bspIState_t intState;

  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  {
  // delay loop to ensure proper startup before SimpliciTI increases DCO
  // This is typically tailored to the power supply used, and in this case
  // is overkill for safety due to wide distribution.
    volatile int i;
    for(i = 0; i < 0xFFFF; i++){}
  }
  if( CALBC1_8MHZ == 0xFF )                 // Do not run if cal values are erased
  {
    volatile int i;
    P1DIR |= 0x03;
    BSP_TURN_ON_LED1();
    BSP_TURN_OFF_LED2();
    while(1)
    {
      for(i = 0; i < 0x5FFF; i++){}
      BSP_TOGGLE_LED2();
      BSP_TOGGLE_LED1();
    }
   
  }
   
  BSP_Init();
  

  setTime( 0x12, 0, 0, 0);        // initialize time to 12:00:00 AM
  BT_1sec_wake();                // configure BT for 1 second update
  LPM3;                                    // enter LPM3, clock will be updated

 
  if( Flash_Addr[0] == 0xFF &&
      Flash_Addr[1] == 0xFF &&
      Flash_Addr[2] == 0xFF &&
      Flash_Addr[3] == 0xFF )
  {
    createRandomAddress();                  // set Random device address at initial startup
  }
  lAddr.addr[0]=Flash_Addr[0];
  lAddr.addr[1]=Flash_Addr[1];
  lAddr.addr[2]=Flash_Addr[2];
  lAddr.addr[3]=Flash_Addr[3];
  SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
 
  MCU_Init();
  //Transmit splash screen and network init notification
  TXString( (char*)splash, sizeof splash);
  TXString( "\r\nInitializing Network....", 26 );

........

 

void MCU_Init()
{
  BCSCTL1 = CALBC1_8MHZ;                    // Set DCO
  DCOCTL = CALDCO_8MHZ;
  

  BCSCTL3 |= LFXT1S_2;                      // LFXT1 = VLO
 
  TACCTL0 = CCIE;                           // TACCR0 interrupt enabled
  TACCR0 = 12000;                           // ~1 second
  TACTL = TASSEL_1 + MC_1;                  // ACLK, upmode
 
  P3SEL |= 0x30;                            // P3.4,5 = USCI_A0 TXD/RXD
  UCA0CTL1 = UCSSEL_2;                      // SMCLK
  UCA0BR0 = 0x41;                           // 9600 from 8Mhz
  UCA0BR1 = 0x3;
  UCA0MCTL = UCBRS_2;                      
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt
  __enable_interrupt();
 
}

 

......

  • u can put 0x00 value in that BCSCTL3 no issue u can check it with this value

  • Hi Srihk,

    I already tried that, but then the program isn't running properly...when debugging it just jumps between the 3 if statements of the main work loop (Joinsem,selfmeasureSem,PeerframSem)...and pretty much doing nothing...so i assumed that  BCSCTL3  has to be set to LFXT1S_2

  • Observe one thig that the board u r using is having connected with the cc2500 crystal so check that once

  • I got it running now....Now I tried to extend the code so that i can measure Milliseconds. I've perpend an incrementMilliseconds function + I'm using  timer B for the interrupt (with ACLK). The main difference is that TI_MIlliseconds must be  an int  because i need 2 bytes. It all kinda works fine as long as only the AP is powered.
    Once I turn on an ED the whole thing dies.....means everything stops the AP is doing nothing, all LEDs are out.

    Do you have any idea how to solve the problem....The problem is that i need a millisecond timebase...

    Thanks in advance

    Chris

    My code:

                ;Variables
                MODULE    RTC
                PUBLIC    TI_millisecond
                PUBLIC    TI_second
                PUBLIC    TI_minute
                PUBLIC    TI_hour
                PUBLIC    TI_PM
                ;Functions
                PUBLIC    incrementMilliseconds
                PUBLIC    incrementSeconds
                PUBLIC    incrementMinutes
                PUBLIC    incrementHours
                PUBLIC    get24Hour

                RSEG      DATA16_I
    TI_millisecond        DS 2
    TI_second               DS 1
    TI_minute                DS 1
    TI_hour                    DS 1
    TI_PM                       DS 1


                RSEG      DATA16_ID
                DC8       0x00
                DC8       0x00
                DC8       0x00
                DC8       0x12
                DC8       0x00

                RSEG    CODE                    ; Code is relocatable
    ;============================================================================
    ; incrementMilliseconds
    ;============================================================================
    incrementMilliseconds
                clrc
                add    #0x01,   &TI_millisecond           ; tick one second
                cmp     #0x03E8,   &TI_millisecond    ; see if we've hit 1000 milliseconds
                jne    return                                               ; if not, return
                clr       &TI_millisecond                        ; if so, go back to 00
                                                                                 ; fall down to increment seconds
    ;============================================================================
    ; incrementSeconds
    ;============================================================================
    incrementSeconds
                clrc
                dadd.b  #0x01,   &TI_second     ; tick one second
                cmp.b   #0x60,   &TI_second     ; see if we've hit 60 seconds
                jne     return                  ; if not, return
                clr.b   &TI_second              ; if so, go back to 00
                                                ; fall down to increment minutes
    ;============================================================================
    ; incrementMinutes
    ;============================================================================
    incrementMinutes
                clrc
                dadd.b  #0x01,   &TI_minute     ; tick one minute
                cmp.b   #0x60,   &TI_minute     ; see if we've hit 60 minutes
                jne     return                  ; if not, return
                clr.b   &TI_minute              ; if so, go back to 00
                                                ; fall down to increment hours
    ;============================================================================
    ; incrementHours
    ;============================================================================
    incrementHours
                clrc
                dadd.b  #0x01,   &TI_hour
                cmp.b   #0x24,   &TI_hour
                jne     return
                clr.b   &TI_hour

     

    return         ret

    End

  • Perhaps I have missed something, but how can you use LFXT1 on the RF2500T board? The XIN and XOUT pins are used for the GDO2 and GDO0 signals to the CC2500 preventing the use of a 32kHz crystal or clock source.

      Paul

     

  • Hi Paul,

    I'm not using LFXT1. I'm using the internal VLOCLK (12KHz)

    Chris

**Attention** This is a public forum