cancel
Showing results for 
Search instead for 
Did you mean: 

Stuck with example[SOLVED]

frankfrank953
Associate II
Posted on May 10, 2010 at 15:27

Stuck with example[SOLVED]

16 REPLIES 16
chikos332
Associate II
Posted on May 17, 2011 at 13:50

Hi marc,

For the HalfDuplex example, you have to connect the two TX  pins with a pull up resistor of 10K.

Are you sure you are using the right IOs ?

As it is mentionned in the readme file:

''

  - STM3210E-EVAL Set-up

    - Connect USART1_Tx(PA.09) to USART2_Tx(PA.02) and connect a pull-up resistor to this line (10K)

''

Otherwise, did you try a simple example like ''USART/Polling'' ?

Andrew Neil
Chief II
Posted on May 17, 2011 at 13:50

''the (sic) Olimex devel board''

Olimex do several STM32 boards; which one, precisely, are you using?

''I am building using the USE_STM3210E_EVAL define''

The Olimex boards that I used were not 100% compatible with this; do check

very

carefully - particularly for pin re-mapping...

frankfrank953
Associate II
Posted on May 17, 2011 at 13:50

I have found some differences in the way that the clock domains have been initialised between the working version and the V3.3.

When I forced the :

SYSCLK_Frequency

HCLK_Frequency

PCLK1_Frequency

PCLK2_Frequency

ADCCLK_Frequency

In the serial initialisation then the serial worked.  The bit I dont understand about this is that the clocks are setup, well at least I think they are, maybe this is where its going wrong:

void Clk_Init (void)

{

  // 1. Cloking the controller from internal HSI RC (8 MHz)

  RCC_HSICmd(ENABLE);

  // wait until the HSI is ready

  while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);

  RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);

  // 2. Enable ext. high frequency OSC

  RCC_HSEConfig(RCC_HSE_ON);

  // wait until the HSE is ready

  while(RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET);

  // 3. Init PLL

  RCC_PLLConfig(RCC_PLLSource_HSE_Div1,RCC_PLLMul_9); // 72MHz

//  RCC_PLLConfig(RCC_PLLSource_HSE_Div2,RCC_PLLMul_9); // 72MHz

  RCC_PLLCmd(ENABLE);

  // wait until the PLL is ready

  while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);

  // 4. Set system clock divders

  RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);

  RCC_ADCCLKConfig(RCC_PCLK2_Div8);

  RCC_PCLK2Config(RCC_HCLK_Div1);

  RCC_PCLK1Config(RCC_HCLK_Div2);

  RCC_HCLKConfig(RCC_SYSCLK_Div1);

  // Flash 1 wait state

  *(vu32 *)0x40022000 = 0x12;

  // 5. Clock system from PLL

  RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

}

The values looked correct when they were initialised but when the USART code queried the clocks with :

RCC_GetClocksFreq()

It got returned only the SYSCLK_Frequency and all other frequencies were 0.

This is where my problem is.  It looked as though the APBAHBPrescTable entries were wrong.  I will have another look at it today.

Thanks for the replies.

frankfrank953
Associate II
Posted on May 17, 2011 at 13:50

To reply to your question about the board... I am using the STM32-P103 board.

I have the UART configured with an external MAX232 chip and all I'm trying to do is get some characters out.

I've been diffing the code between the two versions and it seems to be the same so I'm a bit stumped. The HSI_Value is defined correctly 8M and the device type is selected as STM32F10X_MD which is correct. So back to debug :(

Posted on May 17, 2011 at 13:50

Check that your stack is big enough, if it is not and you use things like printf/scanf, local variables, etc, the stack will creep down and trash the heap/static data below it.

With many of the ST examples a 512 (0x200) byte stack is used, this is often inadequate.

As part of the C startup (Keil and others) the compiler clears the heap RAM, and copies the static (non const initialized) from FLASH into RAM before calling the user main() function.

In startup.s (or whatever)

                EXPORT Stack_Size

                EXPORT Stack_Mem

Stack_Size      EQU     0x00001000

                AREA    STACK, NOINIT, READWRITE, ALIGN=3

Stack_Mem       SPACE   Stack_Size

__initial_sp

 

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
frankfrank953
Associate II
Posted on May 17, 2011 at 13:50

OK... stepping through I see that my APBAHBPrescTable is corrupt!!!

In the V0.2 code it has the correct values but in the V3.3 it either hasnt been initialised or has been corrupted.

The V3.3 declaration is static __I uint8_t

The V0.2 declaratoin is static uc8

Something isnt right with the initialisation of data...  I have forced the structure to be a const uint8_t and that has now been put into const mem so it is always initialised as its part of the image.

So what can I look at to see how the initialised variables get ''initialised'' ? This is definately where the problem is.

Thanks

Marc

frankfrank953
Associate II
Posted on May 17, 2011 at 13:50

I think its something to do with the use of startup_stm32f10x_md.s.  In the previous version of the library < V3 there was no startup assembly source. They have now introduced it so I need to build and link it.  Also I need to add the reigons to the linking so that I dont get this I as I am at the moment :

UNDEFINED SYMBOLS

_sidata

_sdata

_edata

_sbss

_ebss

SystemInit

main

_estack

Posted on May 17, 2011 at 13:50

Sounds like heaps of fun...

I'm using Keil and V2.0.1 of the library. The startup code I'm talking about is for the C compiler, not the library per se, and basically deals with the stack and the vector table. It calls into the C run time library which clears the heap, copies the statics.

Perhaps downloading a demo of Keil or IAR and using the standard example templates might be easier.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
frankfrank953
Associate II
Posted on May 17, 2011 at 13:50

Using the Keil or IAR wont help as the projects define the regions and other vital stuff is auto generated by their toolchain.

gcc is a wonderful beast but takes some configuring.  All examples out there I have found are for use with the older version of libraries. (Aghhhhh)