There is an issue in the startup code for the Renesas RA6M4. The sub clock was configured as populated on the EK-RA6M4, but it would not work. When I stepped through the startup code, I found out why: in bsp_clocks.c: ...Read more
There is an issue in the startup code for the Renesas RA6M4. The sub clock was configured as populated on the EK-RA6M4, but it would not work. When I stepped through the startup code, I found out why: in bsp_clocks.c: #if BSP_CLOCK_CFG_SUBCLOCK_POPULATED /* If the board has a subclock, set the subclock drive and start the subclock if the subclock is stopped. If the * subclock is running, the subclock drive is assumed to be set appropriately. */ if (R_SYSTEM->SOSCCR) <- This line prevents configuring the SOMCR because SOSCCR is 0 at reset /* Configure the subclock drive if the subclock is not already running. */ R_SYSTEM->SOMCR = ((BSP_CLOCK_CFG_SUBCLOCK_DRIVE << BSP_FEATURE_CGC_SODRV_SHIFT) & BSP_FEATURE_CGC_SODRV_MASK); R_SYSTEM->SOSCCR = 0U; #if (BSP_CLOCKS_SOURCE_CLOCK_SUBCLOCK == BSP_CFG_CLOCK_SOURCE) || (BSP_PRV_HOCO_USE_FLL) /* If the subclock is the system clock source OR if FLL is used, wait for stabilization. */ R_BSP_SoftwareDelay(BSP_CLOCK_CFG_SUBCLOCK_STABILIZATION_MS, BSP_DELAY_UNITS_MILLISECONDS). Once I commented the if statement, the sub clock was configured properly and started oscillating. Perhaps it was intended that at some point the sub clock should be disabled (set to 1) prior to configuring it, but I don’t see where anything disables it unless the option is left as “not populated”.
Read less
You could disable the sub-oscillator in the user code :- /* Call pre clock initialization hook. */ R_BSP_WarmStart(BSP_WARM_START_RESET); is called before /* Configure system clocks. */ bsp_clock_init(); in the SystemInit() function, in the file system.c. The function R_BSP_WarmStart() is created inRead more
You could disable the sub-oscillator in the user code :-
/* Call pre clock initialization hook. */
R_BSP_WarmStart(BSP_WARM_START_RESET);
is called before
/* Configure system clocks. */
bsp_clock_init();
in the SystemInit() function, in the file system.c.
The function R_BSP_WarmStart() is created in the file src\hal_entry.c, so you could add the code to stop the sub oscillator there :-
void R_BSP_WarmStart(bsp_warm_start_event_t event)
{
if (BSP_WARM_START_RESET == event)
{
uint16_t prcr = R_SYSTEM->PRCR;
R_SYSTEM->PRCR = 0xA501;
R_SYSTEM->SOSCCR = 1; //disable the SOSC
R_SYSTEM->PRCR = (uint16_t)(0xA500 | (prcr & 0x00FF));
}
}
You might not want to stop the sub-oscillator if the device has been running on the VBATT power supply with the RTC running, and VCC is re-applied, as stopping the sub oscillator would also stop the RTC, so you might only want to stop the sub oscillator on a cold boot of the device.
The SOMCR register should only be modified if the sub oscillator is not running (i.e. the SOSTP bit in the SOSCR register is 1), so just commenting out the check:-
if (R_SYSTEM->SOSCCR)
is not reccomended, the sub oscillator should first be stopped, before modifying the SOMCR register.
See less