This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Some strange errors..

Someone could please tell me why this little piece of code generate

***** syntax error near 'char'

#include <stdio.h> /* standard I/O .h-file */
#include <XC161.h> /* special function register XC161 */
#include <math.h>


/****************/
/* main program */
/****************/
void main (void) { /* execution starts here */
/* initialize the serial interface */
#ifndef Monitor /* do not initialize if you use Monitor-166 */
P3 |= 0x0400; /* SET PORT 3.10 OUTPUT LATCH (TXD) */
DP3 |= 0x0400; /* SET PORT 3.10 DIRECTION CONTROL (TXD OUTPUT) */
DP3 &= 0xF7FF; /* RESET PORT 3.11 DIRECTION CONTROL (RXD INPUT) */
ASC0_TIC = 0x80; /* SET TRANSMIT INTERRUPT FLAG */
ASC0_RIC = 0x00; /* DELETE RECEIVE INTERRUPT FLAG */
ASC0_BG = 0x40; /* SET BAUDRATE TO 9600 BAUD @ 20MHz */
ASC0_CON = 0x8011; /* SET SERIAL MODE */
ALTSEL0P3 |= 0x0C00; /* Configure port pins for serial interface 0 */
#endif

char nome[10];
int i;
int j=0;


while (1)
{

i=-1;
nome[0]='a';
/* An embedded program does not stop and */
do
{
i++;
nome[i]=getchar();
// printf("%c",nome[i]);

}
while (nome[i]!=0x00A);
printf("Ciao, ");
for (j=0;j<=i;j++)
printf("%c",nome[j]);
} /* loop. You may wish to put in your own */
}


and instead this works :


#include <stdio.h> /* standard I/O .h-file */
#include <XC161.h> /* special function register XC161 */
#include <math.h>


/****************/
/* main program */
/****************/
void main (void) { /* execution starts here */
/* initialize the serial interface */
#ifndef Monitor /* do not initialize if you use Monitor-166 */
P3 |= 0x0400; /* SET PORT 3.10 OUTPUT LATCH (TXD) */
DP3 |= 0x0400; /* SET PORT 3.10 DIRECTION CONTROL (TXD OUTPUT) */
DP3 &= 0xF7FF; /* RESET PORT 3.11 DIRECTION CONTROL (RXD INPUT) */
ASC0_TIC = 0x80; /* SET TRANSMIT INTERRUPT FLAG */
ASC0_RIC = 0x00; /* DELETE RECEIVE INTERRUPT FLAG */
ASC0_BG = 0x40; /* SET BAUDRATE TO 9600 BAUD @ 20MHz */
ASC0_CON = 0x8011; /* SET SERIAL MODE */
ALTSEL0P3 |= 0x0C00; /* Configure port pins for serial interface 0 */
#endif




while (1)
{
char nome[10];
int i;
int j=0;

i=-1;
nome[0]='a';
/* An embedded program does not stop and */
do
{
i++;
nome[i]=getchar();
// printf("%c",nome[i]);

}
while (nome[i]!=0x00A);
printf("Ciao, ");
for (j=0;j<=i;j++)
printf("%c",nome[j]);
} /* loop. You may wish to put in your own */
} /*




for both of them, i've choose the small memory model, and near 6 for data threshold.

Pleas help me, or i'll go crazy!

0