Page 1 of 1

STM32G431CBU6 : TIMER17 : setting negative channel mashes positive one

Posted: Thu Apr 04, 2024 2:41 pm
by trimarco232
Hi , here is the code :

Code: Select all

  timer17.setMode(1, TIMER_OUTPUT_COMPARE_PWM1, PA7_ALT3);  // AF1 = TIM17_CH1
  timer17.setMode(1, TIMER_OUTPUT_COMPARE_PWM1, PB7_ALT2);  // AF1 = TIM17_CH1N /// mashes PA7 = CH1
  TIM17->CCR1 = 5; 
  timer17.setPrescaleFactor(170 - 1);  // G431 is 170MHz
  timer17.setPreloadEnable(true);
  timer17.setOverflow(200);  //

  TIM17->CCER = 0b1101; /// must be done , to re-establish bit 0 = CC1E

  timer17.resume();

  /// debug
  Serial.println("");
  Serial.print("T17 CCER ");
  Serial.println(TIM17->CCER, BIN);
  Serial.print("GPIOA MODER ");
  Serial.println(GPIOA->MODER, BIN);
  Serial.print("GPIOB MODER ");
  Serial.println(GPIOB->MODER, BIN);
  Serial.print("GPIOA AFRL ");
  Serial.println(GPIOA->AFR[0], BIN);
I had to set again manually CC1E bit ;
no sure is this a normal behaviour , because the alternate function for PA7 is still ok ?

Re: STM32G431CBU6 : TIMER17 : setting negative channel mashes positive one

Posted: Thu Apr 04, 2024 4:03 pm
by fpiSTM
This is a known issue and fixed in the repo. You can find a workaround in the related issue.
https://github.com/stm32duino/Arduino_C ... /pull/2294