I’m trying to set up PWM on Timer1 Channel 1(N) on the STM8S105K6 together with a repetition counter. Here is my simple intitialisation function for TIM1 which I used to test PWM:

void timer1_init () {

    TIM1_CR1 &= ~CEN;  // disable timer

    TIM1_CR1   |= ARPE; // auto reload preload enable

    TIM1_ARRH   = 0x00; // just some testing values
    TIM1_ARRL   = 0xff;

    TIM1_CCR1H  = 0x00;
    TIM1_CCR1L  = 0x80;

    TIM1_CCMR1 |= OCM1_PWM2;     // PWM mode 2 */
    TIM1_CCER1 |= CC1NE | OC1NP; // output enable, inv  polarity */

    TIM1_BKR = AOE;  // automatic output enable (MOE) works too

    TIM1_IER |= UIE; // enable update interrupt
    TIM1_CR1 = CEN;  // enable timer

And this is my ISR for TIM1:

void timer_isr(void) __interrupt(IRQ_TIM1) {
    TIM1_CR1 &= ~CEN;
    TIM1_SR1 &= ~UIF;

This PWM Output works so far (checked with an oscilloscope) and when the ISR is called the timer is stopped on the first PWM Edge. My understanding is that when I now write a value

into the RCR register it should only trigger the update interrupt on every
N + 1
PWM Edge. However when I add

TIM1_RCR = 15;

to my

function it does not change anything. My question is whether I am missing something in my initialisation. I have not found any information about additional things to add and all the online resources I looked up also just set the RCR register like above.

Asked question