[讨论] C2000 运行就进入RTOSINT_ISR中断

xy598646744   2015-8-28 17:46 楼主
下载到flash后 仿真界面上点运行,就进入RTOSINT_ISR中断了,而直接下载到内存中不会出现这种情况。这是怎么回事????
用的TMS320F28031      XDS100 v2   
请大神指教

回复评论 (8)

把文件列表晒出来,可能是没有nonBIOS文件,或者是没有codestart那个文件。反正是flash启动的文件不全。应该是缺少nonBIOS文件,因为你进入的是RTOS中断,这个是实时操作系统中断 本帖最后由 elvike 于 2015-8-28 18:14 编辑
作为一个水军,就是尽量的多回帖,因为懂的技术少,所以回帖水分大,见谅! EEWORLD开发板置换群:309018200,——电工们免费装β的天堂,商家勿入!加群暗号:喵
点赞  2015-8-28 18:09
相关的CMD 配置不对吧?
点赞  2015-8-28 18:42
没烧好。CMD分配不正确。
点赞  2015-8-28 21:42
至少来个工程截图,便于分析。什么都没有,大家只能想当然的猜了
点赞  2015-8-29 07:37
我添加了这些文件、
无标题.png

我试了一下。官方的LED闪烁工程  main.c  一切正常。自己改的教程就不能在下载到FLASH是正常工作。

官方的例程:
#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

// Prototype statements for functions found within this file.
interrupt void cpu_timer0_isr(void);

void main(void)
{

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2803x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO:
// This example function is found in the DSP2803x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example


// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2803x_PieCtrl.c file.
   InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in DSP2803x_DefaultIsr.c.
// This function is found in DSP2803x_PieVect.c.
   InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
   EALLOW;  // This is needed to write to EALLOW protected registers
   PieVectTable.TINT0 = &cpu_timer0_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize the Device Peripheral. This function can be
//         found in DSP2803x_CpuTimers.c
   InitCpuTimers();   // For this example, only initialize the Cpu Timers
// Configure CPU-Timer 0 to interrupt every 500 milliseconds:
// 60MHz CPU Freq, 50 millisecond Period (in uSeconds)
   ConfigCpuTimer(&CpuTimer0, 60, 500000);


// To ensure precise timing, use write-only instructions to write to the entire register. Therefore, if any
// of the configuration bits are changed in ConfigCpuTimer and InitCpuTimers (in DSP2803x_CpuTimers.h), the
// below settings must also be updated.

   CpuTimer0Regs.TCR.all = 0x4001; // Use write-only instruction to set TSS bit = 0

// Step 5. User specific code, enable interrupts:

// Configure GPIO34 as a GPIO output pin
   EALLOW;
   GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;
   GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;
   EDIS;

// Enable CPU INT1 which is connected to CPU-Timer 0:
   IER |= M_INT1;

// Enable TINT0 in the PIE: Group 1 interrupt 7
   PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

// Enable global Interrupts and higher priority real-time debug events:
   EINT;   // Enable Global interrupt INTM
   ERTM;   // Enable Global realtime interrupt DBGM

// Step 6. IDLE loop. Just sit and loop forever (optional):
   for(;;);
}


interrupt void cpu_timer0_isr(void)
{
   CpuTimer0.InterruptCount++;
   GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Toggle GPIO34 once per 500 milliseconds
   // Acknowledge this interrupt to receive more interrupts from group 1
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}


//===========================================================================
// No more.
//===========================================================================






我自己根据官网的教程修改后的代码:
#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

// Prototype statements for functions found within this file.
void scia_echoback_init(void);
void scia_fifo_init(void);
void scia_xmit(int a);
void scia_msg(char *msg);

// Global counts used in this example
Uint16 LoopCount;
Uint16 ErrorCount;


// Prototype statements for functions found within this file.
interrupt void adc_isr(void);
void Adc_Config(void);
void serial_send_coord(float *coord, float line_number);

// Global variables used in this example:
//Uint16 LoopCount;
Uint16 ConversionCount;
float Voltage1[6];
float Voltage2[6];



void main(void)
{

    //Uint16 ReceivedChar;
    char *msg;

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2803x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO:
// This example function is found in the DSP2803x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
   // InitGpio(); Skipped for this example

// For this example, only init the pins for the SCI-A port.
// This function is found in the DSP2803x_Sci.c file.
   InitSciaGpio();

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2803x_PieCtrl.c file.
   InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in DSP2803x_DefaultIsr.c.
// This function is found in DSP2803x_PieVect.c.
   InitPieVectTable();

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2803x_InitPeripherals.c
// InitPeripherals(); // Not required for this example

// Step 5. User specific code:

    LoopCount = 0;
    ErrorCount = 0;



// Configure GPIO34 as a GPIO output pin
   EALLOW;
   GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;
   GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;
   EDIS;



    scia_fifo_init();           // Initialize the SCI FIFO
    scia_echoback_init();  // Initalize SCI for echoback

    msg = "\r\n\n\nHello World!\0";
    scia_msg(msg);

    msg = "\r\nYou will enter a character, and the DSP will echo it back! \n\0";
    scia_msg(msg);

//ADC
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
   EALLOW;  // This is needed to write to EALLOW protected register
   PieVectTable.ADCINT1 = &adc_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2803x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   InitAdc();  // For this example, init the ADC

// Step 5. User specific code, enable interrupts:

// Enable ADCINT1 in PIE
   PieCtrlRegs.PIEIER1.bit.INTx1 = 1;        // Enable INT 1.1 in the PIE
   IER |= M_INT1;                                                 // Enable CPU Interrupt 1
   EINT;                                                          // Enable Global interrupt INTM
   ERTM;                                                          // Enable Global realtime interrupt DBGM

   LoopCount = 0;
   ConversionCount = 0;

// Configure ADC
        EALLOW;
        AdcRegs.ADCCTL1.bit.INTPULSEPOS        = 1;        //ADCINT1 trips after AdcResults latch
        AdcRegs.INTSEL1N2.bit.INT1E     = 1;        //Enabled ADCINT1
        AdcRegs.INTSEL1N2.bit.INT1CONT  = 0;        //Disable ADCINT1 Continuous mode
        AdcRegs.INTSEL1N2.bit.INT1SEL        = 1;        //setup EOC1 to trigger ADCINT1 to fire
        AdcRegs.ADCSOC0CTL.bit.CHSEL         = 4;        //set SOC0 channel select to ADCINA4
        AdcRegs.ADCSOC1CTL.bit.CHSEL         = 2;        //set SOC1 channel select to ADCINA2
        AdcRegs.ADCSOC0CTL.bit.TRIGSEL         = 5;        //set SOC0 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
        AdcRegs.ADCSOC1CTL.bit.TRIGSEL         = 5;        //set SOC1 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
        AdcRegs.ADCSOC0CTL.bit.ACQPS         = 6;        //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
        AdcRegs.ADCSOC1CTL.bit.ACQPS         = 6;        //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
        EDIS;

// Assumes ePWM1 clock is already enabled in InitSysCtrl();
   EPwm1Regs.ETSEL.bit.SOCAEN        = 1;                // Enable SOC on A group
   EPwm1Regs.ETSEL.bit.SOCASEL        = 4;                // Select SOC from from CPMA on upcount
   EPwm1Regs.ETPS.bit.SOCAPRD         = 1;                // Generate pulse on 1st event
   EPwm1Regs.CMPA.half.CMPA         = 0x0080;        // Set compare A value
   EPwm1Regs.TBPRD                                 = 0xFFFF;        // Set period for ePWM1
   EPwm1Regs.TBCTL.bit.CTRMODE         = 0;                // count up and start
//END ADC





        for(;;)
    {
       msg = "\r\nEnter a character: \0";
       scia_msg(msg);
       scia_msg(msg);
       scia_msg(msg);
       scia_msg(msg);
       scia_msg(msg);
       scia_msg(msg);


       GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1;
    }

}


void serial_send_coord(float *coord, float line_number)
{
    //以指针形式发送坐标值
    char *p = (char *)coord;
    int num;
    //_DINT();            //关闭中断发送坐标
    for( num = 0;num < 24;num++)
    {
        if(num == 0)
        {
                scia_xmit('$');
        }
        scia_xmit(*(p + num));
    }

    //发送行号
    p = (char *)(&line_number);
    for( num = 0; num < 4; num++)
    {
            scia_xmit(*(p + num));
    }
}


interrupt void  adc_isr(void)
{

  Voltage1[ConversionCount] = AdcResult.ADCRESULT0 ;
  Voltage2[ConversionCount] = AdcResult.ADCRESULT1;
  Voltage1[ConversionCount] =  (Voltage1[ConversionCount]*3.3) / 4096 ;
  Voltage2[ConversionCount] =  (Voltage2[ConversionCount]*3.3) / 4096 ;


  // If 20 conversions have been logged, start over
  if(ConversionCount == 5)
  {
         serial_send_coord(Voltage1,1.0);
     ConversionCount = 0;
  }
  else ConversionCount++;

  AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;                //Clear ADCINT1 flag reinitialize for next SOC
  PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;   // Acknowledge interrupt to PIE

  return;
}


// Test 1,SCIA  DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
void scia_echoback_init()
{
    // Note: Clocks were turned on to the SCIA peripheral
    // in the InitSysCtrl() function

        SciaRegs.SCICCR.all =0x0007;   // 1 stop bit,  No loopback
                                   // No parity,8 char bits,
                                   // async mode, idle-line protocol
        SciaRegs.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK,
                                   // Disable RX ERR, SLEEP, TXWAKE
        SciaRegs.SCICTL2.all =0x0003;
        SciaRegs.SCICTL2.bit.TXINTENA =1;
        SciaRegs.SCICTL2.bit.RXBKINTENA =1;

        SciaRegs.SCIHBAUD    =0x0000;  // 9600 baud @LSPCLK = 15MHz (60 MHz SYSCLK).
    SciaRegs.SCILBAUD    =0x00C2;

        SciaRegs.SCICTL1.all =0x0023;  // Relinquish SCI from Reset
}

// Transmit a character from the SCI
void scia_xmit(int a)
{
    while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
    SciaRegs.SCITXBUF=a;

}

void scia_msg(char * msg)
{
    int i;
    i = 0;
    while(msg != '\0')
    {
        scia_xmit(msg);
        i++;
    }
}

// Initalize the SCI FIFO
void scia_fifo_init()
{
    SciaRegs.SCIFFTX.all=0xE040;
    SciaRegs.SCIFFRX.all=0x2044;
    SciaRegs.SCIFFCT.all=0x0;

}

//===========================================================================
// No more.
//===========================================================================

下面是DSP2803x_Headers_nonBIOS  和F28031    CMD文件
DSP2803x_Headers_nonBIOS.txt (7.51 KB)
(下载次数: 2, 2015-8-29 09:05 上传)


F28031.txt (8.49 KB)
(下载次数: 2, 2015-8-29 09:05 上传)


DSP2803x_Headers_nonBIOS.txt (7.51 KB)
(下载次数: 2, 2015-8-29 09:05 上传)

F28031.txt (8.49 KB)
(下载次数: 2, 2015-8-29 09:05 上传)



  • 无标题.png
点赞  2015-8-29 09:07
试了把ADC人部分删除就正常了。怎么回事。

以下是删除部分

//ADC
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
   EALLOW;  // This is needed to write to EALLOW protected register
   PieVectTable.ADCINT1 = &adc_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2803x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   InitAdc();  // For this example, init the ADC

// Step 5. User specific code, enable interrupts:

// Enable ADCINT1 in PIE
   PieCtrlRegs.PIEIER1.bit.INTx1 = 1;        // Enable INT 1.1 in the PIE
   IER |= M_INT1;                                                 // Enable CPU Interrupt 1
   EINT;                                                          // Enable Global interrupt INTM
   ERTM;                                                          // Enable Global realtime interrupt DBGM

   LoopCount = 0;
   ConversionCount = 0;

// Configure ADC
        EALLOW;
        AdcRegs.ADCCTL1.bit.INTPULSEPOS        = 1;        //ADCINT1 trips after AdcResults latch
        AdcRegs.INTSEL1N2.bit.INT1E     = 1;        //Enabled ADCINT1
        AdcRegs.INTSEL1N2.bit.INT1CONT  = 0;        //Disable ADCINT1 Continuous mode
        AdcRegs.INTSEL1N2.bit.INT1SEL        = 1;        //setup EOC1 to trigger ADCINT1 to fire
        AdcRegs.ADCSOC0CTL.bit.CHSEL         = 4;        //set SOC0 channel select to ADCINA4
        AdcRegs.ADCSOC1CTL.bit.CHSEL         = 2;        //set SOC1 channel select to ADCINA2
        AdcRegs.ADCSOC0CTL.bit.TRIGSEL         = 5;        //set SOC0 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
        AdcRegs.ADCSOC1CTL.bit.TRIGSEL         = 5;        //set SOC1 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
        AdcRegs.ADCSOC0CTL.bit.ACQPS         = 6;        //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
        AdcRegs.ADCSOC1CTL.bit.ACQPS         = 6;        //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
        EDIS;

// Assumes ePWM1 clock is already enabled in InitSysCtrl();
   EPwm1Regs.ETSEL.bit.SOCAEN        = 1;                // Enable SOC on A group
   EPwm1Regs.ETSEL.bit.SOCASEL        = 4;                // Select SOC from from CPMA on upcount
   EPwm1Regs.ETPS.bit.SOCAPRD         = 1;                // Generate pulse on 1st event
   EPwm1Regs.CMPA.half.CMPA         = 0x0080;        // Set compare A value
   EPwm1Regs.TBPRD                                 = 0xFFFF;        // Set period for ePWM1
   EPwm1Regs.TBCTL.bit.CTRMODE         = 0;                // count up and start
//END ADC
点赞  2015-8-29 10:44
原来是 InitAdc(); 中调用汇编的延时函数   而出错。。。
点赞  2015-8-29 14:26
把DSP28xxx_ADC_cal.asm文件加进去
作为一个水军,就是尽量的多回帖,因为懂的技术少,所以回帖水分大,见谅! EEWORLD开发板置换群:309018200,——电工们免费装β的天堂,商家勿入!加群暗号:喵
点赞  2015-8-29 21:08
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复