Skip to content

Commit

Permalink
Fix RX PLL multiplier after refactor (code consolidation).
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed May 31, 2024
1 parent 649c37b commit 1aee86b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 4 additions & 2 deletions hal/renesas-rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void uart_write(const char* buf, unsigned int sz)
#define CFG_CKSEL 1 /* 0=LOCO, 1=HOCO, 2=Main, 3=Sub, 4=PLL */
#define CFG_HCO_FRQ (16000000)
#define CFD_PLL_DIV (0)
#define CFG_PLL_MUL (SYS_CLK / CFG_HCO_FRQ)
#define CFG_PLL_MUL (SYS_CLK / (CFG_HCO_FRQ / 2))

void hal_clk_init(void)
{
Expand Down Expand Up @@ -261,12 +261,14 @@ void hal_clk_init(void)
#else
#define PLL_SRCSEL SYS_PLLCR_PLLSRCSEL /* HOCO */
#endif
#define PLL_MUL_STC ((uint8_t)(CFG_PLL_MUL - 1))
/* convert multiplier to STC value */
#define PLL_MUL_STC ((CFG_PLL_MUL * 2) - 1)
reg = (
SYS_PLLCR_PLIDIV(CFD_PLL_DIV) | /* no div */
PLL_SRCSEL | /* clock source (0=main, 1=HOCO) */
SYS_PLLCR_STC(PLL_MUL_STC) /* multiplier */
);

SYS_PLLCR = reg;
SYS_PLLCR2 = 0; /* enable PLL */
while ((SYS_OSCOVFSR & SYS_OSCOVFSR_PLOVF) == 0) { RX_NOP(); }
Expand Down
2 changes: 1 addition & 1 deletion hal/renesas-rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void hal_delay_us(uint32_t us);
#define SYS_PLLCR (*(volatile uint16_t *)(SYSTEM_BASE + 0x28))
#define SYS_PLLCR_PLIDIV(n) ((n) << 0) /* 0=x1, 1=x1/2, 2=x1/3 */
#define SYS_PLLCR_PLLSRCSEL (1 << 4) /* 0=main, 1=HOCO */
#define SYS_PLLCR_STC(n) ((n) << 8) /* Frequency Multiplication Factor */
#define SYS_PLLCR_STC(n) (((n) & 0x7F) << 8) /* Frequency Multiplication Factor */

#define SYS_PLLCR2 (*(volatile uint8_t *)(SYSTEM_BASE + 0x2A))
#define SYS_PLLCR2_PLLEN (1 << 0) /* PLL Stop Control: 0=PLL operating, 1=PLL stopped */
Expand Down
4 changes: 0 additions & 4 deletions hal/spi/spi_drv_renesas_rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,4 @@
/* use RSPI HW chip select */
#define FLASH_SPI_USE_HW_CS

/* not used */
#define SPI_CS_FLASH 0
#define SPI_CS_PIO_BASE 0UL

#endif /* !SPI_DRV_RENESAS_RX_H_INCLUDED */

0 comments on commit 1aee86b

Please sign in to comment.