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