• AVR Freaks

Hot!How to read status register of 25AA02E48?

Author
rbuck
Super Member
  • Total Posts : 354
  • Reward points : 0
  • Joined: 2005/04/28 12:48:11
  • Location: Phoenix, AZ
  • Status: offline
2020/07/11 19:35:47 (permalink)
0

How to read status register of 25AA02E48?

I am trying to bit bang a 25AA02E48 to read the status register. I am able to write to and read from the chip in the normal address range. I can also read the MAC address from 0xFA-0xFF. I am using a STM32 processor but my question is about the EEPROM.
 
According to the data sheet, page 10, Fig. 2-6, you just issue a hex 0x05 command and then 8 additional clock pulses to get the register contents. But I always get a return value of 0x00. I should be getting 0x04 since BP0 is factory programmed to 1.
 
My SPI input pin has an internal pull down resistor of around 50k activated. Since I am able to read from any other memory location of the EEPROM I don't understand why I can't read the status register. When the Spi_Command(uint8_t) function is called, cmd contains 0x05 which is the read status register instruction.
 
void Spi_Command(uint8_t cmd)

{
   uint8_t count, state, bit, data;

   // cmd value coming in is 0x05 to read status register
   HAL_GPIO_WritePin(SPI_CLK_GPIO_Port, SPI_CLK_Pin, 0); // make sure CLK is low
   HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, 0); // set CS low
   for(count = 0; count <8; count++) // send command
   {
      if(cmd & 0x80)
        state = 1; // set data line high
      else
        state = 0; // set data line low

      HAL_GPIO_WritePin(SPI_OUT_GPIO_Port, SPI_OUT_Pin, state); // set data line to current bit state
      HAL_GPIO_WritePin(SPI_CLK_GPIO_Port, SPI_CLK_Pin, 1); // CLK line high to send bit
      asm("NOP");
      HAL_GPIO_WritePin(SPI_CLK_GPIO_Port, SPI_CLK_Pin, 0); // CLK line back low
      cmd <<= 1; // move to next bit position
  }

  for(count = 0; count <8; count++) // read status register
  {
     HAL_GPIO_WritePin(SPI_CLK_GPIO_Port, SPI_CLK_Pin, 1); // CLK line high
     bit = HAL_GPIO_ReadPin(SPI_IN_GPIO_Port, SPI_IN_Pin); // read bit present on input pin
     data += bit; // add bit read to current data
     HAL_GPIO_WritePin(SPI_CLK_GPIO_Port, SPI_CLK_Pin, 0); // CLK line back low
     data <<= 1; // move to next bit position
  }
  HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, 1); // CS back high
  asm("NOP");
}

 
Any suggestions would be appreciated.
#1

2 Replies Related Threads

    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: How to read status register of 25AA02E48? 2020/07/11 23:07:36 (permalink)
    0
    Maybe you accidentally cleared that bit.
    Why not try exercising the WRDI and WREN commands, and see if the WEL bit in the STATUS register changes?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    rbuck
    Super Member
    • Total Posts : 354
    • Reward points : 0
    • Joined: 2005/04/28 12:48:11
    • Location: Phoenix, AZ
    • Status: offline
    Re: How to read status register of 25AA02E48? 2020/07/12 09:10:20 (permalink)
    4 (1)
    Ric, you were correct. Somehow during my initial writing of the SPI code I must have somehow cleared the bit.
    I added code to write to the status register and wrote 0x04 to it. Now when I read the register I get 0x04 back as expected.
    Thanks for the tip.
    #3
    Jump to:
    © 2020 APG vNext Commercial Version 4.5