查看: 1469|回复: 0

[经验] c6000的中断过程描述 及编程

[复制链接]

该用户从未签到

发表于 2021-3-6 21:05:44 | 显示全部楼层 |阅读模式
分享到:
1.  上电复位,产生复位中断请求,上电中断无需确认,直接执行。
2.  STW    B0,*--B15;  进行现场保护
3.  MVKL  addr,B0;
MVKH  addr,B0;载入中断向量表,将中断向量表送入程序指针。
4.  B      B0;跳转至 B0 中存储的地址,执行中断向量表。
5.  执行_c_int00 进行初始化
6.  跳转至 main()执行 csl 函数,IO口,定时器等初始化。
7.  执行 while 循环。
8.  定时时间到,产生定时中断。
9.  重复执行 2-4步骤
10.  执行中断服务程序 c_int14。
11.  中断返回
12.  LDW    *B15++,B0  恢复现场。
13.  继续执行 while 循环。

7.  中断程序解析
void main()
{

           CSL_init();//CSL函数初始化

           Htimer = TIMER_open(TIMER_DEV0,TIMER_OPEN_RESET);//打开定时器 0,返回定
时器句柄
           TimerEventId = TIMER_getEventId(Htimer);//取得定时事件 ID
           TIMER_config(Htimer,&Mtimer_configA);//配置定时器

           Hgpio  = GPIO_open(GPIO_DEV0,GPIO_OPEN_RESET);//打开 IO
           GPIO_config(Hgpio,&Mgpio_config);//配置 IO

           IRQ_setVecs(vectors);//重新设置中断向量,
           IRQ_globalEnable();//全局中断使能
           IRQ_nmiEnable();  
           IRQ_map(TimerEventId,14);//把定时中断重新映射到 14
           IRQ_reset(TimerEventId);
           IRQ_enable(TimerEventId);//

           TIMER_start(Htimer);//定时开始

    while(1);//死循环

           TIMER_close(Htimer);
           GPIO_close(Hgpio);

}
/**********************************************************************
*  中断服务程序
**********************************************************************/
interrupt void c_int14(void)//中断服务程序
{
    if(flag==0)
    {
                GPIO_pinWrite(Hgpio,GPIO_PIN3,flag);  
                flag=1;
           }
           else
           {
                GPIO_pinWrite(Hgpio,GPIO_PIN3,1); //点灯
                flag=0;
           }
}

*------------------------------------------------------------------------------
* Global symbols defined here and exported out of this file
*------------------------------------------------------------------------------
    .global _vectors//全局标号,可以在别处使用.
    .global _c_int00
    .global _vector1
    .global _vector2
    .global _vector3
    .global _vector4
    .global _vector5
    .global _vector6
    .global _vector7
    .global _vector8
   .global _vector9           
    .global _vector10   
    .global _vector11     
    .global _vector12   
    .global _vector13     
    .global _c_int14  ; Hookup the c_int14 ISR in main()
    .global _vector15

*------------------------------------------------------------------------------
* Global symbols referenced in this file but defined somewhere else.   
* Remember that your interrupt service routines need to be referenced here.
*------------------------------------------------------------------------------
    .ref _c_int00//相当于 extern,在这里引用,在别处定义


*------------------------------------------------------------------------------
* This is a macro that instantiates one entry in the interrupt service table.
*------------------------------------------------------------------------------
VEC_ENTRY .macro addr//定义中断向量入口地址

    STW   B0,*--B15;保存B0 内容,中断产生后执行的第一条指令
    MVKL  addr,B0;
      MVKH  addr,B0;//把地址装入 B0
    B     B0;跳转至 B0 中存储的地址
    LDW   *B15++,B0;恢复B0内容; 由于C6000流水线的原因,跳转后仍然可以执行多条指                  

    NOP   2
    NOP   
    NOP   
    .endm


*------------------------------------------------------------------------------
* This is a dummy interrupt service routine used to initialize the IST.
*------------------------------------------------------------------------------
_vec_dummy:未定义中断服务程序
  B     B3;其他没有定义的中断跳转至 B3 存储的地址
  NOP  5

*------------------------------------------------------------------------------
* This is the actual interrupt service table (IST). It is properly aligned and
* is located in the subsection .text:vecs. This means if you don't explicitly
* specify this section in your linker command file, it will default and link
* into the .text section. Remember to set the ISTP register to point to this
* table.
*------------------------------------------------------------------------------
.sect ".text:vecs";定义段
.align 1024;1024 字节对边界对齐

_vectors:
_vector0:    VEC_ENTRY _c_int00      ;RESET  跳转到_c_int00 ,_c_int00是 c语言程序的入口
_vector1:    VEC_ENTRY _vec_dummy  ;NMI
_vector2:    VEC_ENTRY _vec_dummy  ;RSVD
_vector3:    VEC_ENTRY _vec_dummy ;  所有未定义中断均跳转到同一地址
_vector4:    VEC_ENTRY _vec_dummy
_vector5:    VEC_ENTRY _vec_dummy
_vector6:    VEC_ENTRY _vec_dummy
_vector7:    VEC_ENTRY _vec_dummy

_vector8:    VEC_ENTRY _vec_dummy
_vector9:    VEC_ENTRY _vec_dummy
_vector10:  VEC_ENTRY _vec_dummy
_vector11:  VEC_ENTRY _vec_dummy
_vector12:  VEC_ENTRY _vec_dummy
_vector13:  VEC_ENTRY _vec_dummy
_vector14:  VEC_ENTRY _c_int14  ; Hookup the c_int14 ISR in main()  定时中断中断向量
_vector15:  VEC_ENTRY _vec_dummy
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /2 下一条



手机版|小黑屋|与非网

GMT+8, 2024-3-28 23:54 , Processed in 0.112265 second(s), 15 queries , MemCache On.

ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

苏公网安备 32059002001037号

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.