In order to use an interrupt in a Cortex-M3/M4, you need the following

本文讨论了微控制器核心在中断发生时自动保存寄存器到堆栈的过程,强调了正确设置向量表、中断使能和优先级配置的重要性。通过确保中断处理程序的正确位置和初始化中断源,实现安全、高效的中断处理机制。
  • a stack.
    The core automatically saves several registers on the stack when an interrupt fires.
    Initial stack pointer value is read from address 0x0 the first thing when the core starts up.
    That value should normally equal to the end of RAM + 1.

  • correct vector table offset in the SCB->VTOR register.
    By default it's 0, which (again by default) is the start of flash.
    If your startup code / linker script combination sets up the vector table correctly, great.

  • a handler. you have that.

  • address of that handler + 1 needs to be in the correct position in the vector table.
    The way you're assigning a value to a location in the (assumed) vector table
    isn't going to work by default, since it's in flash.

  • the interrupt needs to be enabled in the NVIC and its priority set.
    This uses NVIC->ISER[x] and NVIC->IPR[x] registers.

  • finally, the peripheral needs to be configured to generate actual interrupt requests. 

 

转载于:https://www.cnblogs.com/shangdawei/p/4687495.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值