微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 硬件电路设计 > TI模拟硬件电路设计 > 定时器0中断

定时器0中断

时间:10-02 整理:3721RD 点击:


我从EEWORLD网站上载了一些例子,学习2812。
没有电路板,只进行软件仿真。
其中一个定时器0中断,发现不进中断。
情况是这样的,观察定时器可以计数。
本来我定时器周期设为0XFFFFFFFF.
可是计到0以后,并不恢复为0XFFFFFFFF,
而是0X5F5E100.并且计到0以后,也不进中断。
请高手指教,谢谢!我已经被这个问题困扰了好久。
下面是主程序:
#include \"DSP281x_Device.h\" // DSP281x Headerfile Include File
#include \"DSP281x_Examples.h\" // DSP281x Examples Include File

interrupt void cpu_timer0_isr(void);

void main(void)
{

InitSysCtrl();

DINT;

InitPieCtrl();


IER = 0x0000;
IFR = 0x0000;

InitPieVectTable();

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

InitCpuTimers(); // For this example, only initialize the Cpu Timers

ConfigCpuTimer(&CpuTimer0, 100, 1000000);
StartCpuTimer0();

IER |= M_INT1;

PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

for(;


{asm(\" nop\"

;
asm(\" nop\"

;
}

}

interrupt void cpu_timer0_isr(void)
{
CpuTimer0.InterruptCount++; //断点在这,但运行不到这里
asm(\" nop\");

PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}

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

IFR = 0x0000;

这句应该写成

IFR = 0xFFFF;

先清所有的中断标志位.

程序没有进中断无非是中断响应相关的设置不正确.拿本书对照着仔细查一下.

谢谢你的恢复!
我照你说的改了一下,又出现了新的问题。
运行时出现以下错误提示。
Trouble running Target CPU: Can\'t write to data memory 0x801, check memory config [-2184]
我估计是CMD文件的问题,可是
我在CMD文件中没有定义0X801这个地址。
请各位高手继续指教。多谢!
我的两个CMD文件:
1。
MEMORY
{
PAGE 0: /* Program Memory */

PAGE 1: /* Data Memory */

DEV_EMU : origin = 0x000880, length = 0x000180 /* device emulation registers */
PIE_VECT : origin = 0x000D00, length = 0x000100 /* PIE Vector Table */
FLASH_REGS : origin = 0x000A80, length = 0x000060 /* FLASH registers */
CSM : origin = 0x000AE0, length = 0x000010 /* code security module registers */
XINTF : origin = 0x000B20, length = 0x000020 /* external interface registers */
CPU_TIMER0 : origin = 0x000C00, length = 0x000008 /* CPU Timer0 registers (CPU Timer1 and Timer2 are reserved for BIOS)*/
PIE_CTRL : origin = 0x000CE0, length = 0x000020 /* PIE control registers */
ECANA : origin = 0x006000, length = 0x000040 /* eCAN control and status registers */
ECANA_LAM : origin = 0x006040, length = 0x000040 /* eCAN local acceptance masks */
ECANA_MOTS : origin = 0x006080, length = 0x000040 /* eCAN message object time stamps */
ECANA_MOTO : origin = 0x0060C0, length = 0x000040 /* eCAN object time-out registers */
ECANA_MBOX : origin = 0x006100, length = 0x000100 /* eCAN mailboxes */
SYSTEM : origin = 0x007010, length = 0x000020 /* System control registers */
SPIA : origin = 0x007040, length = 0x000010 /* SPI registers */
SCIA : origin = 0x007050, length = 0x000010 /* SCI-A registers */
XINTRUPT : origin = 0x007070, length = 0x000010 /* external interrupt registers */
GPIOMUX : origin = 0x0070C0, length = 0x000020 /* GPIO mux registers */
GPIODAT : origin = 0x0070E0, length = 0x000020 /* GPIO data registers */
ADC : origin = 0x007100, length = 0x000020 /* ADC registers */
EVA : origin = 0x007400, length = 0x000040 /* Event Manager A registers */
EVB : origin = 0x007500, length = 0x000040 /* Event Manager B registers */
SCIB : origin = 0x007750, length = 0x000010 /* SCI-B registers */
MCBSPA : origin = 0x007800, length = 0x000040 /* McBSP registers */
CSM_PWL : origin = 0x3F7FF8, length = 0x000008 /* Part of FLASHA. CSM password locations. */
}

SECTIONS
{
PieVectTableFile : > PIE_VECT, PAGE = 1

/*** Peripheral Frame 0 Register Structures ***/
DevEmuRegsFile : > DEV_EMU, PAGE = 1
FlashRegsFile : > FLASH_REGS, PAGE = 1
CsmRegsFile : > CSM, PAGE = 1
XintfRegsFile : > XINTF, PAGE = 1
CpuTimer0RegsFile : > CPU_TIMER0, PAGE = 1
PieCtrlRegsFile : > PIE_CTRL, PAGE = 1

/*** Peripheral Frame 1 Register Structures ***/
SysCtrlRegsFile : > SYSTEM, PAGE = 1
SpiaRegsFile : > SPIA, PAGE = 1
SciaRegsFile : > SCIA, PAGE = 1
XIntruptRegsFile : > XINTRUPT, PAGE = 1
GpioMuxRegsFile : > GPIOMUX, PAGE = 1
GpioDataRegsFile : > GPIODAT PAGE = 1
AdcRegsFile : > ADC, PAGE = 1
EvaRegsFile : > EVA, PAGE = 1
EvbRegsFile : > EVB, PAGE = 1
ScibRegsFile : > SCIB, PAGE = 1
McbspaRegsFile : > MCBSPA, PAGE = 1

/*** Peripheral Frame 2 Register Structures ***/
ECanaRegsFile : > ECANA, PAGE = 1
ECanaLAMRegsFile : > ECANA_LAM PAGE = 1
ECanaMboxesFile : > ECANA_MBOX PAGE = 1
ECanaMOTSRegsFile : > ECANA_MOTS PAGE = 1
ECanaMOTORegsFile : > ECANA_MOTO PAGE = 1

/*** Code Security Module Register Structures ***/
CsmPwlFile : > CSM_PWL, PAGE = 1
}
2。MEMORY
{
PAGE 0 :
/* For this example, H0 is split between PAGE 0 and PAGE 1 */
/* BEGIN is used for the \"boot to HO\" bootloader mode */
/* RESET is loaded with the reset vector only if */
/* the boot is from XINTF Zone 7. Otherwise reset vector */
/* is fetched from boot ROM. See .reset section below */

RAMM0 : origin = 0x000000, length = 0x000400
BEGIN : origin = 0x3F8000, length = 0x000002
PRAMH0 : origin = 0x3F8002, length = 0x000FFE
RESET : origin = 0x3FFFC0, length = 0x000002


PAGE 1 :

/* For this example, H0 is split between PAGE 0 and PAGE 1 */

RAMM1 : origin = 0x000400, length = 0x000400
DRAMH0 : origin = 0x3f9000, length = 0x001000
}

SECTIONS
{
/* Setup for \"boot to H0\" mode:
The codestart section (found in DSP28_CodeStartBranch.asm)
re-directs execution to the start of user code.
Place this section at the start of H0 */

codestart : > BEGIN, PAGE = 0
ramfuncs : > PRAMH0 PAGE = 0
.text : > PRAMH0, PAGE = 0
.cinit : > PRAMH0, PAGE = 0
.pinit : > PRAMH0, PAGE = 0
.switch : > RAMM0, PAGE = 0
.reset : > RESET, PAGE = 0, TYPE = DSECT /* not used, */

.stack : > RAMM1, PAGE = 1
.ebss : > DRAMH0, PAGE = 1
.econst : > DRAMH0, PAGE = 1
.esysmem : > DRAMH0, PAGE = 1


}

补充:还有一个现象,单步运行时,出现错误提示:
Can\'t Single Step Target Program: Can\'t write to data memory 0x803, check memory config [-2184]
Can\'t Single Step Target Program: Can\'t write to data memory 0x805, check memory config [-2184]
Can\'t Single Step Target Program: Can\'t write to data memory 0x807, check memory config [-2184]
Can\'t Single Step Target Program: Can\'t write to data memory 0x809, check memory config [-2184]
Can\'t Single Step Target Program: Can\'t write to data memory 0x80B, check memory config [-2184]
Can\'t Single Step Target Program: Can\'t write to data memory 0x80D, check memory config [-2184]
...............................
请各位大侠不吝赐教!多谢。

再补充:程序运行到
ERTM; // Enable Global realtime interrupt DBGM
这一步以后,就会跳到
000000 0000 ITRAP0
然后就会出现上面的问题。
问题越来越具体了。

各位大侠,快来指教啊,谢谢啦。
还有qzx0580兄。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top