BigQuad CPPM remapping to different pin

Firmware/software/electronics/mechanics
Post Reply
matejkarasek
Beginner
Posts: 21
Joined: Tue Jul 09, 2019 11:50 am

BigQuad CPPM remapping to different pin

Post 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!
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: BigQuad CPPM remapping to different pin

Post 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
matejkarasek
Beginner
Posts: 21
Joined: Tue Jul 09, 2019 11:50 am

Re: BigQuad CPPM remapping to different pin

Post 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!
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: BigQuad CPPM remapping to different pin

Post 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()
matejkarasek
Beginner
Posts: 21
Joined: Tue Jul 09, 2019 11:50 am

Re: BigQuad CPPM remapping to different pin

Post 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...
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: BigQuad CPPM remapping to different pin

Post by tobias »

hmm, strange, should be working now. Could the pin PB8 be re-configured by something else maybe...
matejkarasek
Beginner
Posts: 21
Joined: Tue Jul 09, 2019 11:50 am

Re: BigQuad CPPM remapping to different pin

Post 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!
Post Reply