C编程(PIC32的中断) [英] C programming (interrupt for PIC32)

查看:95
本文介绍了C编程(PIC32的中断)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,我不了解pic32mx360f512l的中断.任何人都可以向我解释有关此代码的此功能..谢谢..

void __ISR(_CORE_TIMER_VECTOR,ipl2)CoreTimerHandler(void)
{
//清除中断标志
mCTClearIntFlag();

//..要做的事情

//更新时间段
UpdateCoreTimer(CORE_TICK_RATE);


//..切换LED
mPORTDToggleBits(BIT_1);
}

I have a problem and i dont understand about interrupt for pic32mx360f512l. can anyone explain to me about this function regarding this code..thanks..

void __ISR(_CORE_TIMER_VECTOR, ipl2) CoreTimerHandler(void)
{
// clear the interrupt flag
mCTClearIntFlag();

// .. things to do

// update the period
UpdateCoreTimer(CORE_TICK_RATE);


// .. Toggle the LED
mPORTDToggleBits(BIT_1);
}

What is this use for in the interrupt?

推荐答案

虽然我本人并不熟悉PIC32,也不完全确定UpdateCoreTimer()的作用,但是代码有什么用?您发布的内容对我来说似乎很清楚.

不幸的是,我不明白您的问题是什么. :confused:无论如何,我会发表一些意见.也许我会不经意地回答你的问题. :)

该代码是一个中断服务程序.它由硬件计时器激活,该计时器通过硬件将控制权从执行的任何代码转移到ISR.当ISR返回时,控制权返回到中断的代码.在ISR中使用的代码中有一些严重的问题需要关注.并发就是其中之一.

它的用途是在硬件计时器关闭时执行需要做的事情.

mCTClearIntFlag()显然正在管理中断控制/屏蔽硬件的正确状态.我必须阅读PIC32文档以对此进行更详细的介绍.

我没说要在要做的事情"中添加任何内容.

我正在猜测,但是UpdateCoreTimer()可能会保留当前的日期和时间.再说一遍,无论是注释还是函数名称都听起来并不正确.我真的必须先查看更多详细信息,然后才能确信它的实际作用.

切换LED可以为看硬件的人提供可视的运行状况"指示器.如果指示灯停止闪烁,则说明硬件或软件出现严重问题,并且设备不再工作.

是的.
While I''m not familiar with the PIC32 myself and am not entirely sure what UpdateCoreTimer() does, the code you posted seems pretty clear to me.

Unfortunately, I don''t understand what your question is. :confused: I''ll make a few comments anyway. Maybe I''ll accidentally answer your question. :)

The code is an Interrupt Service Routine. It is activated by a hardware timer which via hardware transfers control from whatever code was executing to the ISR. When the ISR returns, control is returned to the interrupted code. There are serious issues to be concerned about in code used in an ISR. Concurrency is one of them.

Its use is to do things that need doing at the times that the hardware timer goes off.

The mCTClearIntFlag() is evidently managing the proper state of the interrupt control/masking hardware. I''d have to read the PIC32 documentation to be more detailed about that.

I don''t thing there is really anything to add to the comment "things to do".

I''m guessing, but the UpdateCoreTimer() could be maintaining the current day and time. Then again, neither the comment or the function name really sound quite right for that. I''d really have to see more details before being confident of what it was really doing.

Toggling the LED provides a visual "operating health" indicator to someone looking at the hardware. If the led stops blinking, then something has gone seriously wrong with the hardware or software and the device is no longer working.

Does this explain anything to you?


是的.非常感谢您的答案.您已经清楚了我的大部分疑问.非常感谢您的答案. :) :):)
yeah..thanks so much for the answer.you have clear most of my doubts..thanks so much for your answer. :) :) :)


这篇关于C编程(PIC32的中断)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆