完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨,我正在尝试为PIC32 MM0256GPM编写一个汇编中断处理程序,但是有困难。当我在C中创建一个ISR函数时,它编译/连接得很好(和运行)。当我对这个函数进行不正确的处理并尝试在汇编文件中使用它时,链接器就抱怨VEC。Tor函数是大的。我缺少什么?向量间距由启动代码设置为8,MVEC启用。我使用下面的ISR C代码:下面的程序集:这是链接器的输出:XC32-L.E.EX:在异常向量1上的函数太大Exc32-L.EXE:由于先前的错误而终止的链接。urin 255退出状态
以上来自于百度翻译 以下为原文 Hi, I am trying to write a assembly interrupt handler for the PIC32MM0256GPM but having difficulties. When i create a isr function in c it compiles / links just fine (and runs). When i take the disassebly of this function and try to use it in a assembly file however, the linker complains that the vector function is to large. What am i missing?, the vector spacing is set by the startup code to 8, and mvec enabled. I used the following isr c code: void __ISR(_CORE_SOFTWARE_0_VECTOR) soft_int_0(void) { Nop(); } And the following assembly: #include #include .global __vector_dispatch_1 .section .vector_1,code,keep .set nomips16 .set micromips .set noreorder .align 2 .ent __vector_dispatch_1 __vector_dispatch_1: jal soft_int_0 nop .set reorder .end __vector_dispatch_1 .size __vector_dispatch_1, .-__vector_dispatch_1 .set nomips16 .set micromips .set noreorder .align 2 .global soft_int_0 soft_int_0: jr ra This is the output from the linker: xc32-ld.exe: function at exception vector 1 too large xc32-ld.exe: Link terminated due to previous error(s). collect2.exe: error: ld returned 255 exit status |
|
相关推荐
6个回答
|
|
|
对于初学者来说,你的调度函数中缺少一个ErET。
以上来自于百度翻译 以下为原文 For starters you are missing an eret from your dispatch function. .ent __vector_dispatch_1 __vector_dispatch_1: jal soft_int_0 nop eret .set reorder .end __vector_dispatch_1 |
|
|
|
|
|
你的右边,我从编译器输出中复制了一部分,所以第二个函数应该是:SoftTytIn0:ErET-但是仍然不能解决这个问题。有趣的是,我复制了编译器的程序集输出,为什么它在C中工作而不是直接在汇编中工作?我漏掉了像指令一样的东西吗?
以上来自于百度翻译 以下为原文 Your right, i copied a part from the compiler output, so the second function should be: soft_int_0: eret But that still doesn't solve the problem. The funny thing is that i copied the assembly output from the compiler, so why does it work in c and not directly in assembly? Am i missing something like a directive? |
|
|
|
|
|
向量间隔为8字节,SoftTytIn 0函数不适用于Vector 1节。把调度存根和ISR函数之间的方向移到主代码部分。然而,ISR已经被编译为正常函数,而调度存根将浪费$RA寄存器,所以我很怀疑它的工作原理,而不是偶然的。如果使用中断函数属性,或者向IP-ISR宏添加IPL说明符,会发生什么?
以上来自于百度翻译 以下为原文 With a vector spacing of 8 bytes, the soft_int_0 function doesn't fit inside the .vector_1 section. Put the directive .textbetween the dispatch stub and ISR function to move it into the main code section. However, as-is the ISR has been compiled as a normal function, and the dispatch stub will trash the $ra register, so I'm rather suspicious of the claim that it works other than by chance. What happens if you use the interrupt function attribute, or add the IPL specifier to the __ISR macro? |
|
|
|
|
|
安德姆斯说WRT中断函数在.Text中。(我没有注意到,已经很晚了)同样,ISR的一个更好的存根形式是:-即跳转到中断例程和中断程序的ErET,而不是存根。节省必须跳回存根,不浪费RA。注意,如果你真的想要多功能中断(创建堆栈帧、推/ POP状态、EPC、重新启用中断、清除中断标志等),则缺少很多代码。
以上来自于百度翻译 以下为原文 What andersm said wrt the interrupt function being in .text. (I didn't notice that, it was late.) Also, a better form of stub for an isr is:- .globl __vector_dispatch_1 .section .vector_1,code,keep .set nomips16 .set micromips .set noreorder .align 2 .ent __vector_dispatch_1 __vector_dispatch_1: j _soft_int_0 nop .set reorder .end __vector_dispatch_1 .size __vector_dispatch_1, .-__vector_dispatch_1 .text .set nomips16 .set micromips .set noreorder .align 2 .global _soft_int_0 .ent _soft_int_0 _soft_int_0: ; ;interrupt code here ; eret .set reorder .end _soft_int_0 .size _soft_int_0, .-_soft_int_0 I.e. just jump to interrupt routine and eret from the interrupt routine, not the stub. Saves having to jump back to the stub and doesn't trash RA. Note you are missing a lot of code if you actually want functioning multiple interrupts (Create stack frame, push/pop STATUS, EPC, re-enable interrupts, clear interrupt flag etc.) |
|
|
|
|
|
除非你想完全放弃C,你也可以在C--yAtEngy((vector(a CoeLeAuthReal00vector)))中声明IRQ,然后在ASM中创建一个具有相同名称的全局函数(in .text节),它将跳转到向量表中的ASM函数,WH。ICH要简单得多
以上来自于百度翻译 以下为原文 unless you are trying to ditch C altogether, you can also just declare the irq in C- __attribute((vector(_CORE_SOFTWARE_0_VECTOR))) void soft_int_0(); then in asm, create a global function with the same name (in .text section) which will get the jump to your asm function placed in the vector table, which is much simpler |
|
|
|
|
|
这确实是我忘记的文字部分,对我来说太晚了。谢谢。谢谢。
以上来自于百度翻译 以下为原文 It was indeed the .text section i forgot, it was late for me too wink: Thanks |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
485 浏览 0 评论
5806 浏览 9 评论
2346 浏览 8 评论
2234 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3540 浏览 3 评论
1145浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1114浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
882浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
487浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-9 04:58 , Processed in 4.028937 second(s), Total 83, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
3512