中断配置:SCR.FIQ/SCR.IRQ的详细配置解析

459 篇文章 ¥59.90 ¥99.00
本文介绍了嵌入式系统中中断的重要性,特别是ARM处理器的SCR寄存器在FIQ和IRQ中断配置中的作用。通过源代码示例展示了如何启用FIQ和IRQ中断,强调了中断配置在实现实时响应中的关键角色。

中断配置:SCR.FIQ/SCR.IRQ的详细配置解析

嵌入式系统中,中断是一种重要的机制,用于处理异步事件和实现实时响应。在嵌入式系统中,ARM体系结构的处理器广泛应用,其中包括一些特殊寄存器,如SCR(System Control Register),它允许配置中断。SCR寄存器中的FIQ(Fast Interrupt Request)位和IRQ(Interrupt Request)位用于控制中断。本文将详细解析SCR.FIQ和SCR.IRQ的配置,并提供相应的源代码示例。

首先,我们来了解一下FIQ和IRQ的概念。在ARM体系结构中,FIQ和IRQ是两种不同的中断类型。FIQ中断是一种高优先级的中断,用于处理紧急事件,如实时控制和数据传输。IRQ中断是一种低优先级的中断,用于处理一般事件,如外部设备的输入输出。

以下是一个示例代码片段,演示了如何配置SCR.FIQ和SCR.IRQ位:

#include <stdint.h>
#include 
帮我分析这个代码,是arm a52的cpu,32位: //----------------------------------------------------------------------------- // The confidential and proprietary information contained in this file may // only be used by a person authorised under and to the extent permitted // by a subsisting licensing agreement from ARM Limited or its affiliates. // // (C) COPYRIGHT 2014-2021 ARM Limited or its affiliates. // ALL RIGHTS RESERVED // // This entire notice must be reproduced on all copies of this file // and copies of this file may only be made by a person if such person is // permitted to do so under the terms of a subsisting license agreement // from ARM Limited or its affiliates. // // Release Information : Cortex-R52 Processor MP040-r1p4-00rel0 // //----------------------------------------------------------------------------- .include "shared/bootcode/boot_defs.hs" // Enable UAL syntax .syntax unified .section .text.vectors, "ax", %progbits .global vector_table .type vector_table, %function // Weakly import replacement handlers. This allows a test to redefine // handlers. If it doesn't, the default ones below will be used. .weak bootcode_other .weak undef_handler .weak svc_handler .weak pf_abort_handler .weak data_abort_handler .type data_abort_handler, %function .weak irq_handler .type irq_handler, %function .weak fiq_handler .type print, %function //------------------------------------------------------------------------------ // Vector table //------------------------------------------------------------------------------ vector_table: ldr pc, reset_handler_addr // Reset ldr pc, undef_handler_addr // Undef ldr pc, svc_handler_addr // SVC ldr pc, pf_abort_handler_addr // Prefetch abort ldr pc, data_abort_handler_addr // Data abort nop // Not used ldr pc, irq_handler_addr // IRQ ldr pc, fiq_handler_addr // FIQ //------------------------------------------------------------------------------ // Handler addresses //------------------------------------------------------------------------------ reset_handler_addr: .word def_reset_handler undef_handler_addr: .word def_undef_handler svc_handler_addr: .word def_svc_handler pf_abort_handler_addr: .word def_pf_abort_handler data_abort_handler_addr: .word def_data_abort_handler irq_handler_addr: .word def_irq_handler fiq_handler_addr: .word def_fiq_handler //---------------------------------------------------------------------------- // Handler strings //---------------------------------------------------------------------------- // The default handlers print an error message and terminate the simulation // by writing the EOT character to the tube. The error strings are defined // here. undef_exception_str: .asciz "undefined instruction\n" svc_exception_str: .asciz "SVC\n" pf_abort_exception_str: .asciz "prefetch abort\n" data_abort_exception_str: .asciz "data abort\n" irq_exception_str: .asciz "IRQ\n" fiq_exception_str: .asciz "FIQ\n" // Ensure 4-byte alignment for following code .balign 4 //------------------------------------------------------------------------------ // Default handlers // // The default handlers all contain one branch to a weakly-imported exception // handler label followed by default handler code. This allows tests to // define their own handlers, with fall-back default handlers if they do not. // // When a test defines a replacement handler, it must end with an excpetion // return instruction so that the default handler code is never executed. // // When a test does not define a replacement handler, the branch to the // weakly-imported symbol in the default handler is effectively a NOP and // the default handler code is therefore executed. // // The default handlers all print an "Unexpected exception" error message // and terminate the simulation by writing the EOT character to the tube. //------------------------------------------------------------------------------ def_reset_handler: b bootcode def_undef_handler: b undef_handler ldr r0, =undef_exception_str b unexpected_handler def_svc_handler: b svc_handler ldr r0, =svc_exception_str b unexpected_handler def_pf_abort_handler: b pf_abort_handler ldr r0, =pf_abort_exception_str b unexpected_handler def_data_abort_handler: b data_abort_handler ldr r0, =data_abort_exception_str b unexpected_handler def_irq_handler: b irq_handler ldr r0, =irq_exception_str b unexpected_handler def_fiq_handler: b fiq_handler ldr r0, =fiq_exception_str b unexpected_handler // Generic unexpected handler routine. This prints an error message and // terminates the simulation by writing the EOT character to the tube. // Expects r0 to contain a pointer to a string that is the name of the // exception. As this is a terminal routine, no registers are preserved. unexpected_handler: ldr r1, =TUBE_ADDRESS ldr r2, =unexpected_str // Message bl print mov r2, r0 bl print ldr r2, =fail_str bl print // Write EOT character to terminate the simulation mov r2, #0x4 strb r2, [r1] dsb wfi b . // Print a string to the tube // Expects: r1 -> tube // r2 -> message // Modifies r3 print: ldrb r3, [r2], #1 cmp r3, #0 strbne r3, [r1] bne print bx lr unexpected_str: .asciz "Unexpected exception: " fail_str: .asciz "** TEST FAILED **\n" .balign 4 .end
最新发布
06-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值