|
|
View previous topic :: View next topic |
Author |
Message |
zhiling0229
Joined: 13 Sep 2006 Posts: 10
|
How to generate this string? |
Posted: Fri Oct 06, 2006 9:39 am |
|
|
Hi guys,
I'm trying to implement a V-stamp speech synthesizer driver.
I required to generate the text, then followed by CR or NUL. Was wondering how can I terminate with CR or NUL. Here is my test program.
#include <16F877A.h>
#use delay(clock=4000000)
#fuses XT, NOBROWNOUT, NOLVP, NOWDT
#use rs232(baud=2400, xmit=PIN_A2, rcv=PIN_A3)
struct lcd_pin_def
{
BOOLEAN B0; // B0
BOOLEAN B1; // B1
BOOLEAN B2; // B2
BOOLEAN B3; // B3
BOOLEAN B4; // B4
BOOLEAN B5; // B5
BOOLEAN B6; // B6
BOOLEAN B7; // B7
};
struct lcd_pin_def LCD;
#byte LCD = 0x06 // portB address on 16F877A
#use fast_io(D)
void main() {
set_tris_b(0x00); // graphic lcd control lines all output
LCD.B0 = 1;
delay_ms(2000);
LCD.B0 = 0;
printf("Testing 1 2 3"); // What should I change here?
} |
|
|
Ttelmah Guest
|
|
Posted: Fri Oct 06, 2006 10:27 am |
|
|
printf("Testing 1 2 3\r");
C supports various 'escape' characters. '\n', means 'LF', '\r', 'CR', etc..
You can generate any ASCII character, using \nnn, where 'nnn' is the 3 digit octal value to send, and \Xnn, using a hex value. It is standard in C, and mentioned in the manual, under 'expressions'.
Best Wishes |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Oct 06, 2006 10:32 am |
|
|
Quote: |
printf("Testing 1 2 3"); // What should I change here?
|
CR: Carriage Return
Is an old command name used in the Telex machines and electric typewriters.
It was used in conjunction with LF (Line Feed) whose hex equivalent is 0x0A.
#define CR 0x0D // CR: Carriage Return
printf("Testing 1 2 3%c", CR);
or
printf("Testing 1 2 3\r);
Humberto |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|