打印

cc430 程序跑时间长了后进入reset_vector

[复制链接]
4985|14
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
沙发
figo20042005| | 2012-7-15 19:06 | 只看该作者
会不会是你的BUFFER有溢出现象,或者别的变量定义的类型长度不够

使用特权

评论回复
板凳
kebinliu| | 2012-7-16 10:45 | 只看该作者
我也遇到这个问题,正在求解?

使用特权

评论回复
地板
jinye645|  楼主 | 2012-7-16 16:53 | 只看该作者
2# figo20042005
应该不能,因为前面跑的好好的,时间长了之后才会进入这个状况。

使用特权

评论回复
5
jinye645|  楼主 | 2012-7-18 14:53 | 只看该作者
每次死之前都是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)

#define  BUTTON_BIT         0
#define  BUTTON_DIR         PJDIR
#define  BUTTON_OUT         PJOUT
#define  BUTTON_REN         PJREN
#define  BUTTON_IN          PJIN
#define WDT_ARST_20s       (WDTPW+WDTCNTCL+WDTSSEL0+WDTIS2)                         /* 1000ms  " */

extern RF_SETTINGS rfSettings;
u4 Unknow_标志寄存器=0;
u4 Low_标志寄存器=0;
unsigned char packetReceived;
unsigned char packetTransmit;

__no_init unsigned char RxBuffer[64];
unsigned char RxBufferLength = 0;
unsigned char buttonPressed = 0;
unsigned int i = 0;

unsigned char transmitting1= 0;
unsigned char receiving = 0;

void main( void )
{//  u16 press_value;
  // u8  buff[10];
  // Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD; //关闭看门狗
//  WDTCTL = WDT_ARST_250;  
//  Sys_Init();
//  Time_Init();
  // Increase PMMCOREV level to 2 for proper radio operation
  SetVCore(2);         //提升内核电压 PMM Core Voltage 2 (1.75V)                        
  
  ResetRadioCore();    //复位cc430 里面的Radio   
  InitRadio();        //初始化CC430 的Radio 模块
  InitButtonLeds();  //初始化按键和LED
//  Usart_Init();  
// simsend_init();
//  Catch_Init();
  ReceiveOn();      //开启接收模式
// ReceiveOff();
  P1DIR |= BIT0;
  P1DIR |= BIT1;
  P1DIR |= BIT2;
  P1DIR |= BIT3;
  P3DIR |= BIT6;
  P1OUT=0x00;
  P3OUT&=~BIT6;
  receiving = 1;
  _EINT();
      P2DIR |= BIT1;
    P2OUT |= BIT1;
  while (1)
  {
//   ReceiveOn();
    if(Unknow_标志寄存器)
    {
       P1OUT=0X00;
//       Delay_ms(150);
       P1OUT=0X0f;
//       Delay_ms(150);
      
    }
   
        if(Low_标志寄存器)
    {
       P1OUT=0X00;
       P3OUT&=~BIT6;
//       Delay_ms(150);
       P1OUT=0X0f;
       P3OUT|=BIT6;
//       Delay_ms(150);
    }

  }
}


  
void delayms(unsigned int n)
{
  unsigned int i,j;
  for(i=0;i<n;i++)
  {
    for(j=0;j<800;j++);
  }
}

void InitButtonLeds(void)
{
  // Initialize Port J
  PJOUT = 0x01;
  PJDIR = 0xFF;
  
  // 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;
  
  WriteRfSettings(&rfSettings);
  
  WriteSinglePATable(PATABLE_VAL);
}

void Transmit(unsigned char *buffer, unsigned char length)
{
  RF1AIES |= BIT9;                          
  RF1AIFG &= ~BIT9;                         // Clear pending interrupts
  RF1AIE |= BIT9;                           // Enable TX end-of-packet interrupt
  
  WriteBurstReg(RF_TXFIFOWR, buffer, length);     
  
  Strobe( RF_STX );                         // Strobe STX   
}

void ReceiveOn(void)
{  
  RF1AIES |= BIT9;                          // Falling edge of RFIFG9
  RF1AIFG &= ~BIT9;                         // Clear a pending interrupt
  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  );                       
}

#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);
        
        // Stop here to see contents of RxBuffer
        __no_operation();        
        press=atoi(RxBuffer);
        if(press==0)
        {
            P1OUT=0x0f;
            P3OUT|=BIT6;
            Unknow_标志寄存器=0;
            Low_标志寄存器=0;
        }
                else if(press>0&&press<=8)
        {
            P1OUT=0x0f;
            P3OUT&=~BIT6;
            Unknow_标志寄存器=0;
            Low_标志寄存器=0;
        }
               else if(press>8&&press<=16)
        {
            P1OUT=0x0d;
            P3OUT&=~BIT6;
            Unknow_标志寄存器=0;
            Low_标志寄存器=0;
        }
               else if(press>16&&press<=24)
        {
            P1OUT=0x05;
           P3OUT&=~BIT6;
           Unknow_标志寄存器=0;
           Low_标志寄存器=0;
        }
               else if(press>24&&press<=32)
        {
            P1OUT=0x04;
            P3OUT&=~BIT6;
            Unknow_标志寄存器=0;
            Low_标志寄存器=0;
        }
               else if(press>32&&press<=40)
        {
            P1OUT=0x00;
            P3OUT&=~BIT6;
            Unknow_标志寄存器=0;
            Low_标志寄存器=0;
        }
               else
               {
                 Unknow_标志寄存器=1;
                 Low_标志寄存器=0;
               }
      if(press>=0&&press<=5)
        {
                Low_标志寄存器=1;
                Unknow_标志寄存器=0;
        }
        if(RxBuffer[CRC_LQI_IDX] & CRC_OK)
        {                     
          LED_OUT |= (1<<LED_GBIT);         // Toggle LED1
          delayms(10);
          LED_OUT &=~(1<<LED_GBIT);

        }
   //   else while(1);                             // trap
      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
  }  
  ReceiveOn();  
}

使用特权

评论回复
6
ty新气象| | 2012-7-18 14:56 | 只看该作者
跟各位学习了。

使用特权

评论回复
7
第二个小江| | 2012-7-20 13:38 | 只看该作者
1.在CC1101_ISR中少调用函数。
2. 在IAR的OPTION里把STACK设置大些。
3. 把RxBuffer[64]改大些。

使用特权

评论回复
8
568581185| | 2012-7-20 19:58 | 只看该作者
我来学习了
觉得楼上应该是对的

使用特权

评论回复
9
peter_zheng| | 2012-8-12 12:13 | 只看该作者
这种情况一般是接收的数组越界造成的。

使用特权

评论回复
10
hawksabre| | 2012-8-31 18:50 | 只看该作者
应该是数组越界   你尝试着将要调用的数组范围设置的大一点   数组越界这个问题很头疼   只能靠自己书写程序规范   细心

使用特权

评论回复
11
jinye645|  楼主 | 2012-10-30 15:19 | 只看该作者
问题解决,主要是发送字节数问题。

使用特权

评论回复
12
fanspeed| | 2013-1-3 22:39 | 只看该作者
同遇到此问题,时间长了无法接受数据好像(没有单步调试),一会单步看看是哪里。请问楼主是怎么解决的,分享一下经验!

使用特权

评论回复
13
yufanjoy| | 2014-11-14 13:51 | 只看该作者
我也遇到了同样的问题,我是用串口自收自发:收到什么就发什么,用的是中断处理的,具体程序如下:
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
  switch(__even_in_range(UCA0IV,4))
  {
  case 0:break;                             // Vector 0 - no interrupt
  case 2:                                   // Vector 2 - RXIFG
    while (!(UCA0IFG&UCTXIFG));             // USCI_A1 TX buffer ready?
    UCA0TXBUF = UCA0RXBUF;                  // TX -> RXed character
    break;
  case 4:break;                             // Vector 4 - TXIFG
  default: break;
  }  
}

主函数就是对串口初始化而已,并未有其他关于数组和指针的操作,程序的主要是要实现串口接收和发送,所以就简单写了下串口初始化和上面贴出来的串口数据处理代码,用串口调试助手每隔80ms发送数据,程序在收到数据后就自动发到串口调试助手。
程序刚开始运行的半个多小时时间内,跑的很正常,但是要是时间再跑长点,程序就进入?reset_vector段里面去了,调试log里面显示的溢出了,但是我没有涉及数组和指针的操作,怎么会溢出啊,百思不得其解啊,烦请各位大侠帮我参谋参谋啊!!!

使用特权

评论回复
14
firstblood| | 2014-11-16 23:06 | 只看该作者
不是很明白的,,参考借鉴各位的意见的吧。

使用特权

评论回复
15
vivilzb1985| | 2014-11-23 20:47 | 只看该作者
一般都是由硬件问题引起的吧。。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

25

帖子

0

粉丝