Sign In

Trouble In Writing Array String In Internal Eeprom

Sujit Mishra mishras1132@gmail.com India

Hardware: PIC16F877A Running At 4MHZ Software: HITECH Compiler, MPLAB X IDE

Dear Sir please guide me with the routine to edit and write a string in eeprom with simple 3 push button. one for changing string character, one for shifting cursor and one for saving data.

Images

Replies

R Avinash
2016-07-19 03:44:37
So you want us to write the whole code for you?
R Sujit Mishra
2016-07-19 03:54:05
No sir just want you to guide me how to do it.
R Sujit Mishra
2016-07-28 08:49:55
Sir below is my code for entering text in an array but sir I am not able to replace it with the older array character. Please help sir.
char i, Cursor = 0;
char message1[] = "ABCD";
char limit = 16;

void EDIT_Text (void)
{
    int limit = 16;     
    for(i = 0; i < limit ; )
    {        
        if(Down == 1)
        {           
            __delay_ms(300);        // De-bouncing            
            message1[i] = message1[i]-1;
            
            if(message1[i] > 'Z') message1[i] = 'A';
            
            else if(message1[i] < 'A') message1[i] = 'Z'; 
            
            lcd_gotoxy(0,Cursor);
            WriteDataToLCD(message1[i]);
        }

        if(Up == 1)
        {           
            __delay_ms(300);        // De-bouncing           
            message1[i] = message1[i]+1;                      
            if(message1[i] > 'Z')   message1[i] = 'A';
            
            else if(message1[i] < 'A')  message1[i] = 'Z';
              
            lcd_gotoxy(0,Cursor);
            WriteDataToLCD(message1[i]);
        }

        if(Enter == 1)
        {
            __delay_ms(300);        // De-bouncing
            i = i + 1;
            Cursor = Cursor + 1;
        }

        if(Back == 1)
        {
            __delay_ms(300);        // De-bouncing        
            limit = i;
            ClearLCDScreen();           
            lcd_gotoxy (1,1);
            i = 0;
            while (message1[i] != limit)
            {        
                WriteDataToLCD(message1[i]);
                __delay_ms(200);      
                i++; 
            }           
        }        
    }
R Avinash Gupta
2016-07-29 05:29:19
What is happening when you run this code? Can you show us a video? You can upload on YouTube and then paste the link here.
R Sujit Mishra
2016-07-29 07:50:06
Sir, first when I press enter button blinking cursor starts displaying on 1st position of lcd but when i start pressing UP or Down button my characters increments or decrements as per button pressed but why my blinking cursor moves to 2nd position while i am scrolling character on 1st position.
Second after entering the desired character when I press BACK button it should display only the characters which I have typed and replace those characters in an array but instead it display all the 16th characters which i have set for limit. Please have a look on my video and guide me with my mistakes.
https://youtu.be/zCDB3olg-Qg
R Avinash
2016-07-31 06:44:40
on line #1

char message1[] = "ABCD";

this allocates only 5 byte string (4 for ABCD and one for null char at the end to mark end of string)

change this to

char message1[17];//16 for msg and one for null char

change the code starting at line 42 as



__delay_ms(300);        // De-bouncing        
limit = i;
ClearLCDScreen();           
lcd_gotoxy (1,1);
i = 0;
while (i != limit)
{        
    WriteDataToLCD(message1[i]);
    __delay_ms(200);      
    i++; 
}     
R Sujit Mishra
2016-08-01 05:29:28
Thank you sir, one of the problem resolved but still there is a problem for blinking cursor. Why blinking character shifts by one character when I starts scrolling the characters. And sir please also guide me how to save this edited array characters in internal eeprom.

Thanks a lot sir.....!

Post a reply to Sujit Mishra

Think you can help Sujit Mishra ? Then post your thoughts that might help Sujit Mishra. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.