Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SPI Flash SST25VF016B-75-4I-S2AF NO Data read detection

Status
Not open for further replies.

Rikr09

Member level 3
Joined
Feb 14, 2013
Messages
59
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,745
Hello,

I am working with a PIC24FJ128GB110 with a SPI Flash Memory (SST25VF016B-75-4I-S2AF) and i need to detect when the memory do not response any data when the microcontroller read it.

I did one test, i remove the memory and always the micro detects a zero '0', so is the same as read 0!! I did is not reliable to me because i never will detect if my memory is wrong or something like that.


I hope you can hep me with this trouble....
Thanks!
 

Hi,

what about using a 10kOhms pullup at the data line?

In general: Don´t let inputs floating.


Klaus
 

Hi,

what about using a 10kOhms pullup at the data line?

In general: Don´t let inputs floating.


Klaus


Hello Klaus, the hardware is configured as you said.

The problem is that i need to detect once i read the memory that i did not receive any data from it. Maybe, reading any register, flag or something as this.
 

How do you expect a "data read detection" to work? Doesn't sound like a well considered question.

To check existence and health of the SPI flash, you may want to read it's ID or status registers. To verify the consistency of previously written data, use a checksum or CRC.
 

How do you expect a "data read detection" to work? Doesn't sound like a well considered question.

To check existence and health of the SPI flash, you may want to read it's ID or status registers. To verify the consistency of previously written data, use a checksum or CRC.



I am sorry not to be specific. I mean: How i can detect if the memory really is sending me a data, that is to say, i need to detect that the memory send me something, whatever it sends.
 

Hi,

I did one test, i remove the memory and always the micro detects a zero '0',
If u used a pullup, how can it detect a "0"?

Klaus
 

Hi,


If u used a pullup, how can it detect a "0"?

Klaus

I'm not taking the voltage level, i just have reading the SI from the micro, is to say, the value that the reading method return me back is '0'
 

Hi,

I still don't understand...with the pullup installed it should ( or must) read back a "1" when you remove the memory, but not "0".

Klaus
 

Hi,

I still don't understand...with the pullup installed it should ( or must) read back a "1" when you remove the memory, but not "0".

Klaus

This is the method used to read the memory:
Code:
BYTE FlashRead(DWORD dwAddress)
{
    volatile BYTE Dummy;
    BYTE vSPIONSave, vData;
    WORD SPICON1Save;

    //if( vData == 0x00 || wLength == 0x00 )
    //    return;

    // Save SPI state (clock speed)
    SPICON1Save = SPIFLASH_SPICON1;
    vSPIONSave = SPI_ON_BIT;

    // Configure SPI
    SPI_ON_BIT = 0;
    SPIFLASH_SPICON1 = PROPER_SPICON1;
    SPI_ON_BIT = 1;

    // Activate chip select
    SPIFLASH_CS_IO = 0;
    ClearSPIDoneFlag();

    // Send READ opcode
    SPIFLASH_SSPBUF = READ;
    WaitForDataByte();
    Dummy = SPIFLASH_SSPBUF;

    // Send address
    SPIFLASH_SSPBUF = ((BYTE*)&dwAddress)[2];
    WaitForDataByte();
    Dummy = SPIFLASH_SSPBUF;

    SPIFLASH_SSPBUF = ((BYTE*)&dwAddress)[1];
    WaitForDataByte();
    Dummy = SPIFLASH_SSPBUF;

    SPIFLASH_SSPBUF = ((BYTE*)&dwAddress)[0];
    WaitForDataByte();
    Dummy = SPIFLASH_SSPBUF;    
    // Read data
//    while(wLength--)
//    {
        SPIFLASH_SSPBUF = 0;
        WaitForDataByte();       
        vData = SPIFLASH_SSPBUF;        
//    }
    //*vData++ = 0x00;
    // Deactivate chip select
    SPIFLASH_CS_IO = 1;

    // Restore SPI state
    SPI_ON_BIT = 0;
    SPIFLASH_SPICON1 = SPICON1Save;
    SPI_ON_BIT = vSPIONSave;
    
    return vData;
}


static inline __attribute__((__always_inline__)) void WaitForDataByte( void ){
        while ((SPIFLASH_SPITBF == 1) || (SPIFLASH_SPIRBF == 0));

}

I attached my schematic Captura.PNG
 

I'm not taking the voltage level, i just have reading the SI from the micro, is to say, the value that the reading method return me back is '0'

I would suggest posting, using CODE or SYNTAX tags, your code related to configuring, reading and writing of the SPI interface in question.

As FvM indicated, reading the STATUS register would be one of the most straight forward methods of verifying the SPI to device viability.

By default, after powerup, the STATUS register should return a value of 0x1C.


BigDog

- - - Updated - - -

Update:

Posting the SPI Read routine is a start, however the routine used to configure and initialize the SPI interface is of greater interest, without proper configuration and initialization the SPI Read and Write routines are a bit irrelevant.
 

I would suggest posting, using CODE or SYNTAX tags, your code related to configuring, reading and writing of the SPI interface in question.

As FvM indicated, reading the STATUS register would be one of the most straight forward methods of verifying the SPI to device viability.

By default, after powerup, the STATUS register should return a value of 0x1C.


BigDog

- - - Updated - - -

Update:

Posting the SPI Read routine is a start, however the routine used to configure and initialize the SPI interface is of greater interest, without proper configuration and initialization the SPI Read and Write routines are a bit irrelevant.



Thanks Big Dog... I complete the coding:

Code:
void SPIFlashInit2(void){
    BYTE i;
    volatile BYTE Dummy;
    BYTE vSPIONSave;
    WORD SPICON1Save;

    // Save SPI state (clock speed)
    SPICON1Save = SPIFLASH_SPICON1;

    vSPIONSave = SPI_ON_BIT;

    // Configure SPI
    SPI_ON_BIT = 0;
    SPIFLASH_SPICON1 = PROPER_SPICON1;
    ClearSPIDoneFlag();
    SPIFLASH_SPICON2 = 0;
    SPIFLASH_SPISTAT = 0;    // clear SPI
    SPI_ON_BIT = 1;


    // Read Device ID code to determine supported device capabilities/instructions
    {
        // Activate chip select
	SPIFLASH_CS_IO = 0;
	ClearSPIDoneFlag();
//        _SPI1BRG=1; //
	// Send instruction
	SPIFLASH_SSPBUF = RDID;
	WaitForDataByte();
	Dummy = SPIFLASH_SSPBUF;

	// Send 3 byte address (0x000000), discard Manufacture ID, get Device ID
	for( i=0;i<5;i++ ){
            SPIFLASH_SSPBUF = 0x00;
	    WaitForDataByte();
	    Dummy = SPIFLASH_SSPBUF;
	}
	// Deactivate chip select
	SPIFLASH_CS_IO = 1;

	// Decode Device Capabilities Flags from Device ID
	Device2.v = 0x00;

	switch(Dummy){
            case 0x41:  //SST25LF016B
                        Device2.bits.bWriteWordStream = 1;
                        break;
            case 0x43:	// SST25LF020(A)	(2 Mbit)	0xAF, 14us, AAI Byte
            case 0x48:	// SST25VF512(A)	(512 Kbit)	0xAF, 14us, AAI Byte
            case 0x49:	// SST25VF010A		(1 Mbit)	0xAF, 14us, AAI Byte
			Device2.bits.bWriteByteStream = 1;
			break;
            case 0x4B:	// SST25VF064C		(64 Mbit)	0x02, 1.5ms/256 byte page, no AAI
			Device2.bits.bPageProgram = 1;
			break;
            case 0x8E:	// SST25VF080B		(8 Mbit)	0xAD,  7us, AAI Word
			Device2.bits.bWriteWordStream = 1;
                        break;
	}
    }

    // Clear any pre-existing AAI write mode
    // This may occur if the PIC is reset during a write, but the Flash is
    // not tied to the same hardware reset.
    _SendCmd(WRDI);

    // Execute Enable-Write-Status-Register (EWSR) instruction
    _SendCmd(EWSR);

    // Clear Write-Protect on all memory locations
    SPIFLASH_CS_IO = 0;
    SPIFLASH_SSPBUF = WRSR;
    WaitForDataByte();
    Dummy = SPIFLASH_SSPBUF;
    SPIFLASH_SSPBUF = 0x00; // Clear all block protect bits
    WaitForDataByte();
    Dummy = SPIFLASH_SSPBUF;
    SPIFLASH_CS_IO = 1;

    // Restore SPI state
    SPI_ON_BIT = 0;
    SPIFLASH_SPICON1 = SPICON1Save;
    SPI_ON_BIT = vSPIONSave;

}

The writin code i di not attached because i remove the Memory in order to detect that no data will be received.
 

Thanks for posting the initialization code.

It appears you are utilizing the SPI1 interface, is this correct?

What is the actual value of PROPER_SPICON1, which is being loaded into SPIxCON1?


BigDog
 

Thanks for posting the initialization code.

It appears you are utilizing the SPI1 interface, is this correct?

What is the actual value of PROPER_SPICON1, which is being loaded into SPIxCON1?


BigDog

Hello BigDog,

I am using the SPI2 interface, the PIC has PPS pins.

The value of PROPER_SPICON1 is
Code:
#define PROPER_SPICON1  0x013B

On SPIxCON1, wich is SPI2CON1 is loaded de the value of PROPER_SPI1CON1. This can be seen on:

Code:
#define SPIFLASH_SPICON1	(SPI2CON1)

Thanks for your attention....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top