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
  • "TRANSMISSION.C(146): error C249: 'DATA': SEGMENT TOO LARGE

    this dissapears when i comment out unsigned char Packet[PACKET_SIZE] any ideas?"

    The message says that the DATA segment is too large.
    What do you think might be the maximum size for the DATA segment...?

    Are you familiar with the 8051's DATA, IDATA, XDATA, etc memory areas?

    How big do you think unsigned char Packet[PACKET_SIZE] is going to be?
    Will it fit into DATA...?

    If it doesn't, what could you do?

Reply
  • "TRANSMISSION.C(146): error C249: 'DATA': SEGMENT TOO LARGE

    this dissapears when i comment out unsigned char Packet[PACKET_SIZE] any ideas?"

    The message says that the DATA segment is too large.
    What do you think might be the maximum size for the DATA segment...?

    Are you familiar with the 8051's DATA, IDATA, XDATA, etc memory areas?

    How big do you think unsigned char Packet[PACKET_SIZE] is going to be?
    Will it fit into DATA...?

    If it doesn't, what could you do?

Children
  • no i have not come across data segments before. i have did a little research and have changed output options to LARGE:Variables in XDATA.......and i have raised the PACKET_SIZE to 3000...enough to store approx 3 hours of data. The error has now gone....problem solved???

  • no i have not come across data segments before.
    If you want success, you need to get more familiar with the processor and the tools before forging on.

    have changed output options to LARGE:Variables in XDATA.......and i have raised the PACKET_SIZE to 3000...enough to store approx 3 hours of data. The error has now gone....problem solved???

    sure, but the right way? at the same time, you have, probably slowed the execution speed by 2 times or more.

    Revert to SMALL and uniquely qualify your array to xdata.

    Using LARGE can cost execution penalties of great magnitude and, typically will increase your code size by a large amount.

    Code a for loop moving something to your array and look at the generated assembler for SMALL and LARGE

    Erik