2013-07-09 12:34 AM
In mySetSysClockTo72 function, there is
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CR & RCC_CR_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
as you know. But the Flag can not be set at debug. and application stuck at that loop.
How can I fix this, how could it be?
I use Keil IDE.
#rcc #keil #stm32-keil-external-clock-hse #stm32
2013-07-09 02:24 AM
> In my SetSysClockTo72 function,
Okay, my crystal ball is broken. Post that function. > But the Flag can not be set at debug. What do you mean by ''the Flag''? > and application stuck at that loop. It does not exit at the timeout? JW2013-07-09 04:01 AM
Does your board even have an external crystal? The STM32F4-Discovery does NOT.
Is the crystal, if present, actually oscillating?2013-07-09 04:35 AM
Thank you for quick replies;
- I attached my system_stm32f10x.c file- I don't use hardware, I use ''simulator'', (Only soft)
- My MCU: STM32F103xG - I do not use any OS etc - Defined HSE: 8MHz - Desired System Speed: 72 MHz Stuck in this loop:
/**
* @brief Waits for HSE start-up.
* @param None
* @retval An ErrorStatus enumuration value:
* - SUCCESS: HSE oscillator is stable and ready to use
* - ERROR: HSE oscillator not yet ready
*/
ErrorStatus RCC_WaitForHSEStartUp(void)
{
__IO uint32_t StartUpCounter = 0;
ErrorStatus status = ERROR;
FlagStatus HSEStatus = RESET;
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC_GetFlagStatus(RCC_FLAG_HSERDY);
StartUpCounter++;
} while((StartUpCounter != HSE_STARTUP_TIMEOUT) && (HSEStatus == RESET));
if (RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET)
{
status = SUCCESS;
}
else
{
status = ERROR;
}
return (status);
}
My all other settings are default. I use ST std lib v3.5 I call that function from here:
void RCC_Configuration(void)
{
RCC_DeInit();
RCC_HSEConfig(RCC_HSE_ON);
// Wait till HSE is ready
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus == SUCCESS)
{
________________
Attachments : system_stm32f10x.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I18w&d=%2Fa%2F0X0000000biy%2FspM_hoI2GXJJikxywwccDh5zjcRP1lDtBz1Xr2aOBvs&asPdf=false
2013-07-09 04:38 AM
> Does your board even have an external crystal? The STM32F4-Discovery does NOT.
???
2013-07-09 04:58 AM
No, does not have. I use STM32F103VG, and ONLY soft debug.
I compile without any error.When I run debug, it just runs in that loop. No any exit2013-07-09 05:06 AM
Then maybe you need to assume the simulator doesn't support the HSE?
Also 3.5.0 is a CMSIS based library, the clock setup should be occurring in SystemInit() in system_stm32f1xx.c, which is called prior to main(). I'm not sure you'd need to reconfigure it again.2013-07-09 05:07 AM
Your software simulator doesn't have an external crystal, so the flag will never be set.
Change the flag yourself in the register viewer.2013-07-09 05:18 AM
Problem still alive. I used to debug without any problem and any touch on register values before..
I found in datasheet: HSERDYF register name In my register viewer: I browse RCC section and I can see: ''[Bit 3 RO [@ 0x40021008] HSE Ready Interrupt flag'' But bits are read only. I can not change. By the way I use that debugger command:MAP 0x40001000, 0x40023009 READ WRITE
it already covers that address.
2014-01-01 07:59 PM