PC3 下降沿触发中断为例
第一步:设置IO
GPIOC->DDR&=~(1<<3);//设置成输入
GPIOC->CR1|=(1<<3);//悬浮输入/上拉开关
GPIOC->CR2|=(1<<3);//中断使能
EXTI->CR1|=(1<<5);//下降沿触发
第二步:写中断函数
INTERRUPT void GPIOC_IRQHandller(void)
{
///.....
}
//中断向量指定文件中
INTERRUPT void GPIOC_IRQHandller(void);//声明
struct interrupt_vector const _vectab[] = {
{0x82, (interrupt_handler_t)_stext}, /* reset */
{0x82, NonHandledInterrupt}, /* trap */
{0x82, NonHandledInterrupt}, /* irq0 */
{0x82, NonHandledInterrupt}, /* irq1 */
{0x82, NonHandledInterrupt}, /* irq2 */
{0x82, NonHandledInterrupt}, /* irq3 */
{0x82, NonHandledInterrupt}, /* irq4 */
{0x82, GPIOC_IRQHandller}, /* irq5 在这里指定*/
.....
第三步:总中断允许
|
|