akhs
Newbie level 6
i want is to read line by line in a text file of a SD card and display those strings one by one on a LCD display.
first i tried to display strings in 2 lines separately but i was unable to do it,the below code what i developed is only display the 2nd line string........
in here i used character of "\r" carriage return to separately identify the two strings, but i can not display the string in the first line and display the 2nd line string at next
thank you.........
first i tried to display strings in 2 lines separately but i was unable to do it,the below code what i developed is only display the 2nd line string........
Code:
// LCD module connections
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
// SD module connections
sbit Mmc_Chip_Select at LATC0_bit; // for writing to output pin always use latch (PIC18 family)
sbit Mmc_Chip_Select_Direction at TRISC0_bit;
// End SD module connections
unsigned long i,k, size;
char filename[14] = "ASML.TXT"; // File names
char character[]="";
void main(){
ADCON1 |= 0x0D; // Configure AN0 and AN1 pins as analog
CMCON |= 7; // coparators off
TRISB = 0x00; //PORTB output
Delay_ms(100);
//Initialize LCD
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF );
Lcd_Out(1, 1, "Status:");
Lcd_Cmd(_LCD_SECOND_ROW);
// Initialize SPI1 module
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
// use fat16 quick format instead of init routine if a formatting is needed
if (Mmc_Fat_Init() == 0) {
// reinitialize spi at higher speed
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
//error = Mmc_Fat_Assign(&filename, 0);
Mmc_Fat_Assign(&filename, 0);
Mmc_Fat_Reset(&size); // To read file, procedure returns size of file
for (i = 1; i <= size; i++) {
Mmc_Fat_Read(&character);
}
while(character[k]!='\r') //break when find "\r"
k++;
k++;
k++;
Lcd_Out(2,1,&character[k]);
}else{
//Lcd_Cmd(_LCD_CLEAR);
//Lcd_Cmd(_LCD_CURSOR_OFF );
//Lcd_Out(1,2,"MMC init not OK");
}
}
in here i used character of "\r" carriage return to separately identify the two strings, but i can not display the string in the first line and display the 2nd line string at next
thank you.........