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.

How to use SYSRIVECT bit in register SYSCTL?

Other Parts Discussed in Thread: MSP430FR5739

Hi E2E Members,

  I went through the F5xx/F6xx user guider and found that the interrupt vector(FF80-FFFF) can be remapped to top of RAM.  It's a interesting and useful improve,I think .

 In a field firmware upgrade application, we used to poll  the flag to check if  data is avilable or not in the buffer .Not only that, the user's app vector should remap to a non-bootcode area. Once a event is trigered ,it first  feltch PC from FFE0-FFFF,and then jump to the real interrupt vector.

 -----That cost several painful CLKs in vain.

so...I want to try the new character in F5xx/F6xx msp430s. However, PC corrupt when   SYSRIVECT bit is set in SYSCTL.  

Hope some clue from U .

Best regards.


#include "MSP430FR5739.h"

#define  RAM_MAX_ADRESS      0x1FFF
#define  MAP_VECTOR_BASE     (RAM_MAX_ADRESS-1-RESET_VECTOR)
#define  NUM_VECTOR         (  1+( (RESET_VECTOR-RTC_VECTOR)>>1)  )


__interrupt void TA0CCR0_ISR(void);
__interrupt void TA0CCR1_ISR(void);


__no_init unsigned int MAP_VECTOR[ NUM_VECTOR ]@MAP_VECTOR_BASE;


void InitTimer(void);
void Clk_setting(void);
//__no_init __root void (*intvec1[16])()@0x1C00;        //定义指向函数的指针数组,用于映射新的中断向量
unsigned int xx[20];

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;	
  
  MAP_VECTOR[(TIMER0_A0_VECTOR-RTC_VECTOR)/2]=(unsigned int)TA0CCR0_ISR;
  MAP_VECTOR[(TIMER0_A1_VECTOR-RTC_VECTOR)/2]=(unsigned int)TA0CCR1_ISR;
  
  SYSCTL |= SYSRIVECT;
  
  Clk_setting();
  InitTimer();
  
  P3OUT |= BIT4+BIT7;
  P3DIR |= BIT4+BIT7;
  _EINT();
  
  
  
  while(1);
}


/*******************************************************************************
**函数名:Clk_setting
**说明:MCLK=8MHz   ACLK=VLO=8.3KHz(~10KHz)
*******************************************************************************/
void Clk_setting(void)
{
  CSCTL0 = CSKEY;
  CSCTL1 = DCOFSEL_3;//------8MHz
  //CSCTL1 = DCORSEL+
  CSCTL2 = SELM__DCOCLK + SELS__DCOCLK+SELA__VLOCLK;
  CSCTL3 = 0;
  CSCTL4 = XT1OFF+XT2OFF;
  //CSCTL5 = 
  CSCTL6 = 0;
}

/*******************************************************************************
**函数名:InitTimer
**说明:
*******************************************************************************/
void InitTimer(void)
{
  //taclk -- aclk
  TA0CTL = TASSEL_1 + TACLR;
  TA0CCR0 = 5000;
  TA0CCTL0 = CCIE;
  
  TA0CCR1 = 2000;
  TA0CCTL1 = CCIE;
  TA0CTL |= MC_1;//增计数模式
}

/*******************************************************************************
**函数名:TA0CCR0_ISR
**说明:
*******************************************************************************/
#pragma vector = TIMER0_A0_VECTOR
__interrupt void TA0CCR0_ISR(void)
{
  P3OUT ^= BIT4;
}

/*******************************************************************************
**函数名:TA0CCR1_ISR
**说明:
*******************************************************************************/
#pragma vector = TIMER0_A1_VECTOR
__interrupt void TA0CCR1_ISR(void)
{
  switch(__even_in_range(TA0IV,0x0A) )
  {
  case 0x00:
    break;
    
  case 0x02:
    P3OUT ^= BIT7;
    break;
    
  case 0x04:
    break;
    
  case 0x0A:
    break;
  }
}

  • #define MAP_VECTOR_BASE (RAM_MAX_ADRESS-1-RESET_VECTOR)

    The vectors are 16-bit addresses, but this computation uses bytes.

  • The default vector table is FF80~FFFF , so the remaped vector in RAM should be 1F80~1FFF. (FR5739 RAM range 1C00~1FFF)
    MAP_VECTOR_BASE equals 1F80.
  • Actually, my copy of msp430fr5739.h (for gcc) has this:

    ...
    #define SYSNMI_VECTOR           (55)                     /* 0xFFFC System Non-maskable */
    #define RESET_VECTOR            ("reset")                /* 0xFFFE Reset [Highest Priority] */

    So trying to use RESET_VECTOR in computations would use the address of some constant string.

    In the normal vector table, the RTC vector is at address 0xFFCE. So in RAM, it would be at address 0x1FCE. Just use that as base address:

    #define MAP_VECTOR_BASE 0x1fce
    #define NUM_VECTOR      25

  • Why don't you simply copy over the whole vector area? Start and end are processor-specific and well-known values, so why all these calculations? It's overly complex.
    However, the more important thing is not addressed at all: The RAM vector address is at end of ram. Which is usually the top of stack too. If you don't move the TOS to below the ram vector area, all function calls and local variables may overwrite your interrupt vectors.
    Or does the FR use FRAM for the stack? (this would be silly, due to the FRAM waitstates above 8MHz)

**Attention** This is a public forum