Problem with 9S12C32 SPI input

Started by Maria A. Lobo September 15, 2005


Hello all ,

We are having a problem with SPI read from an external EEPROM

We are using the SPI in polling mode .

What is needed is a write to EEPROM at a single address . and then at some other point read back the data from that address.
The EEPROM used is AT 25160A .

What happens here is that the write is successful and the data when read back from the same address appears on the SO line (MISO pin of controller )but the value received in the SPI data register is FF .

Any help would be much appreciated .

The sequence of the read is as follows ...

Send the read command followed by address ( This part is OK)

Make the CS pin of EEPROM low

Write a dummy byte to the SPI data register to start the SPI

SPI0_DR = 0;
// Wait for data transfer to complete Done using SPIF bit check .

while ( ( SPI0_SR & SPISR_SPIF ) == 0 )
{
feed_cop( );
}

Deleselect the EEPROM chip
// Read the value returned in the SPI data register

returned_value = SPI0_DR;

(void)SPI0_SR; // clear status register
(void)SPI0_DR; // Clear data register
Thanks
Maria


I'm not sure if you wrote this out of order or whether this is where your error is

Send the read command followed by address ( This part is OK)
Make the CS pin of EEPROM low

Shouldn't the cs be low and then send command and address?
Steve

Steven D. Letkeman BSc.
President - Zanthic Technologies Inc.
403-526-8318
www.zanthic.com Embedded micro-controllers and CAN interfaces
www.brightan.com Automated lighting systems

----- Original Message -----
From: Maria A. Lobo
To: 68HC12@68HC...
Sent: Thursday, September 15, 2005 7:07 AM
Subject: [68HC12] Problem with 9S12C32 SPI input

Hello all ,

We are having a problem with SPI read from an external EEPROM

We are using the SPI in polling mode .

What is needed is a write to EEPROM at a single address . and then at some other point read back the data from that address.
The EEPROM used is AT 25160A .

What happens here is that the write is successful and the data when read back from the same address appears on the SO line (MISO pin of controller )but the value received in the SPI data register is FF .

Any help would be much appreciated .

The sequence of the read is as follows ...

Send the read command followed by address ( This part is OK)

Make the CS pin of EEPROM low

Write a dummy byte to the SPI data register to start the SPI

SPI0_DR = 0;
// Wait for data transfer to complete Done using SPIF bit check .

while ( ( SPI0_SR & SPISR_SPIF ) == 0 )
{
feed_cop( );
}

Deleselect the EEPROM chip
// Read the value returned in the SPI data register

returned_value = SPI0_DR;

(void)SPI0_SR; // clear status register
(void)SPI0_DR; // Clear data register
Thanks
Maria

------
YAHOO! GROUPS LINKS

a.. ------