Hello,
When I try to compile my program I get the following error:
'project.axf: Error L6218E: Undefined symbol sendchar (referred from retarget.o).'
I've tried to solve this error for quite a while now, but it doesn't work out. I've read other forum threads and I've searched through the net, but I can't find a satisfying answer.
Some background info: I'm trying to get the UART0 working on the LPC2148. I use Keil uVision3 and I use the Philips LPC2000 Flash Utility V2.2.3 to upload the .hex file to the microcontroller.
I'm new with the UART and I find it quite difficult to work with.
This is the Retarget.c:
#include <stdio.h> #include <rt_misc.h> #pragma import(__use_no_semihosting_swi) extern int sendchar(int ch); struct __FILE (int handle;); FILE __stdout; int fputc(int ch, FILE *f) { return (sendchar(ch)); } int ferror(FILE*f) { return EOF; } void _ttywrch(int ch) { sendchar(ch); } void _sys_exit (int return_code) { label: goto label; }
I've tried several codes and everytime I get the same error. I've also tried the example code from 'The Insiders Guide To The Philips ARM7-Based Microcontrollers' for initializing the UART, which is:
#include "lpc214x.h" void init_serial (void) { PINSEL0 = 0x00050000; U1LCR = 0x00000083; U1DLL = 0x000000C2; U1LCR = 0x00000003; } int putchar (int ch) { if (ch == '\n') { while (!(U1LSR & 0x20)); U1THR = CR } while (!(U1LSR & 0x20)); return (U1THR = ch); } int getchar (void) { while (!(U1LSR & 0x01)); return (U1RBR); }
If I try to compile that, I get the error:
schiet.axf: Error: L6218E: Undefined symbol main (referred from kernel.o).
For my school project I need to get the LPC2148 communicating with a scoreboard. All that I have to get the LPC2148 to do is sending a code to the scoreboard to raise the score with '1' and I need to retrieve it's current score. But I have no ideas left how to get this working.
I hope that I've made my problem clear enough!
Kind regards!
from your error message, I think that the problem is not because of the use of serial port, but because your main routine isn't defined good.
normally it should look like:
/*---------------------------------------------------------------------------- * Main Function *---------------------------------------------------------------------------*/ int main (void) { /* Start with 'init' task. */ os_sys_init(init); while(1); }
Here I use the RTX kernel, I start a proces to Init my device and start the other processes.
All the rest is the same in my files (retarget, and initialisation). You know you can use printf("tekst"); now?? Does your code work without this code for serial communication???
"I'm new with the UART and I find it quite difficult to work with."
It seems that you are actually new to any sort of software development, and this has nothing specifically to do with the UART?
extern int sendchar(int ch);
Where is the definition of this "sendchar" function?
"from your error message, I think that the problem is ... because your main routine isn't defined good."
No: the error message say that it is sendchar that is not defined at all!
I really do think this message has something with main() to do :)
Thanks for the feedback. Actually I'm very new indeed, but I'm trying my best to get this working for my school project.
We've tried to define the sendchar function, but we simply didn't know how. Until now we only had to use delays and work with cases. That went well, but this is different :-P
With help from a friend yesterday we got data echoed back, but that only worked in the debug mode. So the program was fine, you'd think. When we tried to connect the LPC2148 with a terminal, it didn't send anything back. So that was our poblem yesterday. But today we were unable to get our program compiled, we obviously changed something. We'll work on it tomorrow and I hope to give you some more details then.
Thank you for your time, Kind regards.
That's what comes with wildly thrashing about and grabbing whatever unrelated code you find next, instead of carefully reading the message and thinking about what it's telling you...
The first message, then, relates to the first piece of code - and says that sendchar is not defined.
The second piece of code contains no main and, unsurprisingly, gets an error saying that main is not defined!
That's true, but, just as I wrote, we've tried different codes, we didn't put them together :-)
And in my previous post I made a slight error. It worked in the debug mode yesterday, then we continued editing the code to make it working from the chip. And that's where it went bad and Keil started giving errors while compiling. Well, today we've been busy trying to correct the code, but we didn't manage to do so, and that's the reason I'm posting my problem on the forum.
Again, you are right Andy, I'm a freshman.
Update: Today we got the whole UART -> Terminal stuff working :) We changed some things and with the help from a friend we got rid of the errors.
Thanks for the feedback!
Kind regards, Daniël