[ersky9x] PPM-in problem
This commit is contained in:
+17
-18
@@ -372,36 +372,35 @@ void start_timer4()
|
|||||||
// (The timer is free-running and is thus not reset to zero at each capture interval.)
|
// (The timer is free-running and is thus not reset to zero at each capture interval.)
|
||||||
// Timer 4 generates the 2MHz clock to clock Timer 3
|
// Timer 4 generates the 2MHz clock to clock Timer 3
|
||||||
|
|
||||||
uint16_t Temp_captures[8] ;
|
|
||||||
|
|
||||||
extern "C" void TC3_IRQHandler() //capture ppm in at 2MHz
|
extern "C" void TC3_IRQHandler() //capture ppm in at 2MHz
|
||||||
{
|
{
|
||||||
uint16_t capture ;
|
uint16_t capture ;
|
||||||
static uint16_t lastCapt ;
|
static uint16_t lastCapt ;
|
||||||
uint16_t val ;
|
|
||||||
|
|
||||||
capture = TC1->TC_CHANNEL[0].TC_RA ;
|
capture = TC1->TC_CHANNEL[0].TC_RA ;
|
||||||
(void) TC1->TC_CHANNEL[0].TC_SR ; // Acknowledgethe interrupt
|
(void) TC1->TC_CHANNEL[0].TC_SR ; // Acknowledgethe interrupt
|
||||||
|
|
||||||
val = (capture - lastCapt) / 2 ;
|
uint16_t val = (capture - lastCapt) / 2;
|
||||||
lastCapt = capture;
|
|
||||||
|
|
||||||
// We prcoess g_ppmInsright here to make servo movement as smooth as possible
|
// G: We process g_ppmIns immediately here, to make servo movement as smooth as possible
|
||||||
// while under trainee control
|
// while under trainee control
|
||||||
if (ppmInState && ppmInState<=8) {
|
if (val>4000 && val < 16000) // G: Prioritize reset pulse. (Needed when less than 8 incoming pulses)
|
||||||
if(val>800 && val<2200) {
|
ppmInState = 1; // triggered
|
||||||
Temp_captures[ppmInState - 1] = capture ;
|
else
|
||||||
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - PPM_CENTER)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
{
|
||||||
}
|
if (ppmInState && ppmInState<=8)
|
||||||
else {
|
{
|
||||||
ppmInState = 0; // not triggered
|
if (val>800 && val<2200) // if valid pulse-width range
|
||||||
}
|
{
|
||||||
}
|
g_ppmIns[ppmInState++ - 1] =
|
||||||
else {
|
(int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||||
if (val>4000 && val < 16000) {
|
}
|
||||||
ppmInState = 1; // triggered
|
else
|
||||||
|
ppmInState = 0; // not triggered
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastCapt = capture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void start_ppm_capture()
|
void start_ppm_capture()
|
||||||
|
|||||||
Reference in New Issue
Block a user