完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用的是PIC32 MZ2048 EFG064和XC32,不能把它送到ISR的矢量。在设置SPI4之后,我这样做:我在最后一行上有一个断点,在那个点上,查看MPLAB X中的“外设”视图,SPI4TXIE被设置,并且SPI4TXIF被清除。看起来不错。然后我允许它运行,但是我在ISR中的断点没有被击中:所以我暂停调试器,看到SPI4TXIF和SPI4TXEY都被设置了。为什么不向ISR引导呢?我已经启用了全局中断和多向量中断,并且值得注意的是,以太网和I2C中断在同一个项目中运行良好。我正在做一些愚蠢的事情。它没有击中异常处理程序,所以它不像是对未实现的位置进行矢量化。
以上来自于百度翻译 以下为原文 I'm using a PIC32MZ2048EFG064 and XC32 and cannot get it to vector to the ISR. After setting up SPI4, I do this: IFS5CLR = _IFS5_SPI4TXIF_POSITION | _IFS5_SPI4RXIF_POSITION | _IFS5_SPI4EIF_POSITION; IPC40bits.SPI4EIP = 6; IPC40bits.SPI4EIS = 3; IEC5bits.SPI4TXIE = 1; SPI4CONbits.ON = 1; I have a breakpoint on the last line and at that point, looking at the "Peripherals" view in MPLAB X, SPI4TXIE is set and SPI4TXIF is cleared. That seems good. Then I allow it to run, but the breakpoint I have in the ISR isn't getting hit: void __attribute__( (interrupt(IPL6AUTO), vector(_SPI4_TX_VECTOR))) SPI4InterruptHandler(void) { SPI4BUF = 0x96; SPI4BUF = 0x96; SPI4BUF = 0x96; SPI4BUF = 0x96; IFS5CLR = _IFS5_SPI4TXIF_POSITION; } So I pause the debugger and see that SPI4TXIF and SPI4TXIE are both set. Why isn't this vectoring to the ISR? I had already enabled both global interrupts and multi-vector interrupts, and for what it's worth, Ethernet and I2C interrupts are working fine in the same project. I'm doing something stupid. It's not hitting the exception handler so it's not like it's vectoring to an unimplemented location. |
|
相关推荐
6个回答
|
|
你的设置是什么?如果你不使用中断,代码会工作吗?
以上来自于百度翻译 以下为原文 What are your settings? Does the code work if you aren't using interrupt? |
|
|
|
你的设置是什么?如果你不使用中断,代码会工作吗?这是事前相关的事情:我确实试着把样本扔进SPIPUF4,我没有看到它的输出,但是可能有多个原因。现在我将注意力放在中断上,通过调试器看这个问题,它似乎认为它正在传输:在将两个样本加载到SPIPUF4之后,TxBuFelm=2,然后它变为零。但是我得到的是,在启用SPI4之后,标志就被设置好了,但是它并没有向ISR提供向量。有一件事我不是很自信的是中断优先级和ISR的语法,但我相信我在那里很好。
以上来自于百度翻译 以下为原文 What are your settings? Does the code work if you aren't using interrupt? Here's what happens that is relevant beforehand: INTCONbits.MVEC = 1; __builtin_enable_interrupts(); RPD3R = 8; //sdo4 RPD4R = 8; //ss4 SPI1BRG = 3; SPI4CONbits.MSSEN = 1; SPI4CONbits.ENHBUF = 1; SPI4CONbits.MCLKSEL = 1; SPI4CONbits.MODE16 = 0; SPI4CONbits.MODE32 = 0; SPI4CONbits.SMP = 0; SPI4CONbits.SSEN = 1; SPI4CONbits.MSTEN = 1; SPI4CONbits.DISSDI = 1; SPI4CONbits.DISSDO = 0; SPI4CONbits.STXISEL = 0b10; //interrupt when buffer half empty SPI4CON2bits.AUDEN = 1; SPI4CON2bits.AUDMOD = 0x01; IFS5CLR = _IFS5_SPI4TXIF_POSITION | _IFS5_SPI4RXIF_POSITION | _IFS5_SPI4EIF_POSITION; IPC40bits.SPI4EIP = 6; IPC40bits.SPI4EIS = 3; IEC5bits.SPI4TXIE = 1; SPI4CONbits.ON = 1; while(1); I did try throwing samples into SPIBUF4 and am not seeing it on the output, but there could be multiple reasons for that. I'm concentrating on the interrupt now, and looking at this through the debugger, it seems to think it's transmitting it: Immediately after loading two samples into SPIBUF4, TXBUFELM=2, then afterwards it goes to zero. But what gets me is the flag is getting set right after enabled SPI4, yet it doesn't vector to the ISR. One thing I'm not fully confident on is interrupt priority levels and the syntax for the ISR, but I believe I'm good there. |
|
|
|
嗯,我不能解释你的症状,因为我看不到你的其他代码,但这不做你明显想要的底线:我想知道你用过多少其他地方,你应该使用的位置,Mask问候,戴夫。
以上来自于百度翻译 以下为原文 Hmmm... I can't explain your symptoms since I can't see the rest of your code, but this doesn't do what you obviously intend Bottom line: I'm wondering how many other places you used _POSITION where you should have used _MASK Regards, Dave |
|
|
|
这设置了SPI4故障中断的优先级。SPI4-TX中断优先级在IPC41,戴夫也这么说。
以上来自于百度翻译 以下为原文 IPC40bits.SPI4EIP = 6; IPC40bits.SPI4EIS = 3; This sets the priority for the SPI4 Fault interrupt. The SPI4 TX interrupt priority is in IPC41. Also, what Dave said. |
|
|
|
底线:我想知道有多少其他地方你使用的位置,你应该使用的Mask问候,DaveOh好发现。我把它们改成了面具。但仍然没有向ISR引导:
以上来自于百度翻译 以下为原文 Bottom line: I'm wondering how many other places you used _POSITION where you should have used _MASK Regards, Dave Oh good find. I changed those to _MASK as they should be. But still not vectoring to ISR :( |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5184 浏览 9 评论
2005 浏览 8 评论
1932 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3179 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2230 浏览 5 评论
740浏览 1评论
626浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
512浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
638浏览 0评论
536浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-28 18:34 , Processed in 1.568060 second(s), Total 87, Slave 70 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号