Theo, Peter's code is spot on but obviously there is a little bit involved with the initialisation due to hardware differences, clock rate etc. When I started with SDCC a few years ago, getting RS232 I/O was my first task so that I could use the STDIO libraries and I am happy to help if you are still having trouble. I've got software code in C for transmitting serial data as well if you are not using the built-in serial port. Email me direct - design [at] clinchcom.com
SDCC rocks! Regards Graham Clinch ----- Original Message ----- From: "Peter Van Epp" <van...@sfu.ca> To: <sdcc-user@lists.sourceforge.net> Sent: Wednesday, October 05, 2011 8:57 PM Subject: [!! SPAM] Re: [Sdcc-user] SDCC Compiler Issue > On Wed, Oct 05, 2011 at 01:16:26PM -0400, Theo Tijssen wrote: >> Hello! I have a simple program in C language that I was hoping to compile >> in >> the SDCC compiler so I could download it onto my 8051 microcontroller. >> The >> code is: >> * >> /* Hello World program */ >> >> #include<stdio.h> >> >> main() >> { >> printf("Hello World"); >> >> }* >> >> The issue I am having is when I compile this in SDCC, the error reads: >> *?ASlink-Warning-Undefined Global '_putchar' referenced by module >> 'vprintf'* >> >> I tried putting in a general putchar code but that didn't work, it just >> gave >> me more errors in the compiler. Do you know how to fix this or what we >> need >> to add to our code in order for the compiler to properly compile it? Any >> help and/or suggestions are appreciated. >> >> Thanks in advance! > > You neet to provide a putchar that will use a suitable output > channel for your hardware. Assuming the UART is already initialized (and > if > not you would need to add the code to initialize it before this gets > called > but that is hardware specific to your hardware) something like this should > work. > > void putchar (char c) { > > while (!TI) > ; > TI = 0; > SBUF = c; > } > > main() > { > > /* code to initialize the UART and set the baud rate here! */ > > printf("Hello World"); > > } > > Peter Van Epp > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sdcc-user ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user