AnsweredAssumed Answered

K70, MQX 4.1 SPI I/O Drivers, Codewarrior CW 10.6 GCC

Question asked by Louie Moye on Aug 16, 2016
Latest reply on Aug 19, 2016 by Louie Moye

Hello,

 

I've read several posts on this forum where others are experiencing the same issue as I am having.  Unfortunately, they are working with different versions of MQX and processor.  I'm reying to use MQX 4.1 SPI IO driver on K70, to read a serial Flash part (Micron M25P20).  I believe I have everything cpnfigured properly as I am seeing exactly what I expect on the SPI bus: Setting the WEL bit to the status register, then reading the status register.  I expect 0x02, and this is what I'm seeing on the MISO line.  /CS, SCLK, MOSI, and MISO timing and data look correct, however, the read buffer always report 0x00.  I've tried _io_ioctl  without success (following).   Below is my actual read function.  Any help would be great,

 

Regards,

Louie

 

/* Test simultaneous write and read to stat reg */

  memset (send_buffer, 0, sizeof (send_buffer));

  memset (recv_buffer, 0, sizeof (recv_buffer));

  send_buffer[0] = SPI_MEMORY_READ_STATUS;

 

  rw.BUFFER_LENGTH = 1;

  rw.WRITE_BUFFER = (char *)send_buffer;

  rw.READ_BUFFER = (char *)recv_buffer;

 

 

  printf ("IO_IOCTL_SPI_READ_WRITE ... ");

  if (SPI_OK == _io_ioctl (m_spifd, IO_IOCTL_SPI_READ_WRITE, &rw))

  {

  printf ("OK\n");

  }

  else

  {

  printf ("ERROR\n");

  }

  _io_fflush (m_spifd);

 

unsigned char SerialEEPROM::ReadStatus()

{

  _mqx_int result;

  uint8_t rxVal = 0xFF;

  spiTxBuf = new unsigned char[SPI_TMP_BUF_SIZE];

  spiRxBuf = new unsigned char[SPI_TMP_BUF_SIZE];

  spiTxBuf[0] = STATUS_REG;

  result = _io_write(m_spifd, spiTxBuf, 1);

  result = _io_read(m_spifd, spiRxBuf, 1);

  _io_fflush(m_spifd);

  rxVal = spiRxBuf[0];

  delete(spiTxBuf);

  delete(spiRxBuf);

  return rxVal;

}

Outcomes