飞思卡尔 mc9s12xs128 周期0.5s中断,计数脉冲个数 。问题1 调试不出速度 。求帮助 10
#include<hidef.h>/*commondefinesandmacros*/#include"derivative.h"/*derivative-specifi...
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include "w_speed.h"
#define chishu 40
#define radius 262 //mm
#define dt 500 //ms
int iPulesNum=0;
int temp=0;
int w_speed0=0;
void main(void) {
/* put your own code here */
PWM4ms_Init();
CAP0_Init();
PIT0_Init();
EnableInterrupts;
for(;;) {
w_speed0=(temp*3*radius)/(dt*chishu);
_FEED_COP(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave main */
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 66 PIT0_ISR(void)
{
temp= iPulesNum;
// w_speed0=(temp*3*radius)/(dt*chishu);
iPulesNum=0;
PITTF_PTF0=1; //clear PIT ch 0 time-out flag
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 8 capture0_ISR(void)
{
TFLG1_C0F = 1;
iPulesNum++;
} 展开
#include "derivative.h" /* derivative-specific definitions */
#include "w_speed.h"
#define chishu 40
#define radius 262 //mm
#define dt 500 //ms
int iPulesNum=0;
int temp=0;
int w_speed0=0;
void main(void) {
/* put your own code here */
PWM4ms_Init();
CAP0_Init();
PIT0_Init();
EnableInterrupts;
for(;;) {
w_speed0=(temp*3*radius)/(dt*chishu);
_FEED_COP(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave main */
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 66 PIT0_ISR(void)
{
temp= iPulesNum;
// w_speed0=(temp*3*radius)/(dt*chishu);
iPulesNum=0;
PITTF_PTF0=1; //clear PIT ch 0 time-out flag
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 8 capture0_ISR(void)
{
TFLG1_C0F = 1;
iPulesNum++;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询