CHAPTER 4 PROGRAM LIST
Application Note U17209EJ1V0AN
179
unsigned char *po;
/* */
if ( reg == SW ) {
return P4;
} else {
return 0;
}
}
4.5.7 Motor control interrupt processing function
#include "Common.h"
#include "Motor.h"
#pragma ioreg /* Peripheral I/O register definition */
/****************************************************************************** /
/* Motor control timer interrupt processing */
/****************************************************************************** /
_ _interrupt
void int_MOTOR(void)
{
// A/D is started automatically.
}
/****************************************************************************** /
/* Motor control processing */
/****************************************************************************** /
void Motor_CONT(void)
{
signed int wrm, wre, trm, tre ;
signed int o_wre, we, o_iqap, o_iqa ;
signed int s_time, ek, sa ;
unsigned char wk, wk2 ;
signed int cow ;
signed int o_vua, o_vva, o_vwa ;
signed int o_vda, o_vqa ;
/* */
/****************************************************************************** /
/* Calculation processing of speed and rotor position */
/****************************************************************************** /
fcalcu( &wrm, &trm ) ;
sum_speed += ( wrm * TH_U / RPM_RADS ) ; /* Radian -> rpm */
if ( --speed_co == 0 ) {
speed_co = 100000 / TS ; /* Set 100 mSEC counter value */
now_speed = sum_speed / speed_co ;
sum_speed = 0 ;
}
wrm = now_speed * RPM_RADS / TH_U ;
wre = wrm * P ;
tre = ( trm * P + OFFSET ) % RAD ;