Download AN731

Transcript
AN731
/**************************************************************
** void Read_file(void)
**
** Requests and reads the HTML web page that is sent when
**
** requested by a web browser.
**
** This routine strips out all carriage returns and line**
** feeds found in the file. It also lookds for a semi**
** colon to end the file.
**
**************************************************************/
void Read_file()
{
printf(“%c[2J”,esc);// Print request to the terminal
printf(“%c[10;20H Ready to receive file”,esc);
printf(“%c[12;20H 32688 bytes max”,esc);
printf(“%c[14;20H End file with ;”,esc);
printf(“%c[16;20H Set your terminal for Hardware Flow Control”,esc);
ch=1;
i=0;
index=0x50;
while(1)
{
CTS = 0;// enable send
ch=getc();// get character from USART
CTS = 1;// disable send
if(index == 32767)// Stop if EEPROM is full
break;
if(ch==00)// Stop if NULL is read
break;
if(ch==’;’)// Stop if semicolon is read
break;
// Otherwise write character to EEPROM
write_ext_eeprom(index, ch);
// FLASH status LED to indicate data transfer
if(bit_test(index,4))// flash LEDs
{
LED1 = 1;
LED2 = 0;
}
else
{
LED1 = 0;
LED2 = 1;
}
index++;
}
write_ext_eeprom(index, 0);// Write terminating NULL
CTS = 0;
// enable send
LED1=1;
// turn off LEDs
LED2=1;
// Print status of download to EEPROM
index = index - 80;
printf(“%c[2J”,esc); // clear screen
printf(“%c[12;28H Received %lu bytes”,esc,index);
if(index > 32688)
printf(“%c[18:20H Error maximum bytes is 32688”,esc);
printf(“%c[18;25H Press any key to continue”,esc);
ch=getc();
CTS = 1;
// disable send
}
DS00731A-page 22
Preliminary
 2000 Microchip Technology Inc.