I am trying to use cc430f5137 and CCS 5.5.0.00077 to make a sensor network (more specificly a WizziMote). I have run into an interesting problem I need help solving. The program is still at a simple state. It does two things. Goes to sleep and waits for user input. The user can ask to listen for a node and test the range of the node. Upon receive it spits out the node ID and it's RSSI in hex form.
At first I got the receiving function working individually, then I tried to add the UART interrupt and the program froze when there was a user input. I hit pause and got:
"No source available for "0x2bd0" "
So I place a breakpoint in the interrupt get into the interrupt and start to step thru the interrupt and at the end of the interrupt I get:
"MSP430: Can't Single Step Target Program: Could not single step device"
So, I go back and make a program that has a user UART interrupt and works. Then add the radio option and get the same thing in the radio interrupt. Upon receiving a transmission it doesn't freeze but ignores the transmission. So I place a breakpoint in the receive interrupt. I step through the interrupt and at the end get:
"MSP430: Can't Single Step Target Program: Could not single step device"
So I do it again, and this time when I get to the break point I click play. Now it freezes. So I hit pause and get:
"No source available for "0x2bd0" "
Interesting huh? There's a work around for this, just don't go to sleep, but how boring and wasteful. Below is the code.
Anyone got any ideas how to further test this situation to figure out the problem?
#include <cc430f5137.h>
#include <stdio.h>
#include "RF1A.h"
//functions
void blinkup(void);
void blinkdown(void);
void init(void);
void ReceiveOn(void);
void ReceiveOff(void);
void Transmit(unsigned char *t, unsigned char length);
void UserMenu(void);
void printstring(char []);
void PrintUserMenu(void);
char getch(void);
void placechar(char);
void wait2Receive(void);
//globals
unsigned int state = 0;
unsigned char transmitting = 0;
unsigned char receiving = 0;
unsigned char RxBuffer[64];
unsigned char RxBufferLength=0;
unsigned char temp[12] = "Hello World!";
void main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
init();
blinkup(); blinkdown(); blinkup(); blinkdown();
printstring("\r\n\nWelcome to Mike's Sink program. Press any key to begin\r\n");
for (;;) {
switch (state) {
case 0: //goto sleep
__bis_SR_register (LPM0_bits +GIE);
__no_operation();
break;
case 1: //User Menu
UserMenu();
break;
default: //don't know how you got here
state = 0; //but I know how to get you out...
break;
}
}
}
void wait2Receive(void) {
char str[20];
state = 2;
printstring("Test target range. Press esc to exit...\r\n");
while (state == 2) {
ReceiveOn();
__bis_SR_register( LPM3_bits + GIE ); //wait to receive
__no_operation();
if (state == 2) { //esc wasn't pressed
P1OUT ^= BIT7; //turn on red light
while (!(UCA0IFG & UCTXIFG)); //wait for buffer to get ready
RxBufferLength = ReadSingleReg(RXBYTES);
ReadBurstReg(RF_RXFIFORD, RxBuffer, RxBufferLength);
__no_operation();
//Check CRC results
if (RxBuffer[RxBufferLength-1] & BIT7) {
P1OUT ^= BIT7; //turn off red if CRC ok...
printstring("CRC OK");
}
else printstring ("CRC Failed ");
sprintf(str, "Node #%i %d\r\n", RxBuffer[1], RxBuffer[RxBufferLength-2]);
printstring(str);
}
}
printstring("Exiting test target range. Press any key to enter User menu.\r\n");
ReceiveOff();
}
void UserMenu() {
char input;
PrintUserMenu();
while (state == 1) {
input = getch();
if (input == '1') blinkup();
else if (input == '2') blinkdown();
else if (input == '3') wait2Receive();
else if (input == 'u' || input == 'U') PrintUserMenu();
else if (input == 'z' || input == 'Z') {
printstring("good night...press any key to return\r\n");
state = 0;
}
}
}
void PrintUserMenu(void) {
printstring("-------------------------------------------------------------\r\n");
printstring("| 1. blink lights up |\r\n");
printstring("| 2. blink lights down |\r\n");
printstring("| 3. Wait to receive (Test range) |\r\n");
printstring("| u. redisplay User Menu |\r\n");
printstring("| z. exit |\r\n");
printstring("-------------------------------------------------------------\r\n");
}
void printstring(char word []) {
int i =0;
while (word[i] != 0x00) {
placechar(word[i]);
i++;
}
}
void placechar(char c) {
while (!(UCA0IFG & UCTXIFG)); //wait for buffer to get ready
UCA0TXBUF = c;
}
char getch (void) {
//wait for user input
while (!(UCA0IFG & UCRXIFG));
return UCA0RXBUF;
}
void blinkup (void) {
P1OUT = 0X80;
__delay_cycles(60000);
P1OUT = 0;
P3OUT = 0x80;
__delay_cycles(60000);
P3OUT = 0x40;
__delay_cycles(60000);
P3OUT = 0;
}
void blinkdown (void) {
P3OUT = 0x40;
__delay_cycles(60000);
P3OUT = 0x80;
__delay_cycles(60000);
P3OUT = 0;
P1OUT = 0x80;
__delay_cycles(60000);
P1OUT = 0;
}
void ReceiveOn (void) {
RF1AIES |= BIT9; //Falling edge of RFIFG9
RF1AIFG &= ~BIT9; //Clear pending interrupts
RF1AIE |= BIT9; //Enable the interrupt
//Radio is in IDLE following a TX, so strobe SRX to enter Receive Mode
Strobe(RF_SRX);
}
void ReceiveOff(void) {
RF1AIE &= ~BIT9; //Disable RX interrupts
RF1AIFG &= ~BIT9; //Clear pending IFG
//It is possible that ReceiveOff is called while radio is receiving a packet.
//Therefore, it is necessary to flush the RX FIFO after issuing IDLE strobe
//such that the RXFIFO is empty prior to receiving a packet
Strobe(RF_SIDLE);
Strobe(RF_SFRX);
}
void Transmit(unsigned char *t, unsigned char length) {
RF1AIES |= BIT9; //High low transition select
RF1AIFG &= ~BIT9; //Clear pending interrupts
RF1AIE |= BIT9; //enable TX end-of-packet interrupt
WriteBurstReg(RF_TXFIFOWR, t, length); //put char in TX que
Strobe(RF_STX); //I want to transmit
}
//interrupts
#pragma vector = USCI_A0_VECTOR
__interrupt void USCI_A0_ISR (void) {
unsigned char ch = 0;
switch(__even_in_range(UCA0IV, 4)) {
case 0: break; //Vector 0 - no interrupt
case 2: //Vector 2 - RXIF
while (!(UCA0IFG & UCTXIFG)); //Input happened
ch = UCA0RXBUF;
if (state == 2) {
if (ch == 0x1B) {
state=0;
__bic_SR_register_on_exit(LPM3_bits+GIE);
}
}
else if (state == 0) {
state = 1;
__bic_SR_register_on_exit(LPM0_bits+GIE);
}
break;
case 4: break; //Vector 4 - TXIFG
default: break;
}
}
#pragma vector=CC1101_VECTOR
__interrupt void CC1101_ISR(void) {
switch(__even_in_range(RF1AIV,32)) { //Prioritizing Radio Core Interrupt
case 0: break; // No RF core interrupt pending
case 2: break; // RFIFG0
case 4: break; // RFIFG1
case 6: break; // RFIFG2
case 8: break; // RFIFG3
case 10: break; // RFIFG4
case 12: break; // RFIFG5
case 14: break; // RFIFG6
case 16: break; // RFIFG7
case 18: break; // RFIFG8
case 20: // RFIFG9
__bis_SR_register_on_exit(LPM3_bits+GIE);
break;
case 22: break; // RFIFG10
case 24: break; // RFIFG11
case 26: break; // RFIFG12
case 28: break; // RFIFG13
case 30: break; // RFIFG14
case 32: break; // RFIFG15
}
}
// Interrupt Service Routines
//#pragma vector = PORT1_VECTOR
//__interrupt void P1_ISR(void) {
// switch (__even_in_range(P1IV,16))
// {
// case 0: //Nothing
// break;
// case 2: //Port P1.0
// break;
// case 4: //Port P1.1
// break;
// case 6: //Port P1.2
// break;
// case 8: //Port P1.3
// break;
// case 10: //Port P1.4
// blinkdown();
// P1IFG &= ~BIT4;
// break;
// case 12: //Port P1.5
// printstring("Quit pressing my buttons...\r\n");
// P1IFG &= ~BIT5;
// break;
// case 14: //Port P1.6
// blinkup();
// P1IFG &= ~BIT6;
// break;
// case 16: //Port P1.7
// break;
// }
//}
void init (void) {
//---------------------------------------GIO------------------------------------------//
P1DIR = 0x80; //red LED output
P3DIR = 0xC0; //others
P1OUT = 0;
P3OUT = 0; //everybody is output
//push buttons
P1IES |= 0x70; //clear previous push button interrupts
P1IFG = 0;
// P1IE = 0x70; //enable push button interrupts
//---------------------------------------CLOCK----------------------------------------//
// ACLK = REF0 = 32 kHz, MCLK = SMCLK = 8MHz, XT2 = 26 MHz external crystal //
//------------------------------------------------------------------------------------//
UCSCTL3 |= SELREF_2; //Set DCO FLL referenece = REF0
UCSCTL4 |= SELA_2; //Set ACLK = REF0
__bis_SR_register(SCG0); //Disable the FLL control loop
UCSCTL0 = 0x0000; //Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_3; //Select DCO range 16 MHz operation
UCSCTL6 &= ~(XT2OFF); //enable XT2 for 26MHz
UCSCTL2 = FLLD_1 + 127; //Set DCO Multipler for 8 MHz
//(N+1)*FLLRef = Fdco
//(249+1)*32768 = 8MHz
//Set FLL Div = fDCOCLK/2
__bic_SR_register(SCG0); //Enable the FLL control loop
__delay_cycles(250000); //allow for settling
//Loop until XT1, XT2 & DCO fault flag is cleared
do {
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
//clear XT2, XT1, DCO fault flags
SFRIFG1 &= ~OFIFG; //clear fault flags
} while (SFRIFG1 & OFIFG); //Test oscilator fault flag
//---------------------------------------UART-----------------------------------------//
PMAPPWD = 0x02D52; //get write-access to port mapping regs
P2MAP0 = PM_UCA0RXD; //map UCA0RXD output to P2.0
P2MAP1 = PM_UCA0TXD; //map UCA0TXD output to P2.1
PMAPPWD = 0; //lock port mapping registers
P2DIR |= BIT1; //Set P2.1 as Tx output
P2SEL |= BIT1 + BIT0; //Set P2.0 & P2.1 to UART function
UCA0CTL1 |= UCSWRST; //put state machine in reset
UCA0CTL1 |= UCSSEL_1; //ACLK
UCA0BR0 = 3; //32kHz/9600 = 3.41
UCA0BR1 = 0; //yea...
// UCA0ABCTL |= BIT0; //AutoBaud rate detect enabled
UCA0MCTL = UCBRS_3 + UCBRF_0; //Modulation UCBRSx=3, UCBRFx=0
UCA0CTL1 &= ~UCSWRST; //Initialize USCI state machine
UCA0IE |= UCRXIE; //Enable USCI_A0 RX interrupt
//---------------------------------------RADIO----------------------------------------//
//SetVCore(2);
ResetRadioCore();
RF_SETTINGS rfSettings = {
0x06, // FSCTRL1 Frequency synthesizer control.
0x00, // FSCTRL0 Frequency synthesizer control.
0x10, // FREQ2 Frequency control word, high byte.
0xA7, // FREQ1 Frequency control word, middle byte.
0x62, // FREQ0 Frequency control word, low byte.
0xF8, // MDMCFG4 Modem configuration.
0x83, // MDMCFG3 Modem configuration.
0x03, // MDMCFG2 Modem configuration.
0x20, // MDMCFG1 Modem configuration.
0x00, // MDMCFG0 Modem configuration.
0x00, // CHANNR Channel number.
0x15, // DEVIATN Modem deviation setting (when FSK modulation is enabled).
0x56, // FREND1 Front end RX configuration.
0x10, // FREND0 Front end RX configuration.
0x18, // MCSM0 Main Radio Control State Machine configuration.
0x16, // FOCCFG Frequency Offset Compensation Configuration.
0x6C, // BSCFG Bit synchronization Configuration.
0x03, // AGCCTRL2 AGC control.
0x40, // AGCCTRL1 AGC control.
0x91, // AGCCTRL0 AGC control.
0xE9, // FSCAL3 Frequency synthesizer calibration.
0x2A, // FSCAL2 Frequency synthesizer calibration.
0x00, // FSCAL1 Frequency synthesizer calibration.
0x1F, // FSCAL0 Frequency synthesizer calibration.
0x59, // FSTEST Frequency synthesizer calibration.
0x81, // TEST2 Various test settings.
0x35, // TEST1 Various test settings.
0x09, // TEST0 Various test settings.
0x47, // FIFOTHR RXFIFO and TXFIFO thresholds.
0x0B, // IOCFG2 GDO2 output pin configuration.
0x06, // IOCFG0D GDO0 output pin configuration.
0x04, // PKTCTRL1 Packet automation control.
0x05, // PKTCTRL0 Packet automation control.
0x00, // ADDR Device address.
0xFF // PKTLEN Packet length.
};
//Set the High-Power Mode Request Enable bit so LPM3 can be entered
//with active radio enabled
PMMCTL0_H = 0xA5;
PMMCTL0_L |= PMMHPMRE_L;
PMMCTL0_H = 0x00;
WriteRfSettings(&rfSettings);
WriteSinglePATable(0x51);
}