[g9x] DSM2=SERIAL FIXED AGAIN -- this time better.
See comments for r1577 for details. Short version is that I found a deeper root cause for the problem and corrected that instead of the previous fix, which turned out to be a band-aid only.
This commit is contained in:
+2
-6
@@ -3010,7 +3010,7 @@ uint16_t getTmr16KHz()
|
||||
|
||||
#if defined (PCBGRUVIN9X)
|
||||
|
||||
/**** SCHDULED MIXER INTERRUPT ****/
|
||||
/**** SCHEDULED MIXER INTERRUPT ****/
|
||||
|
||||
// On G9X board, we use TIMER5 to schedule mixer execution, to achieve
|
||||
// minimal system latency between reading sticks and outputting data.
|
||||
@@ -3246,11 +3246,7 @@ FORCEINLINE void DSM2_USART0_vect()
|
||||
|
||||
pulses2MHzRPtr += sizeof(uint16_t);
|
||||
|
||||
#if defined (DSM2_SERIAL)
|
||||
heartbeat |= HEART_TIMER_PULSES; // G: WDT will time out before 22ms (no bit-banging int. to flag heartbeat)
|
||||
#endif
|
||||
|
||||
if (pulses2MHzRPtr == pulses2MHzWPtr) { // if at end of read buffer ...
|
||||
if (pulses2MHzRPtr == pulses2MHzWPtr) { // if reached end of DSM2 data buffer ...
|
||||
UCSR0B &= ~(1 << UDRIE0); // disable UDRE0 interrupt
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -104,11 +104,10 @@ ISR(TIMER1_COMPA_vect) //2MHz pulse generation (BLOCKING ISR)
|
||||
|
||||
#ifdef DSM2_SERIAL
|
||||
if (s_current_protocol == PROTO_DSM2) {
|
||||
OCR1A = 44000; // next frame in 22ms
|
||||
// sei will be called inside setupPulses()
|
||||
setupPulses(); // will call sei()
|
||||
cli(); // this blocking ISR will automatically issue sei at exit
|
||||
UCSR0B |= (1 << UDRIE0); // enable UDRE0 interrupt
|
||||
setupPulses(); // includes scheduling of next COMPA int. vector (this ISR).
|
||||
// also re-enables interrupts at and for a safe time. (G: Only if in DSM2_SERIAL mode. Why?)
|
||||
cli(); // re-disable interrupts to prevent reentrance here. (This ISR will automatically issue sei upon exit.)
|
||||
UCSR0B |= (1 << UDRIE0); // enable UDRE0 interrupt to start transmitting DSM2 data bytes from buffer
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -865,8 +864,9 @@ void setupPulses()
|
||||
default: // PPM and DSM2=SERIAL modes
|
||||
set_timer3_capture();
|
||||
TCCR1B = 0; // Stop counter
|
||||
OCR1A = 40000; // Next frame starts in 20 mS
|
||||
TCNT1 = 0;
|
||||
TCNT1 = 0; // Must reset counter frist, to prevent possible immediate COMPA int. (sometimes).
|
||||
OCR1A = 44000; // Next frame starts in 22ms -- DSM mode. PPM mode will adjust to the frame rate
|
||||
// set in model SETUP menu, when setupPulsesPPM() is called, below.
|
||||
#if defined(PCBGRUVIN9X)
|
||||
TIMSK1 &= ~0x2F; // All Timer1 interrupts off
|
||||
TIFR1 = 0x2F;
|
||||
|
||||
Reference in New Issue
Block a user