您好,我在主函数中故意进行一步x=(float)1 / 0这样的操作,在调试过程中,没有产生异常,也没有进入中断中,貌似直接给计算过去了,我想问该要捕获这样的异常进行处理,我需要怎么样的配置。有没有相关的Demo程序?谢谢。
Jay:
Hi duan,
请参考帖子:http://www.deyisupport.com/question_answer/microcontrollers/hercules/f/70/t/24732.aspx
安全手册这段中提到的“复位后不会自动打开的异常”应该是指浮点运算单元的异常。
这些异常是:
Floating-point inexact exception
Floating-point overflow exception
Floating-point underflow exception
Floating-point invalid operation exception
Floating-point divide-by-zero exception
Floating-point input denormal exception
这些异常信号受Secondary Auxiliary Control Register(第二辅助控制寄存器)的控制,复位后的默认状态是关闭,用户可以通过Secondary Auxiliary Control Register来打开这些异常。
如何操作Secondary Auxiliary Control 寄存器:
MRC p15, 0, <Rd>, c15, c0, 0 ; Read Secondary Auxiliary Control RegisterMCR p15, 0, <Rd>, c15, c0, 0 ; Write Secondary Auxiliary Control Register详情可以参考ARM的技术手册:http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0363e/index.htmlRegards,Jay
duan duan:
回复 Jay:
您好,那如果只有浮点运算异常没有打开的话,那我在程序中如果出现除零的情况,MCU也是捕获不到?
Jay:
回复 duan duan:
Hi duan,
是这样的。MCU不会把除零处理为异常,但结果将是一个没有意义的值。
regards,
Jay
TI中文支持网

