paulfjujo
Advanced Member level 4
- Joined
- Jun 9, 2008
- Messages
- 1,468
- Helped
- 298
- Reputation
- 596
- Reaction score
- 284
- Trophy points
- 1,363
- Location
- France 01800
- Activity points
- 10,619
hello
use balise CODE to post some code part.
Try to send a LF caractere before , witch is not a visible car
or try to init TRMT=0
13=code of CR=Carriage Retrurn retur to begining of the line
10= code of LF=Line Feed goto next line
sometimes to change the line you can use LF, or LF+CR depending of terminal configuration
Pay attention to use a buffer to contain all caracteres of the string
"a" is one charactere size only !
You can use the same treatment as in #8 , in your main()
your string can be as long as MAX_LEN buffer size or can be terminated by CR (enter Touch)
so no matter for the exact size of string if between 1 to 80 cars
use balise CODE to post some code part.
it's because Transmit register is not empty at the begining of program.here one extra " € " is coming.
Try to send a LF caractere before , witch is not a visible car
or try to init TRMT=0
what is that 13 means ?
13=code of CR=Carriage Retrurn retur to begining of the line
10= code of LF=Line Feed goto next line
sometimes to change the line you can use LF, or LF+CR depending of terminal configuration
Code:
//for that i use getsUSART(a,5);
putsUSART(a);
Pay attention to use a buffer to contain all caracteres of the string
"a" is one charactere size only !
You can use the same treatment as in #8 , in your main()
Code:
#define CR 13;
#define LF 10;
#define BS 8;
#define MAX_LEN 80
char buffer[MAX_LEN]; // buffer de reception
void main()
unsigned char a;
int i,k;
i=0;
buffer[0]=0;
....
....
while(1)
{
if(PIR1bits.RCIF) // si un car arrive
{
a =Read1USART(); // le lire => RAZ RCIF
if(RCSTAbits.FERR || RCSTAbits.OERR) // error treatment
{
RCSTAbits.CREN = 0 ; RCSTAbits.CREN= 1 ;
}
while(Busy1USART()); // par sécurité
if (PORTBbits.RB1==0) Write1USART(a); // echo on display if RB1=0
if( a == BS) // erase the last car with touch Back Slash (<-)
{
if(i>0){
i--; }
}
else
{
if(a != CR && i<MAX_LEN)
{
buffer[i++]=a ; // stockage dans le buffer
}else
{
buffer[i]='\0'; // fin de chaîne si CR ou taille maxi
i=0;
put_RS(CR);put_RS(LF); // new empty line on display
k=PutStr_RS(buffer); // print out the content of buffer
buffer[0]=0; // re-init buffer stating point at the beginning
}
}
}
.....
.....
}
}
your string can be as long as MAX_LEN buffer size or can be terminated by CR (enter Touch)
so no matter for the exact size of string if between 1 to 80 cars