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!
printf uses putchar and _getkey and they are configured to use UART1 (for the MCB2100). Take a look in \KEIL\ARM\LIB for the source for putchar and getkey. They are polled but this is at least a starting point. As for the debugger, are you using ULINK to connect to your hardware? IF not, you can use the simulator. I accurately simulates the on-chip peripherals for the devices we support. It's what I used to test the hello world example. Jon
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.
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: