jaime
Joined: 25 Nov 2005 Posts: 56 Location: Porto - Portugal
|
Uart stream - solved |
Posted: Mon May 25, 2009 3:13 pm |
|
|
Hello
I'm testing the fat driver from ccs with 4.072 compiler. Everything works with one uart, but when I change my code for two uarts and add a stream for each one I have some compiler error.
undefined identifier pc
Can anyone explain this?
Code: |
#include <18F2525.h>
#device PASS_STRINGS = IN_RAM
#fuses NOWDT,HS, NOPROTECT
#use delay(clock=16M)
#use rs232(baud=57600, xmit=pin_b6, rcv=pin_b7, errors, stream=pc)
#use rs232(baud=4800, xmit=pin_c6, rcv=pin_c7, errors, stream=gps)
#define MMCSD_PIN_SCL PIN_A1 //o
#define MMCSD_PIN_SDI PIN_A3 //i
#define MMCSD_PIN_SDO PIN_A2 //o
#define MMCSD_PIN_SELECT PIN_A0 //o
#include <mmcsd.c>
#include <fat.c>
void main()
{
int i;
char file_name[20];
char buffer[255];
FILE stream_file;
strcpy(file_name,"/log.txt");
delay_ms(3000);
fprintf(pc,"\r\nINIT: ");
i = fat_init();
if (i)
fprintf(pc,"ERROR INITIALIZING FAT");
else
fprintf(pc,"INIT OK");
delay_ms(1000);
fprintf(pc,"\r\nMAKING FILE '%s': ", file_name);
if(mk_file(file_name) != GOODEC) //??????????????
fprintf(pc,"ERROR CREATING FILE");
else
fprintf(pc,"FILE CREATED");
delay_ms(1000);
fprintf(pc,"\r\nWRITE SOMETHING : ");
while(1)
{
do{
buffer[i] = getch();
// check for a backspace
if(buffer[i] != 8)
{
fprintf(pc,"%c", buffer[i]);
i++;
}
else if(i > 0)
{
// delete the last character
i--;
putc(8);
putc(' ');
putc(8);
}
}while(buffer[i - 1] != '\r');
buffer[i-1] = '\0';
fprintf(pc,"\r\nAPPENDING '%s' TO '%s':", buffer, file_name);
if(fatopen(file_name, "a", &stream_file) != GOODEC)
fprintf(pc,"\n\rERROR OPENING FILE");
else
fprintf(pc,"\n\rOPEN OK");
fatputs(buffer, &stream_file);
fatputs("\r\n", &stream_file);
if(fatclose(&stream_file) != GOODEC)
fprintf(pc,"\n\rERROR CLOSING FILE");
else
fprintf(pc,"\n\rCLOSING OK");
fprintf(pc,"\r\nWRITE SOMETHING : ");
i=0;
}
}
|
Last edited by jaime on Tue May 26, 2009 1:40 am; edited 1 time in total |
|