cancel
Showing results for 
Search instead for 
Did you mean: 

HSE can not be ready at debug

auzgec
Associate II
Posted on July 09, 2013 at 09:34

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
9 REPLIES 9
Posted on July 09, 2013 at 11:24

> 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?

JW

Posted on July 09, 2013 at 13:01

Does your board even have an external crystal? The STM32F4-Discovery does NOT.

Is the crystal, if present, actually oscillating?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
auzgec
Associate II
Posted on July 09, 2013 at 13:35

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
Posted on July 09, 2013 at 13:38

> Does your board even have an external crystal? The STM32F4-Discovery does NOT.

???

http://www.st.com/st-web-ui/static/active/en/fragment/product_related/rpn_information/board_photo/stm32f4_discovery.jpg

auzgec
Associate II
Posted on July 09, 2013 at 13:58

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 exit

Posted on July 09, 2013 at 14:06

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.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stm32forum
Associate II
Posted on July 09, 2013 at 14:07

Your software simulator doesn't have an external crystal, so the flag will never be set.

Change the flag yourself in the register viewer.

auzgec
Associate II
Posted on July 09, 2013 at 14:18

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.
artniman
Associate
Posted on January 02, 2014 at 04:59

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6dY&d=%2Fa%2F0X0000000bsE%2FeDR3e4oCne8IKed.r50Qkdu31wnqoNhVcy_drsL5yxs&asPdf=false