This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

printf on lpc2129

I can't seem to get printf going on my system. I've declared putchar as extern and written a routine called putchar to output to the serial port, but the application dies whenever I try to printf. I dare say I'm not doing something fairly fundamental!

Parents
  • I had a quick look last night into what you've suggested. Firstly, the \keil\arm\lib directory doesn't exist so maybe this is half my problem! I'm also a little unsure of how to start a project from scratch with issues like the linker. I've figured out the startup file after much grief initially. Pretty much i've started off with the blinkyirq project and added my own code.I've conquered the interrupts,timers and uarts but the issue with printf is still eluding me.FYI I'm using a tinyarm50 board.

Reply
  • I had a quick look last night into what you've suggested. Firstly, the \keil\arm\lib directory doesn't exist so maybe this is half my problem! I'm also a little unsure of how to start a project from scratch with issues like the linker. I've figured out the startup file after much grief initially. Pretty much i've started off with the blinkyirq project and added my own code.I've conquered the interrupts,timers and uarts but the issue with printf is still eluding me.FYI I'm using a tinyarm50 board.

Children
  • I did a bit more reading and fiddling tonight. After reading a bit more on how to create a project (I had previously added to the blinkyirq sample project), I created a new project, added the same files as I had used previously and sprintf started working. I then tried printf which also worked through my interrupt driven comms. So I'm happy, don't ask me what changed though to make it work apart from creating a new project. I found to get printf working with my code I had to add syscalls.c to the project (I had tried that previously with no luck). Thanks.

  • Are you using the KEIL compiler or the GNU compiler?

    Jon

  • I'n using the GNU toolchain. With the tinyarm board they supply the IAR tools but there was no sample programs and I couldn't get a piece of code to run, so I tried the Keil demo that had the blinky demo. That ran first time so I've stuck with the Keil tools. I'm porting across some of my 8bit code to do a comparison in terms of performance and to get a feel for the ARM tools. Now I've overcome the printf problem, I can forge ahead! Cheers.

  • There is a generic GNU example that shows printf I/O in the folder:
    Keil\ARM\GNU\Examples\Hello.

    It is written for a Atmel device, but can be easily adapted to any other part. Change the following:



  • There is a generic GNU example that shows printf I/O in the folder:
    Keil\ARM\GNU\Examples\Hello.

    It is written for a Atmel device, but can be easily adapted to any other part. Change the following:

    • UART initalization at the beginning of main.
    • I/O functions in SERIAL.C.

    Basically you may take a look to the Keil ARM C example (part of DKARM V1.3) in the folder Keil\ARM\Examples\Hello. This variant of the "Hello World" program is already configured for an LPC21xx device.