SPI example is not working

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

SPI example is not working

1,160 Views
yadhukrishnanvm
Contributor III

hi,

SPI example in the mqx folder is not working in my TWR-K65F180M. I think there is no EEPROM in my board that is why the example is not working.When I run the example it runs as below I don't know why is this happening. Anybody please help me...


-------------- SPI driver example --------------

This example application demonstrates usage of SPI driver.
It transfers data to/from external memory over SPI bus.
The default settings in memory.h apply to TWR-MEM flash memory.
Current baud rate ... 10000000 Hz
Changing the baud rate to 500000 Hz ... OK
Current baud rate ... 468750 Hz
Setting clock mode to SPI_CLK_POL_PHA_MODE0 ... OK
Getting clock mode ... SPI_CLK_POL_PHA_MODE0
Setting endian to SPI_DEVICE_BIG_ENDIAN ... OK
Getting endian ... SPI_DEVICE_BIG_ENDIAN
Setting transfer mode to SPI_DEVICE_MASTER_MODE ... OK
Getting transfer mode ... SPI_DEVICE_MASTER_MODE
Clearing statistics ... OK
Getting statistics:
Rx packets: 0
Tx packets: 0

Read memory status ... 0xff
Enable write latch in memory ... OK
Read memory status ... 0xff
Write unprotect memory ... OK
Enable write latch in memory ... OK
Read memory status ... 0xff
Write unprotect memory ... OK
Enable write latch in memory ... OK
Read memory status ... 0xff
Erase whole memory chip:
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff
Read memory status ... 0xff

............................................

............................................

0 Kudos
7 Replies

817 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi

In folder spi, C:\Freescale\Freescale_MQX_4_2\mqx\examples\spi

The application example creates one task for spi master, which is responsible for configuring the SPI protocol, erasing memory in memory board and reading data from and writing data to the memory board. The MCU is the master and the SPI serial flash memory is the slave in the SPI data transfer.

For each example is also included Readme file, which desribed the example.

According to the readme file, the MCU board and the memory board are connected via the 4-wire SPI connection. The SPI_CLK, SPI_DOUT, SPI_DIN,SPI_CS pins are used.

Regards

Daniel

0 Kudos

817 Views
yadhukrishnanvm
Contributor III

Hi danielchen@fsl,

I understand what you said, but my spi example code show an error.Reading the byte is showing an error I couldn't find out the error.

please help me.


-------------- SPI driver example --------------

This example application demonstrates usage of SPI driver.
It transfers data to/from external memory over SPI bus.
The default settings in memory.h apply to TWR-MEM flash memory.
Current baud rate ... 9600000 Hz
Changing the baud rate to 500000 Hz ... OK
Current baud rate ... 500000 Hz
Setting clock mode to SPI_CLK_POL_PHA_MODE0 ... OK
Getting clock mode ... SPI_CLK_POL_PHA_MODE0
Setting endian to SPI_DEVICE_BIG_ENDIAN ... OK
Getting endian ... SPI_DEVICE_BIG_ENDIAN
Setting transfer mode to SPI_DEVICE_MASTER_MODE ... OK
Getting transfer mode ... SPI_DEVICE_MASTER_MODE
Clearing statistics ... OK
Getting statistics:
Rx packets: 0
Tx packets: 0

Read memory status ... 0x00
Enable write latch in memory ... OK
Read memory status ... 0x00
Write unprotect memory ... OK
Enable write latch in memory ... OK
Read memory status ... 0x00
Write unprotect memory ... OK
Enable write latch in memory ... OK
Read memory status ... 0x00
Erase whole memory chip:
Read memory status ... 0x00
Erase chip ... OK

Enable write latch in memory ... OK
Read memory status ... 0x00
Write byte 0xba to location 0x000000f0 in memory ... done
Read memory status ... 0x00
Read byte from location 0x000000f0 in memory ... 0x00
Byte test ... ERROR
Getting statistics:
Rx packets: 8
Tx packets: 25

IO_IOCTL_SPI_READ_WRITE ... OK
Simultaneous write and read - memory read from 0x000000f0 (10):
Write: 0x03 0x00 0x00 0xf0 0x00 0x00 0x00 0x00 0x00 0x00
Read : 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Simultaneous read/write (data == 0x00) ... ERROR


-------------- End of example --------------

0 Kudos

817 Views
danielchen
NXP TechSupport
NXP TechSupport

Please check the TWR-MEM User's Manual for more details.

http://www.nxp.com/files/32bit/doc/user_guide/TWRMEMUM.pdf?fasp=1&WT_TYPE=Users%20Guides&WT_VENDOR=F... 

Regards

Daniel

817 Views
yadhukrishnanvm
Contributor III

Hi danielchen@fsl

 Now I am working with my k60n512 cusom board. It has W25Q64FV spi flash.Here also I am getting the same read error. Could you please tell me what are the possible problems for this situations. Also If you could please tell me the solutions. I am asking you all these because I am new to embedded world.Excuse me for my silly questions. :smileyhappy:

0 Kudos

817 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Yadhukrishnan:

Did you solve this issue with TWR-K65F180 ?

I noticed you opened another thread  for K60n512 Unknown error in spi example , I answered your question in that thread.

K60n512 is a very old chip, are you sure you will use it in your products?

Regards

Daniel

0 Kudos

817 Views
yadhukrishnanvm
Contributor III

Hi danielchen@fsl‌,

Ofcourse I am using K60N512 in the product.Yes I openen another thread because I didn't got a reply from this.

0 Kudos

817 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi

I think you need to check the jumper settings in your TWR-MEM board.

J4:  Serial Flash Configuration options 1-2

J14:  Serial Flash Chip-select  1-2

Please see my console output. I tested with TWR-K65F180M and TWR-MEM board

pastedImage_1.png

Regards

Daniel

0 Kudos