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

unable to write and read an alphabet from location (0xFF01) & then increment the location

I am using 16x2 lcd display and C8051F120 kit.I am using keil compiler.I have taken an array of size 26 as p[26]={a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}

I want to select an alphabet from array,write it at location (0xFF01) of flash memory ,read it from same location and then display it on lcd.Next,I want select another alphabet,write it at next location ,read it and then display it.Likewise <i repeat doing so till I form a suitable string of variable length.
could you please let me know how can I write an alphabet in flash memory.

  • Do you mean, you want to select a character?

  • Shouldn't you have an array:

    char p[26] = { 'a','b','c',...};
    


    or an alternative way:

    char p[26] = "abcdef...";
    


    Take a look in a standard C textbook about character arrays and strings.

  • I have taken my array as char p[26] only as you said.I want to selsct an alphabet using a key (ok) and then writeat location (0xff01) of lsh memory and read from same location and then display on lcd.similarly,I want to select another alphabet write at next location,read and then display onlcd.

  • Again, what do you mean by "alphabet" here?

    An alphabet is the complete set of letters used by a language - are you sure you don't mean "character" rather than "alphabet"...?

    Before worrying about details like memory types, specific addresses, LCDs, etc - have you thought about how you would do this in plain, standard 'C' ?

  • Are you playing with some form of shiffer, where every character in the alphabet is replaced with another character? Or you have a character set sent from a PC, and a display that uses a different character set, so you need to convert the numeric value of the character 'A' between the sender and the display?

  • By alphabet I mean all the alphabets from A to Z.and their data type is 'char'.I have taken an array storing all alphabets from a to z as

    char p[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    
    
    and the code i m using is:
    
    while(i>=0 && i<=25)
    {
            lcdcmd(0xC0);  //to clear lcd screen
            lcddata(p[i]);  //to send array to lcd.
    
            a=key(0);               //key function to see if  any key pressed//
    
            if(a=='U')      //if up key pressed
    
            i2=p[i++];       /increment the alphabets in array
            else if(a=='D') /if down key pressed
            i2=p[i--];        //decrement the alphabets in array
            delay(1000);
    

    //---------end---
    Could you let me know that for storing the incremented alphabet in array ,I am using 'i2'.Is this would store that alphabet which I want to select.

    Now,the next step I want is to write that selected alphabet at memory location (0xFF01),read from same location and then display on lcd.Next,move to select any othet alphabet from array ,write at next location ,read and displayed at next postion on the lcd.
    I hope know I am clear about my problem.
    Could you please help me out with this.
    Mainly,I am facing problem with the flash wite and read operation.
    Would you please help me.

  • No, no, no, NO!

    A is a character, not an alphabet.
    B is a character, not an alphabet.
    C is a character, not an alphabet.

    The union of A, B, C, ... Z represents an alphabet containing 26 characters.

    The next thing is that the character 'A' in the ASCII encoding has the numeric value 65. The character 'B' has the value 66. The character 'C' has the value 67.

    So you do not need to store the individual characters in memory. Why?

    If you get the numeric value 65 from a serial port, that value represents an 'A'. And if your display is only a tiny bit normal, it will also make use of ASCII and know that when it receivers the numeric value 65, it should display the graphical form of an 'A' at the current cursor position.

    But notice that the ASCII character table has the characters numbered in the normal sort order. So you do not need a lookup table to increment from a 'I' to a 'J'. If you add 1 to the numeric value of an 'I', you will get the numeric value of a 'J' - and can send this value to the display to show a 'J'.

    Another thing. You wrote in your code:

    lcddata(p[i]);  //to send array to lcd.
    


    You are not sending any array. You are sending a single character. So your comment is wrong. An incorrect comment is worse than a missing comment.

    idx = 0;
    for (;;) {
        lcdcmd(0xC0);        // Clear the display
        lcddata('A' + idx);  // Send current character
        do {
            key = get_key();
        } while (key == KEY_NONE);
        switch (key) {
            case KEY_UP:
                idx = (idx+1) % 26;
                break;
            case KEY_DOWN:
                idx = (idx+26-1) % 26;
                break;
            default:
                // Some other key pressed.
                ;
        }
        delay(1000);
    }
    

  • May be my comments are wrong but when I send the data to lcd it shows characters.But,i am not able to write it at location (0xFF01 ),read from same and then display on the lcd. could you tell me what is this symbol '%' in the code which you sent to me.I am not able to get it.selecting a character each time I want to form a string of variable length.I want to write ,read the characters in flash memory location starting at (0xFF01).

  • could you tell me what is this symbol '%' in the code which you sent to me
    that makes it crystal clear that you desperately need to read a 'C' book. in mine it is in chapter 2

    Erik