0
\$\begingroup\$

I am trying to read the status register for the EEPROM following the instructions in this Application Note. I wanted to have the opinion of the community on the signals I am getting. They don't seem normal to me.

http://ww1.microchip.com/downloads/en/AppNotes/01073A.pdf

Wiring Diagram: I am using the exact same pinout recommended in the Application Note.

When I read MISO, I get a strange behavior. Output of the EEPROM

MOSI and CS Signals:

I get the MOSI signal as expected on rising edge. Input to the EEPROM

Chip Select sync with Clock

I setup the clock to tick @1MHz

SPI Initialization code, and running code in my main.c. (from eewiki, adapted to my needs)

#define eepromCS LATBbits.LATB15
void initSPI(void)
{
// Add GPIO config on pin RB15
eepromCS = 1; //GND


IEC0bits.SPI1EIE = 0;
IEC0bits.SPI1RXIE = 0;
IEC0bits.SPI1TXIE = 0;


SPI2CONbits.ON = 0;

SPI2BUF = 0;

SPI2BRG = 0; // 1MHZ

SPI2STATbits.SPIROV = 0;

/* SPI2CON Settings */
SPI2CONbits.FRMEN = 0;
SPI2CONbits.SIDL = 0;
SPI2CONbits.DISSDO = 0;

// 8 bits !
SPI2CONbits.MODE16 = 0;
SPI2CONbits.MODE32 = 0;

SPI2CONbits.CKP = 0; // Active state is high
SPI2CONbits.CKE = 0; // sampling from idle to active
SPI2CONbits.SSEN = 0;
SPI2CONbits.MSTEN = 1;
SPI2CONbits.SMP = 0; // sample during transmission

SPI2CONbits.ON = 1;
}

int main(void)
{
TRISBbits.TRISB15 = 0;
CSEEPROM = 1; 


initSPI(); //EEPROM as a slave
unsigned char status;
unsigned char tmp;

//First READ
while (!SPI2STATbits.SPITBE);
eepromCS = 0;
SPI2BUF = 0x05;
while (!SPI2STATbits.SPIRBF);
status = SPI2BUF;
SPI2BUF = 0;
while (!SPI2STATbits.SPIRBF);
status = SPI2BUF;
eepromCS = 1;
write_char(status);


//Enable write LATCH
while (!SPI2STATbits.SPITBE);
eepromCS = 0;
SPI2BUF = 0x06;
while (!SPI2STATbits.SPIRBF);
tmp = SPI2BUF;
eepromCS = 1;


//Read Status register
while (!SPI2STATbits.SPITBE);
eepromCS = 0;
SPI2BUF = 0x05;
while (!SPI2STATbits.SPIRBF);
status = SPI2BUF;
SPI2BUF = 0;
while (!SPI2STATbits.SPIRBF);
status = SPI2BUF;
eepromCS = 1;
//write_char(status);

while (42);
return 0;
}

I did screenshots only for the last two operations (write latch enable, and read from status register). I have exactly the same signals when I read the status register before I send the write latch command.

I am using PIC32MX Olimex prototyping board, Below the protoboard documentation and EEPROM datasheet.

https://www.olimex.com/Products/PIC/Proto/PIC-32MX/resources/PIC-32MX.pdf http://ww1.microchip.com/downloads/en/DeviceDoc/22064B.pdf

As usual the devil is in the details, it would be great if I could have a new look on my issue. Maybe I missed something.

Thank you for your help !

PS: increasing the baud to match 20MHz makes the signal flat but doesn't solve my issue.

\$\endgroup\$
0
\$\begingroup\$

It doesn't look like anything code-related. It looks like either a pin shorted to another output pin which is set to zero ( or another slave not tri-stating its MISO ). Disconnect the memory chip, set PIC MISO to output and try to toggle it by writing 1 and 0 to the corresponding port bit.

Another suspect is power supply to the memory chip. Make sure it receives VCC and has a capacitor from VCC to ground.

\$\endgroup\$
  • \$\begingroup\$ Thank you for your answer. I did try your solutions, and it doesn't work. I did some tests with the multimeter and I discovered something horrifying. Current doesn't flow into the EEPROM. I actually have 2, I hope I didn't short circuited them both. I have a generator with 5V and I am testing current with a multimeter. It stays @ 0 microA Any clue as to how I could debug it ? I tried other circuits too, and I am getting the same result \$\endgroup\$ – Mehdi Sabwat Aug 16 '18 at 18:05
  • \$\begingroup\$ If the chip is not damaged, you won't be able to see current into this chip with a multimeter. Did you try to toggle MISO as suggested? \$\endgroup\$ – Oleg Mazurov Aug 16 '18 at 21:55
  • \$\begingroup\$ I tried to enable RG7 as suggested and I get the right ouput line. I even tried to change the prototyping board, and nothing happens. It must be something small. I have to start everything from the beginning \$\endgroup\$ – Mehdi Sabwat Aug 17 '18 at 14:24
  • \$\begingroup\$ I would like to point out that I was trying to get the operating current in the multimeter, I don't understand why I would not be able to see current ? In the datasheet it says that in Standby mode, I would get between 12 and 20 microA imgur.com/a/bu4lNd8 – \$\endgroup\$ – Mehdi Sabwat Aug 17 '18 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.