cancel
Showing results for 
Search instead for 
Did you mean: 

C Lib problem

ter-jose
Associate II
Posted on July 09, 2007 at 09:24

C Lib problem

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
1 ACCEPTED SOLUTION

Accepted Solutions
raouf1
Associate II
Posted on May 17, 2011 at 12:15

Hello,

With default compiler option, when you made a call to a function within a driver, all the driver size will be included in the final image and not only the used function size. In fact, when you call the NVIC_SetVectorTable function, all the stm32f10x_nvic.c object will be included in the final image which correspond to the extra 1KByte.

To avoid such scenario, you have to set the right compiler configuration. For RVMDK toolchain please proceed as follows: in the project option menu, select 'C/C++' window and check the ''One ELF Section per Function'' box.

In your attached project I can see that you uses the V0.2 of the STM32F10x Firmware Library, this release is not up to date as the V0.3 has been released some weeks ago. This release comes with a rich set of examples (69) covering all the product features (w/ 5 examples for the ADC) and a preconfigured projects for RVMDK and EWARM tool chains. Please download this last release,

http://mcu.st.com/mcu/modules.php?name=mcu&file=familiesdocs&FAM=110

, and use the provided project for RVMDK which has been optimized to get the best code size.

If this is not already done, you have also to download the last RVMDK version V3.11 from Keil website.

With regards,

Raouf.

View solution in original post

4 REPLIES 4
ter-jose
Associate II
Posted on May 17, 2011 at 12:15

Hi all,

 

 

OBS1: i´m not a specialist in C.

 

OBS2: the code cote is not working.

 

 

running the ADC example we have this code in configuration function.

 

#else /* VECT_TAB_FLASH */

/* Set the Vector Table base location at 0x08000000 */

NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);

#endif

the NVIC_SetVectorTable function is:

void NVIC_SetVectorTable(u32 NVIC_VectTab, u32 Offset)

{

/* Check the parameters */

assert(IS_NVIC_VECTTAB(NVIC_VectTab));

assert(IS_NVIC_OFFSET(Offset));

SCB->ExceptionTableOffset = NVIC_VectTab | (Offset & (u32)0x1FFFFF80);

}

so, compiling this code with keil it is a 4798 bytes long. But if i hide the function call and write all the code inside the function...

 

#else /* VECT_TAB_FLASH */

/* Set the Vector Table base location at 0x08000000 */

//NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);

assert(IS_NVIC_VECTTAB(NVIC_VectTab_FLASH));

assert(IS_NVIC_OFFSET(0x0));

SCB->ExceptionTableOffset = NVIC_VectTab_FLASH | (0x0 & (u32)0x1FFFFF80);

#endif

... the code is 3682 bytes long. I think that 1k for this function call is so much. Can anyone explain what is happening? (forget about the assert function because i disabled #DEBUG)

 

 

thanks!

 

[ This message was edited by: jpremor on 02-07-2007 13:17 ]

ter-jose
Associate II
Posted on May 17, 2011 at 12:15

Attached is the example.

in C/C++ options, no boxes is selected. Im using the boot_flash option and the compile strings is here:

-c --device DLM -g -O2 -I..\..\LAB7 -I..\..\library\inc -I ''C:\Keil\ARM\INC\STMicroelectronics'' -DVECT_TAB_FLASH -o ''.\Obj\*.o'' --omf_browse ''.\Obj\*.crf'' --depend ''.\Obj\*.d''

thanks ibtiss, your answer was so helpfull!

raouf1
Associate II
Posted on May 17, 2011 at 12:15

Hello,

With default compiler option, when you made a call to a function within a driver, all the driver size will be included in the final image and not only the used function size. In fact, when you call the NVIC_SetVectorTable function, all the stm32f10x_nvic.c object will be included in the final image which correspond to the extra 1KByte.

To avoid such scenario, you have to set the right compiler configuration. For RVMDK toolchain please proceed as follows: in the project option menu, select 'C/C++' window and check the ''One ELF Section per Function'' box.

In your attached project I can see that you uses the V0.2 of the STM32F10x Firmware Library, this release is not up to date as the V0.3 has been released some weeks ago. This release comes with a rich set of examples (69) covering all the product features (w/ 5 examples for the ADC) and a preconfigured projects for RVMDK and EWARM tool chains. Please download this last release,

http://mcu.st.com/mcu/modules.php?name=mcu&file=familiesdocs&FAM=110

, and use the provided project for RVMDK which has been optimized to get the best code size.

If this is not already done, you have also to download the last RVMDK version V3.11 from Keil website.

With regards,

Raouf.

ter-jose
Associate II
Posted on May 17, 2011 at 12:15

Thanks raouf!!!

You solved my problem!!