Hi Everyone, I'm newbie about keil and ARM tools. I have STM32 discovery board and I want to build RTC clock with calendar which is controlled by RS232.
I have a problem when use exported functions which are defined in stm32f10x_XXX.h.
I prapare configration wizard to create STM32_Init.c. Enabled USART and RTC.
I got error message from compiler. "Error: L6218E: Undefined symbol RTC_EnterConfigMode (referred from main.o)." I search L6218E error code on form and everone said its about defination and library manegment.
I checked project explorer window and check "stm32f10x_rtc.h" file connected to main.c . I can't use any other stm32f10x_XXX.h libraries exported functions too.
This is code which I worked on it. Why I got L6218E ? Could u guide to me for this.
Best regards
/******************************************************************************************/ #include <stm32f10x_lib.h> // STM32F10x Library Definitions #include "STM32_Init.h" // STM32 Initialization #include "stdio.h" #include "string.h" int saniye=0; int dakika=59; int saat=11; // Time variable saniye-second dakika-minute saat-hour void SendChar (char text[]) ; // Send Char to RS232 void SendByte (int byte); // Send byte to RS232 char aName[] = "RTC over RS232\n\r"; char aTime[] = "Timer \n\r"; char buffer[] = "24 : 59 : 59\n\r"; /*---------------------------------------------------------------------------- MAIN function *----------------------------------------------------------------------------*/ int main (void) { stm32_Init (); // STM32 init while (1){ RTC_EnterConfigMode(); // PROBLEM is HERE. Without this line, Code Worked RTC_ExitConfigMode(); // PROBLEM is HERE Without this line, Code Worked if(GPIOA->IDR & (u32)(1<<0)) // Led 4 blink When push Button { GPIOC->BSRR=(u32)(1<<8); } else { GPIOC->BRR=(u32)(1<<8); } } } // end main void RTC_IRQHandler(void) //RTC interreupt handler to send Time data RS232 port every second { sprintf (buffer, "%d : %d : %d\n\r", saat,dakika,saniye); // Write Time variable to Buffer SendChar(aName); SendChar(buffer); if (RTC->CRL & (1<<0) ) { // check second flag RTC->CRL &= ~(1<<0); // clear second flag if(++saniye>=60){ // create time value with RTC interrupt and count time variale saniye=0; if(++dakika>=60){ dakika=0; if(++saat>=24) saat=0;} } if(GPIOC->IDR & (u32)(1<<9)){ //Toggle every sec LED3 GPIOC->BRR=(u32)(1<<9); } else GPIOC->BSRR=(u32)(1<<9); } } // end RTC_IRQHandler void SendChar ( char text[] ) { unsigned int i, len; len = strlen(text); for(i=0; i<len; i++) { SendByte(text[i]); } } void SendByte (int byte) { while (!(USART1->SR & USART_FLAG_TXE)); //Wait for the uart to finish sending the byte. USART1->DR = byte; }
.
Do you have the function "RTC_EnterConfigMode" defined in your code or in a library you link along? If not, add it in a separate module (providing the prototype in the header file please!) or just add it in the module where the error occurs as a static.
Your header file *.h just tells the compiler that there somewhere exists a function with that specific name, and what data types it returns and takes as parameters.
You still need either the source code for the function, or a precompiled version in an object file or library.
Thanks for reply.
If i understand correctly ,
stm32f10x_rtc.h has function prototype "void RTC_EnterConfigMode(void);". It's not source code.
You said , I have to write these source code in header file, right? These exported functions are just prototype for guidance?
If these are library file, they have to include sourse code on some where right? Where is source of functions. I tought it will be easy when I saw exported functions.
Sorry Per Westermark,
I tought I reply bought.
******
The others have explained the problem. It has nothing to do with Keil or ARM - it is standard, textbook, 'C' stuff.
It is essential that you understand the difference between Declarations and Definitions - search this forum for those 2 terms to find very many previous examples!
See also:
c-faq.com/.../decldef.html
publications.gbdirect.co.uk/.../declarations_and_definitions.html
blog.antronics.co.uk/.../12
"stm32f10x_rtc.h has function prototype 'void RTC_EnterConfigMode(void);'"
Correct.
"It's not source code"
Not strictly correct! It is 'source code' in the sense that it is input text to the compiler, but it is not the source code that Defines the function - it is just a Declaration
As I said earlier, it is essential that you understand the difference!
"I have to write these source code in header file, right?"
No, he didn't say that - and it would not be right.
It is correct for the header to contain only the Declatation - not the Definition
"These exported functions are just prototype for guidance?"
The prototypes Declare to the compiler that the Definitions will be exported by some other module - that's why they are called "Declarations"!
"If these are library file, they have to include source code on some where right?"
Wrong: Library files have already been compiled - so that you do not need the source!
"Where is source of functions."
They are provided by ST - you can download them from the ST website
In the source (.c) file you place the implementation of a function:
void RTC_EnterConfigMode(void) { // your implementation }
in the respective header file, you tell the compiler how it should be used - note that without a prototype in a header file, a function is not more than a resolved memory address anybody can call - even delivering the wrong number of parameters to a function (not a good idea...).
So in the header file (.h) you place
extern void RTC_EnterConfigMode(void) ;
Dear Andrew,
Thanks your guidence.
I will search ST website to get source of this functions. And your preferred forms.
I try understand differece with declaration and defination.
Can I share my result here. I feel bad after your answer. this is not about keil form.
Thanks anyway .
Keil include a version of the ST Standard Peripheral Library with both source & pre-built library as a standard part of the ARM toolset:
Source: Keil\ARM\Examples\ST\STM32F10xFWLib
Library: Keil\ARM\RVxx\LIB\ST
However, note that this is almost certainly not the latest version; therefore it will not work with current examples on the ST site.
"...almost certainly not the latest version; therefore it will not work with current examples on the ST site."
There has been a great deal of grief discussed in a great many threads on both this & the ST forum about the problems due to trying to use code written for one version of the ST Standard Peripheral Library with a different version.
I have also suffered this myself.
For example:
http://www.keil.com/forum/19540/
http://www.keil.com/forum/docs/thread19482.asp
AFAIK, ST only provide their "library" as source - not as a true, ready-built Library.
Therefore, my recommendation is that you include the necessary source files from the appropriate "library" version in your Project, and build them as part of the project.
If you wish, you could make a separate Group for the ST files: www.keil.com/.../uv4_ca_create_file_groups.htm
This also has the advantage of giving you source-level debugging in the "library" functions.
To avoid any risk of confusion, I would delete the ready-built Library & sources from the Keil installation.
Because it's such a frequently-occurring problem, I have pulled the above post out into a separate thread - for easy reference:
http://www.keil.com/forum/19588/
Please make any comments there unless they are directly related to this original thread.