|
From: J S <g1p...@ya...> - 2005-06-18 14:39:08
|
Hi Peter,
--- Peter <pl...@ac...> wrote:
>
> Two solutions:
>
> No interrupts:
>
> // set TI at program start
> TI=1;
>
> // write characters
> for(i = 32; i < 96; ++i) { // span ascii set
> while(!TI); // wait until TI is 1
> TI=0; // clear it
> SBUF=i; // send a character;
> }
Ahh, ok, I had something similar to that before in my
code, but it didn't work. Can't say it was exactly
what you have here, so I might have wrote it wrong.
>
> With interrupts:
>
Hmm, thats a tad bit more complicated with interrupts
;-)
> Read the fine manual. You have to define putchar.
> SDCC has no idea what
> is attached to the circuit, you have to write a
> function that does the
> actual output. You could output to leds, a lcd, or
> serial. A synchronous
> putchar suitable for serial from above would be:
>
> // in init code, after SCON=... etc
> // you HAVE to set TI at the start of the program
> TI=1;
>
> // send a character via serial line, suitable for
> printf() etc
> int putchar(int ch)
> {
> while(!TI); // wait until TI is set (it MUST be
> set in the init
> // code for the first character
> to go out!!!
> TI=0; // clear
> SBUF=ch; // send it out
> return((unsigned char)ch); // also return it as
> per standard C
> }
Ahh, didn't know I needed to define my own putchar. I
decided to try this first since I had the code already
set for using printf_tiny. I added in the putchar
function and then tried to output some stuff to the
LCD screen. However, only the first character of a
string is displayed and nothing else. Not sure if its
because this putchar function is a synchronous one
(the lcd module wants asynchronous). Any help would
be great.
Thanks!
J Silverman
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
|