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

interacting with a k6x8008 ram chip

hello everyone, I am reading some code on a system that connect the 8051 with an external ram chip but I have no idea what is going on with the code, I have been struggling on this for quite some time now, just want to see if anyone can point me to the right direction.

the first part i dun understand is how the ram is use

void k6x8008_writebyte (unsigned char hadd,unsigned char madd,unsigned char ladd,unsigned char indat)
{ RD = 1; WR = 1; k6x8008_laddress(ladd); k6x8008_maddress(madd); k6x8008_din(indat); k6x8008_din(indat); k6x8008_haddress(hadd); WR = 0; WR = 0; WR = 1; k6x8008_haddress(0x00); P0 = 0; WR = 1;
}

i don't understand what those ladd, madd or hadd means at all

on the main code this is the part that requires writing data to the ram...

iphadd=((subaddress&HADDBITS)/0x00010000);
ipmadd=((subaddress&MADDBITS)/0x00000100);
ipladd=((subaddress&LADDBITS)/0x00000001); k6x8008_writebyte(iphadd,ipmadd,ipladd+0x00,0xff);
k6x8008_writebyte(iphadd,ipmadd,ipladd+0x01,0xff);
k6x8008_writebyte(iphadd,ipmadd,ipladd+0x02,0xff);

why does the coder uses binary division?? and this might be abstract but im also not sure why he is writing 0xff to the ram in the part above

Parents
  • P.S. in the k6x8008_writebyte function, why did the previous developer set WR = 0 for two lines then set it back to 1?
    The real thing to consider, is "why do you have to even ask this question?" as it should be well documented. I suggest you get the project SCHEMATIC <you MUST have this or your project is DOOMED> and see if pertinent information is on it, such as how the SRAM you are using is interfaced into it (see http://www.keil.com/dd/docs/datashts/winbond/w77e58.pdf for your processor data sheet also) ALL of this data should be with your project data already. IE the data sheet the schematic etc should be packaged with the source code. The source code is abysmally useless without it.

    Most importantly LOOK at the schematic, LOOK at the data sheet for the RAM, that should indicate how they were addressing the SRAM. If not you should ask someone who has an idea, or find the project files and see if anything was documented. ALL of these things need to be carefully documented. You should be sure to add this data and note that it had to be searched for (you should account for the time you are using to do all this in case someone asks).

    A bit of documentation (IE 5 minutes) will save you DAYS worth of discovery by trial and error. It's VERY expensive to not document things properly.

    Stephen

Reply
  • P.S. in the k6x8008_writebyte function, why did the previous developer set WR = 0 for two lines then set it back to 1?
    The real thing to consider, is "why do you have to even ask this question?" as it should be well documented. I suggest you get the project SCHEMATIC <you MUST have this or your project is DOOMED> and see if pertinent information is on it, such as how the SRAM you are using is interfaced into it (see http://www.keil.com/dd/docs/datashts/winbond/w77e58.pdf for your processor data sheet also) ALL of this data should be with your project data already. IE the data sheet the schematic etc should be packaged with the source code. The source code is abysmally useless without it.

    Most importantly LOOK at the schematic, LOOK at the data sheet for the RAM, that should indicate how they were addressing the SRAM. If not you should ask someone who has an idea, or find the project files and see if anything was documented. ALL of these things need to be carefully documented. You should be sure to add this data and note that it had to be searched for (you should account for the time you are using to do all this in case someone asks).

    A bit of documentation (IE 5 minutes) will save you DAYS worth of discovery by trial and error. It's VERY expensive to not document things properly.

    Stephen

Children
  • as it should be well documented
    I guess that, of what I have 'inherited' over the years the status has been:
    5% "well documented" and reasonably commented
    20% documented and reasonably commented
    30% reasonably commented
    45% no documentation whatsoever

    Erik

  • Managers sees function, not the source code or all the documentation around the code.

    And they pay for a fast delivery of working code.

    The consultant who skips the documentation can offer the lowest price and fastest delivery. (And make the most money by delivering code that no other company is interested in maintaining.)

    In a world where you write your budget based on the initial costs, and ignores the total life-time costs, the buyer tends to get exactly what they are willing to pay for. And the customers does the same - buys the cheapest product. Then they get surprised/frustrated/angry when it doesn't work as well as they hoped.