Topic : Lost communication

Forum : ARM

Original Post
Post Information Post
June 25, 2009 - 2:46am
Guest

I keep getting 'lost communication' message boxes when I try to add a new 'watch' variable. This is most annoying as it involves getting the Windows Task Manager to end the Ride7 application and then restarting Ride7 with a consequent reprogramming of the STM32F103C8 FLASH. Also, the program hangs when I try to initialize GPIOB. Anybody had any experience with either of these problems?

Replies
Post Information Post
+1
0
-1
June 30, 2009 - 11:07am
Guest

Hi

Can you let us know if you have this problem with the latest version of our software.
And also if it hapens with every project even the samples from Ride7 installation.

Regards,
Matloub

+1
0
-1
June 30, 2009 - 11:44pm
Guest

Hi matloub,
I was using Ride7 version 7.16 and RKit-ARM version 1.16 at the time, but have upgraded to 7.20 and 1.20 respectively since then. Also, I've been having so much trouble with things like 'while(RCC_GetSYSCLKSource() != 0x08) ;' and 'GPIO_Init(GPIOA, &GPIO_InitStructure) ;' hanging up during RLink sessions (see my post of 2009-06-29) that I've resorted to using SIM-ARM. This still hangs but at least I don't have the hassle of having to reconnect and reprogram the FLASH.
While I'm talking about my woes, add the following to the litany: Sometimes locally declared variables are not visible to the 'watch' window and I have to re-declare them globally. I presume this is because of compiler optimization.
Can you tell me if you think the following code should work:

// This part of the 'if' statement is for when I use the RLink to the real board

if(HSEStartUpStatus == SUCCESS)
{
/* Enable Prefetch Buffer */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);

/* HCLK = SYSCLK */
RCC_HCLKConfig(RCC_SYSCLK_Div1);

/* PCLK2 = HCLK */
RCC_PCLK2Config(RCC_HCLK_Div1);

/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);

/* PLLCLK = 4MHz * 14 = 56 MHz */
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_14);

/* Enable PLL */
RCC_PLLCmd(ENABLE);

/* Wait till PLL is ready */
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{
}

/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

/* Wait till PLL is used as system clock source */
while(RCC_GetSYSCLKSource() != 0x08)
{
}

// So far, so good

}
else // This is for when I use SIM-ARM and if the real HSE should fail
{
/* At this point clock source = ??? */
// ClockSource = RCC_GetSYSCLKSource();
/* At this point clock source = HSI */

/* Disable HSE. This line is probably not necessary. Is it desirable? */
// RCC_HSEConfig(RCC_HSE_OFF);

/* Enable HSI (Probably already done. Yes - see above) ------------------------------------*/
// RCC_HSICmd(ENABLE);

/* Enable Prefetch Buffer */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);

/* HCLK = SYSCLK */
RCC_HCLKConfig(RCC_SYSCLK_Div1);

/* PCLK2 = HCLK */
RCC_PCLK2Config(RCC_HCLK_Div1);

/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);

/* PLLCLK = (8MHz div 2) * 14 = 56 MHz */
RCC_PLLConfig(RCC_PLLSource_HSI_Div2, RCC_PLLMul_14);

/* Enable PLL */
RCC_PLLCmd(ENABLE);

/* Wait till PLL is ready */
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{
}

/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

// This next step is where the call never returns

/* Wait till PLL is used as system clock source --------------------------*/
while(RCC_GetSYSCLKSource() != 0x08)
{
}

// Stepping through the assembly code, I see the HSI never relinquishes control. But why?

}

Thanks for any help.

H.

+1
0
-1
July 1, 2009 - 6:35pm
Guest

Hi

Pelase find below some answers:

1 About the problem of adding a watch
From what you wrote:
- opening a project with STM32F103C8 as target
- starting debug with the simulator
- adding a watch
Should make the debug exit?
If you can give the details or what I have to do to reproduce the problem
I can try to find a solution.

About the code you have posted
I not sure using hte simulator is efficient.
What I can suggest is that you do not use the compiled version of the library in your porject options.
Add all the files from the library to your project.
Some times it can solve such issues.

Regards,
Matloub

+1
0
-1
July 2, 2009 - 3:28am
Guest

Hi,

The code lines preceding the if ... else statement are:

void RCC_Configuration(void)
{
RCC_ClocksTypeDef RCC_Clocks;

/* Get the frequencies of different on-chip clocks */
/* At this point all clocks 8 MHz except ADC clock = 4 MHz *? */
RCC_GetClocksFreq(&RCC_Clocks);

/* RCC system reset(for debug purpose) -------------------------------------*/
RCC_DeInit();

/* Enable HSE --------------------------------------------------------------*/
RCC_HSEConfig(RCC_HSE_ON);

/* Wait till HSE is ready --------------------------------------------------*/
HSEStartUpStatus = RCC_WaitForHSEStartUp();

... etc.

After the if...else statement is the line:

/* Get the frequencies of different on-chip clocks */
RCC_GetClocksFreq(&RCC_Clocks);

}

That's the entire routine.

Note that 'RCC_Clocks' is defined locally, but 'HSEStartUpStatus' is declared globally. When done like this, changes to both variables can be observed in the 'Watch' window. When 'HSEStartUpStatus' is declared locally, however, you can still see it in the 'Watch' window, but the debugger thinks it is not defined and won't show you how it changes when it is written to during the course of running the program. This is a minor point and I can work around it.

The bigger problem (on the way to yet other problems) is why the last 'while' statement in the compound 'else' statement never exits. That is, why can't I use a PLL-multiplied HSI clock? Why does:

/* Wait till PLL is used as system clock source --------------------------*/
while(RCC_GetSYSCLKSource() != 0x08)
{
}

never exit when the PLLs source is HSI, not HSE?

When you say: "I not sure using hte simulator is efficient", I don't know what you mean. The word 'efficient' does not make sense to me in this context. I'm not using a hse simulator. I expect the 'if' statement to fail (so far as I know, there is no way to simulate the external clock using the simulator) and have to resort to the 'else' statement, where the HSI clock will be used as the PLL's source.

Regards,

H.