betaflight / bidircfg

9 stars 15 forks source link

Matek F411: BF 4.1 DShot BitBang not working when assigning Pin A08 (LED) to cam control #40

Closed RipperDrone closed 5 years ago

RipperDrone commented 5 years ago

BetaFPV Whoop AIO 2-4S with Matek F411 FC, BF 4.1: BF 4.1 DShot BitBang not working when assigning Pin A08 (LED) to cam control

Steps to reproduce the behavior:

Everything worked ok until I remapped the LED_STRIP pin. Seems timers are used differently now, because it did work in non bit bang mode before.

RipperDrone commented 5 years ago

Might possibly related to Issue betaflight/betaflight#8840 (just guessing)

etracer65 commented 5 years ago

We really shouldn't have to ask every time. Include your diff as requested when you opened the issue.

jflyper commented 5 years ago

@RipperDrone Yes, please always remember to provide sufficient information to reproduce your board on our side.

However, in this case, the answer is simple: "You can't do that." This is because F411 requires TIM1 for BB DShot and PA8 is TIM1.

If the board was working without an issue, I'd say you go back to dshot_bitbang = OFF.

RipperDrone commented 5 years ago

@jflyper thank you! @etracer65 - I added the 2 single lines from the diff which make the change, therefore was suspecting the answer was straight about timer use. Have added the full diff still as per your request.

RipperDrone commented 5 years ago

Twig Betaflight Diff.txt

RipperDrone commented 5 years ago

@jflyper @joelucid This situation might be a 'trap' for some users upgrading, isn't it? 'Abusing' the LED pin for softserial or - like in my case - for cam control is probably a common way to work around the limited number of exposed UART pins on today's 'Matek F411'-based Whoop boards. People who have reassigned the LED pin will hit this issue when upgrading since the default dshot mode is Bitbang now, and it will want to use TIMER 1. Don't see an elegant way out right now... 🤔

mikeller commented 5 years ago

@RipperDrone: Definitely something we need to fix.

Marking this as a duplicate of betaflight/betaflight#8840 so that we can keep the discussion in one place.

joelucid commented 5 years ago

@mikeller can we keep this issue open to discuss the case of boards where dshot_bitbang is problematic, the timer dshot implementation is unproblematic and does not require pin/dma remapping? I think in these targets we might want to default dshot_burst=off and dshot_bitbang=off. What do you think?

joelucid commented 5 years ago

Here are F411 targets which use timer 1:

MATEKF411RX:

const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
    DEF_TIM(TIM9, CH2, PA3,  TIM_USE_PPM,   0, 0), // PPM/RX2

    DEF_TIM(TIM2, CH3, PB10, TIM_USE_MOTOR, 0, 0), // S1_OUT - DMA1_ST1
    DEF_TIM(TIM4, CH1, PB6,  TIM_USE_MOTOR, 0, 0), // S2_OUT - DMA1_ST0
    DEF_TIM(TIM4, CH2, PB7,  TIM_USE_MOTOR, 0, 0), // S3_OUT - DMA1_ST3
    DEF_TIM(TIM4, CH3, PB8,  TIM_USE_MOTOR, 0, 0), // S4_OUT - DMA1_ST7

    DEF_TIM(TIM5, CH1, PA0,  TIM_USE_LED,   0, 0), // 2812LED - DMA1_ST2

    DEF_TIM(TIM9, CH1, PA2,  TIM_USE_PWM,   0, 0 ), // TX2
    DEF_TIM(TIM1, CH2, PA9,  TIM_USE_PWM,   0, 0 ), // TX1
    DEF_TIM(TIM1, CH3, PA10, TIM_USE_PWM,   0, 0 ), // RX1
};

MATEKF411:

const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
    DEF_TIM(TIM9, CH2, PA3,   TIM_USE_PPM,   0, 0), // PPM IN

    DEF_TIM(TIM3, CH1, PB4,  TIM_USE_MOTOR,  0, 0), // S1_OUT
    DEF_TIM(TIM3, CH2, PB5,  TIM_USE_MOTOR,  0, 0), // S2_OUT
    DEF_TIM(TIM4, CH1, PB6,  TIM_USE_MOTOR,  0, 0), // S3_OUT
    DEF_TIM(TIM4, CH2, PB7,  TIM_USE_MOTOR,  0, 0), // S4_OUT

    DEF_TIM(TIM2, CH2, PB3,  TIM_USE_MOTOR, 0, 0), // S5
    DEF_TIM(TIM2, CH3, PB10, TIM_USE_MOTOR, 0, 0), // S6
    DEF_TIM(TIM5, CH1, PA0,  TIM_USE_ANY,   0, 0), // RSSI pad
    DEF_TIM(TIM5, CH3, PA2,  TIM_USE_ANY,   0, 0), // TX2

    DEF_TIM(TIM1, CH1, PA8,  TIM_USE_LED,   0, 0), // LED
};

MAMBAF411:

const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {

    DEF_TIM(TIM11,  CH1,  PB9,  TIM_USE_PPM,   0, 0 ), // PPM IN
    DEF_TIM(TIM2,   CH2,  PB3,  TIM_USE_MOTOR, 0, 0 ), // S1_OUT - UP1-1
    DEF_TIM(TIM3,   CH1,  PB4,  TIM_USE_MOTOR, 0, 0 ), // S2_OUT - UP1-2
    DEF_TIM(TIM4,   CH1,  PB6,  TIM_USE_MOTOR, 0, 0 ), // S3_OUT - UP1-2
    DEF_TIM(TIM4,   CH2,  PB7,  TIM_USE_MOTOR, 0, 0 ), // S4_OUT - UP1-2
    DEF_TIM(TIM2,   CH1,  PA15, TIM_USE_ANY,   0, 0 ), // S5_OUT - UP1-1
    DEF_TIM(TIM10,  CH1,  PB8,  TIM_USE_ANY,   0, 0 ), // S6_OUT - DMA NONE

    DEF_TIM(TIM1,   CH1,  PA8,  TIM_USE_LED,   0, 0 ), // LED_STRIP - DMA2_ST3_CH6

};
joelucid commented 5 years ago

At first look these seem fine for timer based dshot.

jflyper commented 5 years ago

MATEKF411RX has much less chance for TIM1 being used, as it is configured only as a backdoor timer on RX1 and TX1.

joelucid commented 5 years ago

True given that this board has an integrated rx and no need for inverted telemetry.

etracer65 commented 5 years ago

True given that this board has an integrated rx and no need for inverted telemetry.

Probably not a good assumption. I know of several people that used this board (or clones) and switched to using an external receiver because of instability with the onboard SPI receiver.

0crap commented 5 years ago

True given that this board has an integrated rx and no need for inverted telemetry.

Probably not a good assumption. I know of several people that used this board (or clones) and switched to using an external receiver because of instability with the onboard SPI receiver.

Correct, I'm using a MATEKF11RX in the TinyhawkS, the internal SPI RX is utter cr@p! Using a FrSky XM (not +) receiver on UART1. Problem solved.

stale[bot] commented 5 years ago

This issue / pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within a week.

joelucid commented 5 years ago

Don’t want this to be auto-closed. It’s a very common issue that’s been reported more than 15x over the last month or so. A fix has been available for some time (https://github.com/betaflight/betaflight/pull/8978) but so far apparently isn’t targeted for 4.1.

joelucid commented 5 years ago

@RipperDrone could you verify whether this is fixed now that #8978 has been merged?

RipperDrone commented 5 years ago

@joelucid confirmed, it's fixed. Verified on RacerX Twig, Matek F411, image

--> running on JESC, smooth as silk :-)

joelucid commented 5 years ago

Perfect, thanks for testing!