每次死之前都是stack100%100,好像是溢出了,但是不知道是哪块出现了这个问题,程序如下
/******************************************************************************
* CC430 RF Code Example - TX and RX (variable packet length =< FIFO size)
*
* Simple RF Link to Toggle Receiver's LED by pressing Transmitter's Button
* Warning: This RF code example is setup to operate at either 868 or 915 MHz,
* which might be out of allowable range of operation in certain countries.
* The frequency of operation is selectable as an active build configuration
* in the project menu.
*
* Please refer to the appropriate legal sources before performing tests with
* this code example.
*
* This code example can be loaded to 2 CC430 devices. Each device will transmit
* a small packet upon a button pressed. Each device will also toggle its LED
* upon receiving the packet.
*
* The RF packet engine settings specify variable-length-mode with CRC check
* enabled. The RX packet also appends 2 status bytes regarding CRC check, RSSI
* and LQI info. For specific register settings please refer to the comments for
* each register in RfRegSettings.c, the CC430x613x User's Guide, and/or
* SmartRF Studio.
*
* M. Morales
* Texas Instruments Inc.
* February 2010
* Built with IAR v4.21 and CCS v4.1
******************************************************************************/
#include "stdlib.h"
#include "stdio.h"
#include "../inc/RF_Toggle_LED_Demo.h"
/*#include "../inc/usart.h"
#include "../inc/press.h"
#include "../inc/gprs.h"
#include "../inc/time.h"
#include "../inc/ds18b20.h"*/
#include "cc430x613x.h"
#define PACKET_LEN (0x05) // PACKET_LEN <= 61
#define RSSI_IDX (PACKET_LEN+1) // Index of appended RSSI
#define CRC_LQI_IDX (PACKET_LEN+2) // Index of appended LQI, checksum
#define CRC_OK (BIT7) // CRC_OK bit
// 433MHz下的发射功率宏定义
#define PATABLE_VAL (0xc4) // 0XC4-- 10 dBm;
// 0X50-- 0 dBm;
// 0X2D-- -6 dBm;
// 0X26-- -12dBm;
// 0x05-- -30dBm;
// 0xc0-- max
#define LED_RBIT 6
#define LED_GBIT 7
#define LED_DIR P2DIR
#define LED_OUT P2OUT
#define LED_SEL P2SEL
#define LEDR_ON() LED_OUT|=(1<<LED_RBIT)
#define LEDG_ON() LED_OUT|=(1<<LED_GBIT)
#define LEDR_OFF() LED_OUT&=~(1<<LED_RBIT)
#define LEDG_OFF() LED_OUT&=~(1<<LED_GBIT)
// Set up the button as interruptible
BUTTON_DIR&=~(1<<BUTTON_BIT); // 按键设置为输入
BUTTON_REN|=BIT0; // 上拉
// Set up LEDs
LED_OUT&=~((1<<LED_RBIT)|(1<<LED_GBIT)); // LED端口输出0
LED_DIR|=(1<<LED_RBIT)|(1<<LED_GBIT); // LED端口方向设置为输出
}
void InitRadio(void)
{
// 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;
// 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 );
}
#pragma vector=CC1101_VECTOR
__interrupt void CC1101_ISR(void)
{
static u8 press;
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
// if(receiving) // RX end of packet
// {
// Read the length byte from the FIFO
RxBufferLength = ReadSingleReg( RXBYTES );
ReadBurstReg(RF_RXFIFORD, RxBuffer, RxBufferLength);