Page 1 of 1

BigQuad CPPM remapping to different pin

Posted: Fri Oct 02, 2020 10:14 am
by matejkarasek
Hi,

I am trying to remap the CPPM on the BigQuad deck to a different pin, such that I can also use LPS & SDcard.
IO_1 (PB8) looks like a good option as it has Timer 10 available and does not interfere with anything I plan to use.

I modified cppm.c as follows, but still cannot get it runnig:

Code: Select all

#define CPPM_TIMER                   TIM10
#define CPPM_TIMER_RCC               RCC_APB2Periph_TIM10
#define CPPM_TIMER_CH_Init           TIM_OC1Init
#define CPPM_TIMER_CH_PreloadConfig  TIM_OC1PreloadConfig
#define CPPM_TIMER_CH_SetCompare     TIM_SetCompare1
#define CPPM_GPIO_RCC                RCC_AHB1Periph_GPIOB
#define CPPM_GPIO_PORT               GPIOB
#define CPPM_GPIO_PIN                GPIO_Pin_8
#define CPPM_GPIO_SOURCE             GPIO_PinSource8
#define CPPM_GPIO_AF                 GPIO_AF_TIM10

#define CPPM_TIM_PRESCALER           (168 - 1) // TIM10 clock running at sysclk (168 MHz). Prescaler of 168 will give 1MHz --> 1us tick.
Using debug messages I see extRxDecodeCppm() is running but no messages are being decoded. Thus I suspect there still is something incorrect with my pin/timer configuration.
All works fine on the original pin.

Any advice on this would be appreaciated!

Re: BigQuad CPPM remapping to different pin

Posted: Mon Oct 05, 2020 11:21 am
by tobias
My guess is that the interrupt (TIM8_TRG_COM_TIM14_IRQHandler) is not updated to the new timer at the bottom of cppm.c

Re: BigQuad CPPM remapping to different pin

Posted: Mon Oct 05, 2020 5:14 pm
by matejkarasek
Ah yes, thanks for the pointer in the right direction!

The handler function should be ok as CPPM_TIMER is now defined as TIM10 (?)
And there is also

Code: Select all

NVIC_InitStructure.NVIC_IRQChannel = TIM8_TRG_COM_TIM14_IRQn;
I must say this goes beyond my (very limited) embedded programming skills, will have to read a bit about timers and interrupt requests first :) Thanks!

Re: BigQuad CPPM remapping to different pin

Posted: Tue Oct 06, 2020 8:04 am
by tobias
I have not tested but I think you need to change to this

Code: Select all

NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_TIM10_IRQn;

Code: Select all

void __attribute__((used)) TIM1_UP_TIM10_IRQHandler()

Re: BigQuad CPPM remapping to different pin

Posted: Thu Oct 08, 2020 1:46 pm
by matejkarasek
Thanks Tobias, this indeed is what I was missing.

I just tried with these changes, all builds and flashes, but unfortunately still not working, so there must be yet something else...
WIll keep looking...

Re: BigQuad CPPM remapping to different pin

Posted: Fri Oct 09, 2020 7:44 am
by tobias
hmm, strange, should be working now. Could the pin PB8 be re-configured by something else maybe...

Re: BigQuad CPPM remapping to different pin

Posted: Fri Oct 09, 2020 8:20 am
by matejkarasek
Yeah, I suspect something like that...

I did observe some inconsistencies when trying with different boards (CF2.1, Roadrunner, Bolt), will dig into that and post if I find anything!