cancel
Showing results for 
Search instead for 
Did you mean: 

Timer Channel 1 Input / Output on different pins?

IanB
Visitor

I am using TIM4 as a quadrature encoder counter, works fine. It is using the Channel 1 and 2 inputs on PB6 and PB7.

Now I would like to add a compare output to create a pulse at a particular position. It seems I have to use channel 1 or channel 2 as there are only CCR1 and CCR2 compare registers. I would like to set a different pin port D12 for the output signal, I have also done this without problem.

When I set bit 0 to value 1 in CCER, my output becomes available on D12, great. But it also drives on PB6 therefore corrupting one of my encoder inputs.

Looking at the Alternate function mapping I can only set the AF for a pin to be "TIM4_CH1", I cannot specify input or output separately on different pins.

Am I missing something here or is it simply not possible to combine encoder mode with a hardware output? I have a compare interrupt and could create an output that way but it is obviously not as good as an output directly from the timer.

 

 

 

 

 

 

 

1 REPLY 1
IanB
Visitor

I found a solution:

I assumed that Ch3 and Ch4 did not have compare value registers as they did not show up on my IAR workbench, but of course they are there. So I set up channel 3 for the compare output, it works without affecting the Ch1 and Ch2 inputs.

So my conclusion is that that a channel can only be used for one purpose, and if you want 2 inputs and 1 output for a timer, you have to use 3 different channels, sort of makes sense