打印
[MCU]

什么都进不去

[复制链接]
335|15
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
spark周|  楼主 | 2020-1-18 13:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我都要疯了!SVPWM 软件法,弄了一周了,下溢中断进不去,我换了文件(vectors.asm)到最后什么中断都进不去了,这是怎么回事?!求帮助。。。。

使用特权

评论回复

相关帖子

沙发
dengdc| | 2020-1-18 13:40 | 只看该作者
什么中断都进不去了?

使用特权

评论回复
板凳
spark周|  楼主 | 2020-1-18 13:47 | 只看该作者
我是说int2中的比较、周期、上溢、下溢中断

使用特权

评论回复
地板
jiahy| | 2020-1-18 13:50 | 只看该作者
楼主程序可以公开吗?贴程序看下吧,这么说看不出什么原因

使用特权

评论回复
5
spark周|  楼主 | 2020-1-18 13:54 | 只看该作者
我设了CMPR1\2\3,但是只有CMPR1输出对称波形了,其他的都是没有,这是怎么回事呢?

使用特权

评论回复
6
spark周|  楼主 | 2020-1-18 13:57 | 只看该作者

程序在这--主程序

#include  "register.h"

int count,count1;


void KickDog()                                /*踢除看门狗 */
{
        WDKEY=0x5555;
        WDKEY=0xAAAA;
}

void initsys(){
        asm(" SETC        INTM ");        /* 关闭总中断 */
        asm(" CLRC  SXM  ");        /* 禁止符号位扩展 */
        asm(" CLRC  CNF  ");    /* B0块映射为 on-chip DARAM*/
        asm(" CLRC  OVM  ");    /* 累加器结果正常溢出*/
        SCSR1=0x83FE;                 /* 系统时钟CLKOUT=20*2=40M */
                                                        /* 打开ADC,EVA,EVB,CAN和SCI的时钟,系统时钟CLKOUT=40M */
        WDCR=0x006F;                        /* 禁止看门狗,看门狗时钟64分频 */
        KickDog();                            /* 初始化看门狗 */  
    IFR=0xFFFF;                                /* 清除中断标志 */
    IMR=0x0002;        
}  

void inline disable(){
asm(" setc INTM ");
}

void inline enable(){
asm(" clrc INTM ");
}

void PWMinit(){
        MCRA=MCRA|0x0FC0;         //  开PWM1~6  其他都是IO功能
        EVAIFRA=0xFFFF;                        //  清除中断标志
        ACTRA=0x0666;                                 // PWM1、3、5高有效,PWM2、4、6低有效
        GPTCONA=0x41;
        DBTCONA=0x01F4;              //死区时间1.6us
        CMPR1=100;     
        CMPR2=200;
        CMPR3=400;
        T1PR=1000;
        COMCONA=0x8200;
        T1CNT=0;  
        EVAIMRA=0x0080;                        //定时器1下溢中断使能  
//        EVAIFRC=EVAIFRC|0X0FFFF;      
        T1CON=0x0840;       //连续增减模式
        
}


void interrupt nothing()
{
        count1++;
        if(count1==5000)
                count1=0;
return;
}



void main()
{
count=0;
count1=0;
disable();                            //总中断禁止
   
initsys();                            //系统初始化
PWMinit();                            //pwm初始化

while(1);

}

void interrupt c_int2()               /*定时器1中断服务程序*/
{
               
        count++;
        if(count==5000)
                count=0;
/*   if(PIVR!=0x27)
                {          asm(" CLRC INTM ");
                        return;
                }
*/
        T1CNT=0;
        EVAIFRA=0x0080;              //清除下溢中断标志位
        asm(" CLRC        INTM ");   
        
}

使用特权

评论回复
7
jlyuan| | 2020-1-18 14:00 | 只看该作者

vectors.asm程序

使用特权

评论回复
8
spark周|  楼主 | 2020-1-18 14:04 | 只看该作者

         .title "vectors.asm"
            .ref    _c_int0
            .ref    _nothing
        ;    .ref    _int1
            .ref    _c_int2
          ;  .ref    _int5
            .sect   ".vectors"
_vector:
reset       b       _c_int0         ; 0x0000: 1 c_int0 函数调用main函数开始执行c程序
int1        b       _nothing    ; 0x0002: 4 (pdpinta 0x0020 4 int1_0.0)
int2        b       _c_int2     ; 0x0004: 5
int3        b       _nothing        ; 0x0006: 6
int4        b       _nothing        ; 0x0008: 7
int5        b       _nothing     ; 0x000a: 8 (rxint 0x0006 43 int5_1.8) (txint 0x0007 44 int5_1.9)
int6        b       _nothing        ; 0x000c: 9
reserved    b       _nothing        ; 0x000e:10 Analysis Int
sw_int8     b       _nothing        ; 0x0010: -
sw_int9     b       _nothing        ; 0x0012: -
sw_int10    b       _nothing        ; 0x0014: -
sw_int11    b       _nothing        ; 0x0016: -
sw_int12    b       _nothing        ; 0x0018: -
sw_int13    b       _nothing        ; 0x001a: -
sw_int14    b       _nothing        ; 0x001c: -
sw_int15    b       _nothing        ; 0x001e: -
sw_int16    b       _nothing        ; 0x0020: -
trap        b       _nothing        ; 0x0022: - Trap vector
nmi         b       _nothing        ; 0x0024: 3 Non maskable Int
emu_trap    b       _nothing        ; 0x0026: 2 Emulator Trap 2
sw_int20    b       _nothing        ; 0x0028: -
sw_int21    b       _nothing        ; 0x002a: -
sw_int22    b       _nothing        ; 0x002c: -
sw_int23    b       _nothing        ; 0x002e: -
sw_int24    b       _nothing        ; 0x0030: -
sw_int25    b       _nothing        ; 0x0032: -
sw_int26    b       _nothing        ; 0x0034: -
sw_int27    b       _nothing        ; 0x0036: -
sw_int28    b       _nothing        ; 0x0038: -
sw_int29    b       _nothing        ; 0x003a: -
sw_int30    b       _nothing        ; 0x003c: -
sw_int31    b       _nothing        ; 0x003e: -
            .sect   ".pvecs"        ;.text
_text:            
phantom     b       _nothing       ;0x0000: phantom
xint1       b       _nothing       ;0x0001: 7 int1_0.2 (48 int6_1.13)
            b       _nothing       ;0x0002: pevctor
            b       _nothing       ;0x0003: pevctor
adcint      b       _nothing       ;0x0004: 6 int1_0.1 (47 int6_1.12)
spiint      b       _nothing       ;0x0005: 9 int1_0.4 (42 int5_1.7)
rxint       b       _nothing       ;0x0006:10 int1_0.5 (43 int5_1.8)
txint       b       _nothing       ;0x0007:11 int1_0.6 (44 int5_1.9)
            b       _nothing       ;0x0008: pevctor
            b       _nothing       ;0x0009: pevctor
            b       _nothing       ;0x000a: pevctor
            b       _nothing       ;0x000b: pevctor
            b       _nothing       ;0x000c: pevctor
            b       _nothing       ;0x000d: pevctor
            b       _nothing       ;0x000e: pevctor
            b       _nothing       ;0x000f: pevctor
            b       _nothing       ;0x0010: pevctor
xint2       b       _nothing       ;0x0011: 8 int1_0.3 (49 int6_1.14)
            b       _nothing       ;0x0012: pevctor
            b       _nothing       ;0x0013: pevctor
            b       _nothing       ;0x0014: pevctor
            b       _nothing       ;0x0015: pevctor
            b       _nothing       ;0x0016: pevctor
            b       _nothing       ;0x0017: pevctor
            b       _nothing       ;0x0018: pevctor
pdpintb     b       _nothing       ;0x0019: 5 int1_2.0
            b       _nothing       ;0x001a: pevctor
            b       _nothing       ;0x001b: pevctor
            b       _nothing       ;0x001c: pevctor
            b       _nothing       ;0x001d: pevctor
            b       _nothing       ;0x001e: pevctor
            b       _nothing       ;0x001f: pevctor
pdpinta     b       _nothing       ;0x0020: 4 int1_0.0
cmp1int     b       _nothing       ;0x0021:14 int2_0.9
cmp2int     b       _nothing       ;0x0022:15 int2_0.10
cmp3int     b       _nothing       ;0x0023:16 int2_0.11
cmp4int     b       _nothing       ;0x0024:21 int2_2.1
cmp5int     b       _nothing       ;0x0025:22 int2_2.2
cmp6int     b       _nothing       ;0x0026:23 int2_2.3
t1pint      b       _nothing       ;0x0027:17 int2_0.12
t1cint      b       _nothing       ;0x0028:18 int2_0.13
t1ufint     b       _nothing       ;0x0029:19 int2_0.14
t1ofint     b       _nothing       ;0x002a:20 int2_0.15
t2pint      b       _nothing       ;0x002b:28 int3_1.0
t2cint      b       _nothing       ;0x002c:29 int3_1.1
t2ufint     b       _nothing       ;0x002d:30 int3_1.2
t2ofint     b       _nothing       ;0x002e:31 int3_1.3
t3pint      b       _nothing       ;0x002f:24 int2_2.4
t3cint      b       _nothing       ;0x0030:25 int2_2.5
t3ufint     b       _nothing       ;0x0031:26 int2_2.6
t3ofint     b       _nothing       ;0x0032:27 int2_2.7
cap1int     b       _nothing       ;0x0033:36 int4_1.4
cap2int     b       _nothing       ;0x0034:37 int4_1.5
cap3int     b       _nothing       ;0x0035:38 int4_1.6
cap4int     b       _nothing       ;0x0036:39 int4_2.12
cap5int     b       _nothing       ;0x0037:40 int4_2.13
cap6int     b       _nothing       ;0x0038:41 int4_2.14
t4ping      b       _nothing       ;0x0039:32 int3_2.8
t4cint      b       _nothing       ;0x003a:33 int3_2.9
t4ufint     b       _nothing       ;0x003b:34 int4_2.10
t4ofint     b       _nothing       ;0x003c:35 int4_2.11
            b       _nothing       ;0x003d: pevctor
            b       _nothing       ;0x003e: pevctor
            b       _nothing       ;0x003f: pevctor
canmbint    b       _nothing       ;0x0040:12 int1_0.7 (45 int5_1.10)
canerint    b       _nothing       ;0x0041:13 int2_0.8 (46 int5_1.11)
            .end

使用特权

评论回复
9
spark周|  楼主 | 2020-1-18 14:10 | 只看该作者

我都不知道怎么写中断向量表才是正确的!!
还有他的入口!

使用特权

评论回复
10
spark周|  楼主 | 2020-1-18 14:13 | 只看该作者
我写28335的时候也没有这样过啊,都是现成的东西,怎么2407就得自己弄呢???!!无语2.。。。。

使用特权

评论回复
11
huangchui| | 2020-1-18 14:15 | 只看该作者

感觉程序有些乱
两个中断服务函数    &nothing和&c_int2两个入口好像没有指定啊

使用特权

评论回复
12
zhaoxqi| | 2020-1-18 14:19 | 只看该作者

DSP2407有两级中断:
第一级是来自外设的中断请求(PIRQ)
第二级是内核级中断请求(INTn)
中断原理为:当CPU接收到一个内核级中断INTn请求时,它并不知道具体是那个外设中断事件引起的,因此为了使CPU响应正确的中断,DSP为每个外设中断分配了一个惟一的中断向量。当PIE接收到CPU控制器发出中断应答信号后,PIE控制器将外设中断的中断向量值放入中断向量寄存器PIVR中,通过判断PIVR中的地址值来确定是那个外设中断响应的。在DSP2407中的define.asm文件中有这样的语句:
;建立中断向量表         
            .sect     ".vectors"           
RSVECT      B     _c_int0 //地址为0000h
INT1      B  PHANTOM       //地址为0002h
INT2      B       _c_int2//地址为0004h
INT3        B       PHANTOM  //地址为0006h
INT4  B  PHANTOM//地址为0008h
INT5        B  PHANTOM//地址为000ah
INT6  B       PHANTOM//地址为000ch
当一个内核级中断发生时 就执行到相应的通用中断服务程序中:
如INT2      B       _c_int2//地址为0004h
就执行_c_int2对应的地址:也就是C语言中的c_int2;
在C语言和汇编语言中差一个下划线,即汇编语言中的_c_int2和C语言中的c_int2是一样的。
我们在MAIN.C中找到:void interrupt c_int2()              
{
   if(PIVR!=0x27)
  {   asm(" CLRC INTM ");
   return;
  }
T1CNT=0;
numled++;
   
EVAIFRA=0x80;
asm(" CLRC INTM ");  

}
也就是说中断发生时执行这段服务程序:
用if(PIVR!=0x27)来判断具体是哪一个外设触发。

使用特权

评论回复
13
spark周|  楼主 | 2020-1-18 14:23 | 只看该作者

你的意思是0x27是INT2的代号?

使用特权

评论回复
14
spark周|  楼主 | 2020-1-18 14:26 | 只看该作者
那我想问一下,如果是这样的话,那为什么在EV中,我可以进入周期中断,但是我不能进入下溢 上溢 比较恩?是不是某个文件有问题 CMD ?。H?

使用特权

评论回复
15
shimx| | 2020-1-18 14:32 | 只看该作者

#include "GLOBAL.C"
void SystemInit();
int Timer1Init();
void KickDog();
main()
{  

   SystemInit();                 //系统初始化
   MCRC=MCRC & 0xFF00;             //IOPE0-7设为IO口模式
   PEDATDIR=0xFF00;               //所有LED=0,
   
   Timer1Init();                  //定时器初始化
   asm(" CLRC INTM ");
   T1CON=T1CON|0x0040;        
   while(1);
   
}

void SystemInit()
{  

        asm(" SETC        INTM ");        /* 关闭总中断 */
        asm(" SETC  SXM  ");        /* 禁止符号位扩展 */
        asm(" CLRC  CNF  ");    /* B0块映射为 on-chip DARAM*/
        asm(" CLRC  OVM  ");    /* 累加器结果正常溢出*/
//        SCSR1=0x83FE;                 /* 系统时钟CLKOUT=20*2=40M */
                                                           /* 打开ADC,EVA,EVB,CAN和SCI的时钟,系统时钟CLKOUT=40M */
        SCSR1=0x81FE;
                                                        
        WDCR=0x0e8;                        /* 禁止看门狗,看门狗时钟64分频 */
    IMR=0x0002;                                /* 打开中断1,2*/  
    IFR=0xFFFF;                                /* 清除中断标志 */
    WSGR=0x00;  //等待状态发生控制寄存器设置为0,禁止所有等待状态     
}  
  
int Timer1Init()           
{
    EVAIMRA=EVAIMRA|0x0080;                        //定时器1周期中断使能
    EVAIFRA=EVAIFRA&0x0080;
    T1CON=0x160c;
    T1PR=2500;
//        T1PR=0x0177;                                //定时器1初值,定时0.4us*2500=1ms                        
        T1CNT=0;

}

void interrupt c_int2()               //定时器1中断服务程序
{
   int flag;
   flag=EVAIFRA&0X0080;
   if(flag!=0x0080)
   {   
             asm(" CLRC INTM ");            
                        return;
   }
  /* if(PIVR!=0X27)
    {   
             asm(" CLRC INTM ");            
                        return;
   }*/
         
          T1CNT=0x00;  //定时器1的计数寄存器清零
      EVAIFRA=EVAIFRA&0x0080;  //清除定时器1周期中断标志
      PEDATDIR=0xfff0;
      
      asm(" clrc  INTM ");        
      
      return;
}
void KickDog()    //踢除看门狗
{
WDKEY=0x5555;
WDKEY=0xAAAA;
}  我这定时器中断进不去  为什么   都查吐了

使用特权

评论回复
16
zhenykun| | 2020-1-18 14:36 | 只看该作者
你的中断后面都能知道怎么配置了!!

使用特权

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

本版积分规则

821

主题

10121

帖子

4

粉丝