SPI->EEPROM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI->EEPROM

664 Views
josephchen
Contributor III

I'm using MQX 4.1.1 and trying to connect to a SPI EEPROM by MK63 MCU. The part number of EEPROM I'm using is CAT25512HU5I−GT3. I use the spi example, but everytime I get wrong data when I try to read from EEPROM. I have detect the signals by oscilloscope. For the writing, it shows exactly what I transfer. However, when I read, it shows one-byte READ instruction with 16-bit address, but it always has an extra byte 0xFF sent out after the three bytes. Is it possible to be the problem in its driver?

0 Kudos
3 Replies

494 Views
soledad
NXP Employee
NXP Employee

Hi Joseph,

Are you using a Freescale board???

Which BSP are you using???


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

494 Views
josephchen
Contributor III

My callback function :

static _mqx_int set_CS (uint32_t cs_mask, void *user_data)

{

LWGPIO_STRUCT_PTR spigpio = (LWGPIO_STRUCT_PTR)user_data;

static boolean chip_selected = FALSE;

if (cs_mask)

{

      if (!chip_selected)

      {

           if (cs_mask & SPI_EEPROM_CS)

           {

                if (lwgpio_get_value(spigpio) == LWGPIO_VALUE_HIGH)

                {

                     lwgpio_set_value(spigpio, LWGPIO_VALUE_LOW);

                     _dspi_time_delay(5);

                }

                lwgpio_set_value(spigpio, LWGPIO_VALUE_HIGH);

                _dspi_time_delay(5);

           }

           else /* IOExpander “ispi1 :1:” */

           {

                if (lwgpio_get_value(spigpio) == LWGPIO_VALUE_LOW)

                {

                     lwgpio_set_value(spigpio, LWGPIO_VALUE_HIGH);

                     _dspi_time_delay(5);

                }

                lwgpio_set_value(spigpio, LWGPIO_VALUE_LOW);

                _dspi_time_delay(5);

           }

           chip_selected = TRUE;

         }

     }

      else

      {

           chip_selected = FALSE;

           _dspi_time_delay(5);

           lwgpio_toggle_value(spigpio);

     }

      return MQX_OK;

}

As you can see, I specially add 5 us delay between CS and SCLK.

0 Kudos

494 Views
josephchen
Contributor III

I'm actually using a customized board with K63 MCU and a SPI EEPROM connected. There's another IOExpander connected via same SPI channel, and they share the same SS line. Therefore,  there's a NOT gate added to the SS line between MCU and EEPROM. I have set the CS to GPIO and select the device by a callback function.The BSP is modified from K61 BSP, and I'm pretty sure the BSP is set correctly. I also have the same customized board but with K61 MCU, and it encounters the same problem.

0 Kudos