Changeset a6ae6ac in avrstuff for EPRoxygen/at29c040.cpp


Ignore:
Timestamp:
Jul 9, 2012, 11:05:43 PM (12 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
16cf6ff
Parents:
34c57e8
Message:

Still not working...
Added very agressive timing, fixed some potential glitches, but still not enough to even read the device ID !

git-svn-id: svn://pulkomandy.tk/avrstuff@60 c6672c3c-f6b6-47f9-9001-1fd6b12fecbe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EPRoxygen/at29c040.cpp

    r34c57e8 ra6ae6ac  
    1414        Device::write(CTRL, 0b10011111 | CTRLmask);
    1515        Device::write(VOLT, 0b11001000 | VOLTmask);
     16        outb(port + 2, NONE);
    1617}
    1718
     
    2021        // All pins of the ROM are put either in high-Z, or 0V when it's not
    2122        // possible
    22         Device::write(CTRL, 0x62);
    23         Device::write(VOLT, 0x7F);
     23        Device::write(CTRL, 0b01100010);
     24        Device::write(VOLT, 0b01111111);
    2425        outb(port + 2, NONE);
    2526}
     
    5152{
    5253        // Chip enable
    53         Device::write(CTRL, CTRLmask | CE);
     54        Device::write(CTRL, CTRLmask | WE | OE | CE | A17);
    5455                // Address bits low, WE = 1, CE = 0, OE = 1
    5556                // TC and TD = 1
     
    6061
    6162        wr16(0x5555, 0xAA);
    62         wr16(0x2AAA, 0x55);
     63        wr16(0xAAAA, 0x55);
    6364        wr16(0x5555, 0x90);
    6465
     
    7071        // Read the result now
    7172        Device::write(ADR0, 0x00);
    72         Device::write(ADR1, 0x00);
    73         Device::write(CTRL, WE | CE | CTRLmask);
     73                        usleep(1000);
     74        Device::write(ADR1, 0x00 ^ A13);
     75                        usleep(1000);
     76        Device::write(CTRL, WE | A17 | CTRLmask);
     77                        usleep(1000);
    7478        uint8_t manufacturer = Device::read();
    7579
    76         getchar();
    7780
    78         Device::write(CTRL, OE | WE | CE | CTRLmask);
     81        Device::write(CTRL, CE | OE | WE | A17 | CTRLmask);
     82                        usleep(1000);
    7983        Device::write(ADR0, 0x01);
    80         Device::write(CTRL, WE | CE | CTRLmask);
     84                        usleep(1000);
     85        Device::write(CTRL, WE | A17 | CTRLmask);
     86                        usleep(1000);
    8187
    8288        uint8_t product = Device::read();
    8389
     90        Device::write(CTRL, CE | WE | OE | A17 | CTRLmask);
     91                        usleep(1000);
    8492        // re enable DOE, we are going to write again...
    85         Device::write(CTRL, WE | OE | CE | CTRLmask);
    8693        Device::write(VOLT, VOLTmask);
     94                        usleep(1000);
    8795
    8896        wr16(0x5555, 0xAA);
    89         wr16(0x2AAA, 0x55);
     97        wr16(0xAAAA, 0x55);
    9098        wr16(0x5555, 0xF0);
    9199        usleep(10000);
     
    93101        // Chip disable - we're done !
    94102        Device::write(CTRL, 0xFF | CTRLmask);
     103                        usleep(1000);
    95104       
    96105        bool ok = (manufacturer == 0x1F && product == 0xA4);
Note: See TracChangeset for help on using the changeset viewer.