FRDM-KL25Z Can't Communicate with SPI

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

FRDM-KL25Z Can't Communicate with SPI

764 Views
bhavinmaru
Contributor III

Hello,
I am working with FRDM-KL25Z EVM.with this controller i interfaced M95M02-DR EEPROM using SPI communication.As per datasheet of this EEPROM to write in EEPROM first we have to send WREN(Write Enable) command so i send this command and i also attached waveform of this in Figure_1.jpg(in attachment).


Then i follow the waveform given in datasheet of this EEPROM for writting and its waveform is given in Figure_2.jpg(in attachment).

 

After writting data in address i read the data from same address but i am not getting the data which i have written instead i am getting 0x00 only.Detailed read cycle's waveform is given in Figure_3.jpg(in attachment).


By observing waveform of read cycle i see that in MISO pin i am getting data which i was written but in SPI0_D(SPI Data Register) i am not getting data which i see in MISO pin's waveform.so why SPI0_D register not getting update value?

 

As per the Oscilloscope waveform's observation all the waveforms are correct as per the datasheet of EEPROM.i also attached my code for your reference.

 

Please help me so that i can read data from EEPROM.Any help in this will be appreciated more.

 

Thank You
Bhavin

Original Attachment has been moved to: Code_and_Waveforms.zip

Labels (1)
0 Kudos
3 Replies

562 Views
mjbcswitzerland
Specialist V

Hi

Download the uTasker project and copy its SPI Flash/EEPROM driver interface for the FRDM-KL25Z (plus FRDM-FXS-MULTI-B extension). It supports about 6 such chips on the SPIs and also simulates them in case you want to accelerate your work.

Otherwise just compare the SPI interface macros since it is important to correctly clear flags and data - before doing anything with the interface do:

(void)SPIx_S;
(void)SPIx_D;

to ensure that the status and data registers are initially synchronised.

Regards

Mark

FRDM-KL25Z: http://www.utasker.com/kinetis/FRDM-KL25Z.html

0 Kudos

562 Views
bhavinmaru
Contributor III

Thank You for your reply by observing my attached code and waveforms can you tell me why i can't read data from EEPROM?

0 Kudos

562 Views
mjbcswitzerland
Specialist V

Hi

I looked at the code briefly and see that you are not clearing the data register after you have send data (this means that you have old reception values there and the receiver is over-running so data is getting lost).

This means that your concept is presently wrong for data reception.

A quick fix would be to do the following but I still advice you to compare with proven code at the link. Also you are using some software time delays which are not needed and not advisable (they are possibly working around other conceptional errors).

uint8 eeprom_read(uint32 address)
{
    uint8 upper_addr,middle_addr,lower_addr;
    
    upper_addr = (address >> 16);    
    middle_addr = (address >> 8);    
    lower_addr = address;
    
    CS_LOW;
    spi_send(READ);              // Send Read command    
    
    spi_send(upper_addr);
    spi_send(middle_addr);
    spi_send(lower_addr);
    
// dummy read of data register to clear old values
// wait for rx flag to be set
// dummy read of data register to clear last value
    spi_send(0x76);             //Send Dummy data        
     
    data = spi_read();
               
    my_delay();
    CS_HIGH;
    
    return data;
}

Regards

Mark

0 Kudos