完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我刚刚开始使用PIC32 MX340F12和MPLABX。我的第一次尝试是编写一个定时器中断,所以我使用了数据表、编译器手册和例子,并提出了下面的内容。但它不起作用…中断从不触发,事实上,如果我同时离开定时器中断使能(T1IE=1)和一般中断使能激活(“EI”),它运行几秒钟,然后挂起(在调试模式下说“目标停止”)。如果我删除其中任何一个,它只是无限期地运行,但仍然没有计时器中断。因此,我的ISR语法中的某个地方出现了一个非常糟糕的问题。它跳到任何人身上吗?就像我说的,我刚刚开始,所以我确信这是一个愚蠢的疏忽。正如你可能注意到的,我喜欢用寄存器和编译器指令尽可能直接地工作(而不是制造商提供的函数),我觉得我学到的东西最多。谢谢!
以上来自于百度翻译 以下为原文 I'm just getting started with a PIC32MX340F12, and MPLABX. My first attempt was to write a timer interrupt, so I worked with the datasheet, compiler manual, and examples and came up with the below. But it doesn't work... the interrupt never fires, and in fact if I leave both the timer interrupt enable (T1IE=1) and the general interrupt enable active ("ei"), it runs for a few seconds then hangs (says "target halted" in debug mode). If I remove either of those, it just runs indefinitely but still no timer interrupt. So I appear to have a pretty bad problem somewhere in my ISR syntax. Does it jump out at anyone? Like I said I'm just getting started so I'm sure it's a pretty dumb oversight. And as you may notice I like to work as directly as possible with registers and compiler directives (rather than manufacturer supplied functions), I feel like I learn the most that way. Thanks! #include #include #include "p32mx340f512h.h" #include int x = 0; int main(int argc, char** argv) { INTCONbits.MVEC = 1; // turn on multi-vector interrupts T1CON = 0; // set timer control to 0 T1CONbits.TCKPS = 1; // set T1 prescaler to 8 PR1 = 62499; // set t1 period TMR1 = 0; // initialize the timer T1CONbits.ON = 1; // activate the timer IPC1bits.T1IP = 5; // T1 priority to 5 IPC1bits.T1IS = 0; // T1 secondary priority to IFS0bits.T1IF = 0; // clear the T1 flag IEC0bits.T1IE = 1; // enable the T1 interrupts asm volatile("ei"); // enable interrupts while (1) { x++; if (x > 10000) { x = 0; } } return (EXIT_SUCCESS); } bool zzz = false; void __attribute__((interrupt(IPL5AUTO))) T1Handler(void) { IFS0bits.T1IF = 0; zzz = true; } |
|
相关推荐
11个回答
|
|
如果您正在使用PIC32,则使用MPLAB和谐。并在框架上留下位级操作。在通过协调器自动生成代码片段之后,只需编写应用程序代码和测试即可。还有在和谐目录中可用的示例应用程序。
以上来自于百度翻译 以下为原文 If you are working with PIC32, then use MPLAB Harmony. ANd leave bit level operations on framework. After auto generating require code snippets through harmony configurator, Just write your application code and test. And also there are sample apps available in harmony directory. |
|
|
|
我很不喜欢使用和声,也许是外围图书馆。至少我知道我在说芯片要做什么。我更喜欢寄存器设置,但是如果你提供了一个外围的库命令,它可能会做我想做的事情,我会给它一个答案。(我不敢相信答案不会跳到人身上)
以上来自于百度翻译 以下为原文 I'd very much prefer not to use harmony. Perhaps peripheral library. At least then I know what I'm telling the chip to do. I'd prefer register settings, but if you provide a peripheral library command that might do what I'm missing I'll give it a shot. (I can't believe the answer isn't leaping out at people) |
|
|
|
你跑的速度有多快?在发布的源代码中没有任何配置设置的迹象。
以上来自于百度翻译 以下为原文 How fast are you running the PIC? There's no sign of your CONFIG settings in the posted source. |
|
|
|
您可以尝试使用MCC,代码配置器。这里是MCC为PIC32 MX250生成的代码。可能是您的ISR的命名问题,请尝试T1中断。
以上来自于百度翻译 以下为原文 You can try using MCC, the code configurator. Here is the code generated by MCC for PIC32MX250.. void INTERRUPT_Initialize (void) { // TI: Timer 2 // Priority: 1 // SubPriority: 0 IPC2bits.T2IP = 1; IPC2bits.T2IS = 0; // Enable the multi vector INTCONbits.MVEC = 1; // Enable Global Interrupts __builtin_mtc0(12,0,(__builtin_mfc0(12,0) | 0x0001)); } void __ISR(_TIMER_2_VECTOR, IPL1AUTO) _T2Interrupt ( ) { //***User Area Begin // ticker function call; // ticker is 1 -> Callback function gets called everytime this ISR executes TMR2_CallBack(); //***User Area End tmr2_obj.count++; tmr2_obj.timerElapsed = true; IFS0bits.T2IF = false; } might be the naming issue for your ISR, try _T1Interrupt |
|
|
|
我猜想看门狗定时器是启用的,这就是停止程序的原因。设置中断标志。然后,一旦设置了启动,就会得到中断。然后你就会知道这个部分是否有效。
以上来自于百度翻译 以下为原文 I am guessing the watchdog timer is enabled and that is what is stopping the program. Set the interrupt flag. You will then get an interrupt as soon as you get set the enable. Then you will know if that part works. |
|
|
|
“没有任何迹象表明你的配置设置在公布的来源。”嗯…我猜我什么也没有设定。我刚刚启动了一个项目,指定了CPU,并编写了一个主循环。原谅我的天真…我习惯了更简单的芯片。我错过了大量启动代码吗?我确实试着运行配置器插件,但它始终无法从一个消息开始说它不支持我的芯片(这似乎不太可能)。我要试一试…如果它是看门狗定时器,当我中断中断时它不会消失,对吧?提米:谢谢你的代码,我会和我的混合和匹配,看看我是否得到更好的结果。感谢所有的答案,我会在几个小时后报告。
以上来自于百度翻译 以下为原文 "There's no sign of your CONFIG settings in the posted source." Well... I havent set any I guess. :) I just started a project, specified the CPU, and wrote a main loop. Pardon my naivite... I'm used to much simpler chips. Am I missing a ton of startup code? I did try to run the configurator plugin but it keeps failing to start with a message saying it doesn't support my chip (which seems unlikely). @NKurzman... I'll give it a shot... although if it was watchdog timer it wouldn't go away when I disable interrupts, would it? @timijk thanks for the code, I'll mix and match with mine, see if I get better results. Thanks for all the answers I'll report back in a couple of hours. |
|
|
|
你是正确的,PIC32 MX340不支持在MCC PIC32 MX V1.25…在本文档中提到了http://WW1.Microchip .com /…OtSePicp3MxV1V25.25.PDF。
以上来自于百度翻译 以下为原文 you are right, PIC32MX340 is not supported in MCC PIC32MX v1.25 ... it's mentioned in this document, http://ww1.microchip.com/...otes_PIC32MX_v1_25.pdf |
|
|
|
有一个窗口用来改变配置比特,然后当你完成时,有一个按钮为它生成C代码。
以上来自于百度翻译 以下为原文 There is a window to veiw an change the config bits, then there is a button to generate the C code for it when you are done. |
|
|
|
你好!前几天,我遇到了中断问题,我设法解决了,在这里我的例子可能对你有所帮助。
以上来自于百度翻译 以下为原文 Hi!! The other day I had problems with the interruptions, I manage to solve it, here my example may help you in something. http://www.microchip.com/forums/m968911.aspx |
|
|
|
在那里,我会调用ActuababySistMuleVCuto Enter(),这个论坛软件不会让我做一个真正的帖子。
以上来自于百度翻译 以下为原文 Somewhere in there I'd call INTEnableSystemMultiVectoredInt(); This forum software won't let me do a real post. |
|
|
|
弗里森,很管用!我不知道为什么[代码]。
以上来自于百度翻译 以下为原文 friesen, that worked! I'm not sure why INTCONbits.MVEC = 1; // turn on multi-vector interrupts ... asm volatile("ei"); // enable interrupts weren't accomplishing the same thing. Here's the source for that function: unsigned int val; // set the CP0 cause IV bit high asm volatile("mfc0 %0,$13" : "=r"(val)); val |= 0x00800000; asm volatile("mtc0 %0,$13" : "+r"(val)); INTCONSET = _INTCON_MVEC_MASK; // set the CP0 status IE bit high to turn on interrupts INTEnableInterrupts(); [/code] and I'm not sure what the extra code is doing, I will look into it. But thanks!! |
|
|
|
只有小组成员才能发言,加入小组>>
5192 浏览 9 评论
2011 浏览 8 评论
1936 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3183 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2238 浏览 5 评论
746浏览 1评论
632浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
517浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
644浏览 0评论
544浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-1 07:19 , Processed in 1.521751 second(s), Total 96, Slave 80 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号