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

code explaination

Hi can anyone tell me the basics of what this code is doing? I know it is writing to eeprom but is it writing a byte at a time and incrimenting the address?

EECSN is the eeprom pin.


#define EE_WRSR     0x01
#define EE_WRITE    0x02
#define EE_READ     0x03
#define EE_WRDI     0x04
#define EE_RDSR     0x05
#define EE_WREN     0x06

void EEWrite(unsigned int addr, unsigned char b)
{
    while((EEStatus() & 0x01) != 0x00)      // Wait if busy
        ;
    EECSN = 0;
    SPI_ReadWrite(EE_WREN);
    EECSN = 1;
    EECSN = 0;
    SPI_ReadWrite(EE_WRITE);
    SPI_ReadWrite(addr >> 8);
    SPI_ReadWrite(addr & 0xff);
    SPI_ReadWrite(b);
    EECSN = 1;

}

thank you all.

Parents
  • "now its getting complicated!"

    Not really, you simply select the C51 memory model to match the capabilities of your target device along with how you have designed and written your code. Your particular needs for packet byte buffering may very well fit in the 8051's DATA space.

    You control the memory model settings using the GUI and/or command line and/or pragma (all means are explained in the toolchain guides and manuals), but in any case, the memory model has no bearing on the external EEPROM since that (presumably) uses a serial interface.

Reply
  • "now its getting complicated!"

    Not really, you simply select the C51 memory model to match the capabilities of your target device along with how you have designed and written your code. Your particular needs for packet byte buffering may very well fit in the 8051's DATA space.

    You control the memory model settings using the GUI and/or command line and/or pragma (all means are explained in the toolchain guides and manuals), but in any case, the memory model has no bearing on the external EEPROM since that (presumably) uses a serial interface.

Children
No data