欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > DOCX文档下载  

    Nios II按键中断调试程序及经验.docx

    • 资源ID:3061919       资源大小:37.60KB        全文页数:3页
    • 资源格式: DOCX        下载积分:6.99金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要6.99金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    Nios II按键中断调试程序及经验.docx

    Nios II按键中断调试程序及经验软件:Quatus II 6.1,Nios II 6.1 硬件:EP1C3T144 FPGA开发板 实验目的:熟悉nios II开发,掌握中断程序调试 系统配置:CPU+OnChipRam(4K)+LED_PIO+BUTTON_PIO 功能描述:按键实现中断,使led亮或灭 led配置成开发板上的led0,led1,led2,led3 按键采用简单按钮B17,B18,19,B20 不给过多注释了(其实注释够多了) #include <stdlib.h> #include <io.h> #include "sys/alt_irq.h" #include "altera_avalon_pio_regs.h" #include "system.h" /* A variable to hold the value of the button pio edge capture register. */ volatile int edge_capture; #ifdef BUTTON_PIO_BASE /* 按键中断服务程序*/ static void handle_button_interrupts(void* context, alt_u32 id) /* Cast context to edge_capture's type. It is important that this be * declared volatile to avoid unwanted compiler optimization. */ volatile int* edge_capture_ptr = (volatile int*) context; /* Store the value in the Button's edge capture register in *context. */ *edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE); /* Reset the Button's edge capture register. */ IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0); /* Initialize the button_pio. */ static void init_button_pio /* Recast the edge_capture pointer to match the alt_irq_register function * prototype. */ void* edge_capture_ptr = (void*) &edge_capture; /* Enable all 4 button interrupts. */从硬件角度,允许硬件中断 IOWR_ALTERA_AVALON_PIO_IRQ_MASK(BUTTON_PIO_BASE, 0xf); /* Reset the edge capture register. */ IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0x0); /* Register the interrupt handler. */ 注册后开中断 alt_irq_register( BUTTON_PIO_IRQ, edge_capture_ptr, handle_button_interrupts ); #endif int main (void) _attribute_ (weak, alias ("alt_main"); int alt_main(void) alt_irq_init(ALT_IRQ_BASE); /necessary,enable interrupts alt_sys_init; /unnecessary alt_io_redirect(ALT_STDOUT,ALT_STDIN,ALT_STDERR);/unnecessary init_button_pio; while(1) switch(edge_capture) case 0x01: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,0xFF); break; case 0x02: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,0x00); break; case 0x04: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,0xFF); break; case 0x08: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,0x00); break; default: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,0x0A); break; return 0; 1 因为使用的是片上RAM,容量有限,故得重载alt_main, 否则空间不够 2 系统默认的alt_main是干了很多活的.比如系统中断,IO设备驱动等,改写的时候得注意,哪些用户程序用到了.比如本例用到中断,故 alt_irq_init(ALT_IRQ_BASE);函数是必须的.开始没有调试成功就是因为没有开总中断 中断的调试过程可以依次看以下: status:最低位PIE,为禁止,为允许中断 ienable:32位,每位对应一个外部中断,为则对应使能 ipending:表示处理器正在处理的中断 全局变量:alt_irq.若注册成功的话就会向向量表写入和Context.注册完后返回则成功,为负则失败

    注意事项

    本文(Nios II按键中断调试程序及经验.docx)为本站会员(小飞机)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开