Skip to content

Commit

Permalink
boards: arkv6x fix wrong pwm output values
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKlimaj authored and dagar committed Oct 31, 2023
1 parent b8c541d commit 40c9789
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
1 change: 0 additions & 1 deletion boards/ark/fmu-v6x/src/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@
/* PWM
*/
#define DIRECT_PWM_OUTPUT_CHANNELS 8
#define BOARD_PWM_FREQ 1024000

#define GPIO_FMU_CH1 /* PI0 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTI|GPIO_PIN0)
#define GPIO_FMU_CH2 /* PH12 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTH|GPIO_PIN12)
Expand Down
8 changes: 3 additions & 5 deletions boards/ark/fmu-v6x/src/spix_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@
#define rDMAR(_tmr) REG(_tmr, STM32_GTIM_DMAR_OFFSET)
#define rBDTR(_tmr) REG(_tmr, STM32_ATIM_BDTR_OFFSET)

#if !defined(BOARD_PWM_FREQ)
#define BOARD_PWM_FREQ 1000000
#endif
#define BOARD_SPIX_SYNC_PWM_FREQ 1024000

unsigned
spix_sync_timer_get_period(unsigned timer)
Expand Down Expand Up @@ -129,11 +127,11 @@ static void spix_sync_timer_init_timer(unsigned timer, unsigned rate)
* Otherwise, other frequencies are attainable by adjusting .clock_freq accordingly.
*/

rPSC(timer) = (spix_sync_timers[timer].clock_freq / BOARD_PWM_FREQ) - 1;
rPSC(timer) = (spix_sync_timers[timer].clock_freq / BOARD_SPIX_SYNC_PWM_FREQ) - 1;

/* configure the timer to update at the desired rate */

rARR(timer) = (BOARD_PWM_FREQ / rate) - 1;
rARR(timer) = (BOARD_SPIX_SYNC_PWM_FREQ / rate) - 1;

/* generate an update event; reloads the counter and all registers */
rEGR(timer) = GTIM_EGR_UG;
Expand Down

0 comments on commit 40c9789

Please sign in to comment.