SPI Memory, 25LC1024 and SPI Component

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

SPI Memory, 25LC1024 and SPI Component

Post by Mark »

I am trying to interface SPI Memory, 25LC1024 using Flowcode, but have not had any success, despite reading the literature and checking the connections.

Taking one step at a time, could anyone post a flowcode routine (two address byte SPI EEPROM) that they know works? (or one in C), using the SPI component or otherwise so I can test hardware.

The command bytes seem correct in the Flowcode SPI component when reading the underlying C code, however I cannot get it to work, trouble is it could also be a hardware issue.

The SPI Memory, 25LC1024 uses a Two Byte address, can run up to 20MHz (anything will do for now), is available as a P-DIP package and has 128k of memory, so should be quite useful.
For info it takes 6ms to program but can take 256 bytes at full speed (e.g. from a periodically downloaded array as I intend) which should only take 0.1ms.
I have pulled write protect and hold to 5v by 10k resistors and CS is at ground. Clk goes to Clk, SDO to SDI and SDO to SDI.

Code for any mainstream chip will do, but 16f887, 16f877 preferred.

Thanks in advance.
Go with the Flow.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI Memory, 25LC1024 and SPI Component

Post by Benj »

Hello,

It could be your chip select line at fault. A lot of SPI devices need the chip select to be high when not in use, then pulled low when you are performing a transaction and then pulled high again to signify the end of the transaction. Could you post up your current program and i will see if I can spot any potential problems.

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Re: SPI Memory, 25LC1024 and SPI Component

Post by Mark »

Ben,

Thanks, the test is about as simple as I can make it.
CS no longer tied to ground - thanks for the tip.

Uses an 16F887 on the HP-488 Board.
CS on RC0/Connector Pin1
CLK on RC3 (SCK) Connector Pin4
CHIP SO on RC4 (SDI) Connector Pin5
CHIP SI on RC5 (SDO) ConnectorPin 6

Program:-
Initialise - Print Data variable
Read Data - Print data variable
Write - New data byte
Read Data - Print data variable

Outputs 0,0,255 on first run after power up
Outputs 0,255,255. subsequent reset
Remove clock pin connection Outputs 0,0,0
Reconnect clock with no power up Outputs 0,255,255

16F887 SPI Memory Test on HP488 PortC.fcf
(7 KiB) Downloaded 337 times
Go with the Flow.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI Memory, 25LC1024 and SPI Component

Post by Benj »

Hello,

Ok I've had a quick play with your program and have written macros which should perform the byte read and byte write operations. Hopefully this should work correctly on the hardware. There are other commands to do page read and page write so you could implement these by referring to the current commands and strings rather then bytes for the data.
Attachments
16F887 SPI Memory Test on HP488 PortC.fcf
(10 KiB) Downloaded 326 times

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Re: SPI Memory, 25LC1024 and SPI Component

Post by Mark »

Hi Ben,

Many thanks, the chip is now being written to and can be read.

Two mods to the framework you provided were needed:

1) 'Input samples at end of data output time' option required in SPI Component.
2) Need to write '0x06' to chip to enable write.

The working code is attached.

For anyone interested useful references are:
Microchip Application note AN1006 (AN909 is of limited use).
http://ww1.microchip.com/downloads/en/A ... 01006a.pdf
Microchip document SPI 'Overview and use of the PICMicro Peripheral Interface'.
http://ww1.microchip.com/downloads/en/devicedoc/spi.pdf
The Wikipedia page is also worth a look
http://en.wikipedia.org/wiki/Serial_Per ... erface_Bus
Attachments
16F887 SPI Memory Test of Ben - Modified.fcf
(11 KiB) Downloaded 330 times
Go with the Flow.

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Re: SPI Memory, 25LC1024 and SPI Component

Post by Mark »

Hi Ben,

I have pulled together a suite of 10, tested, subroutines to utilise the functions of the
25LC1024 Chip. The attached code should be self explanatory. It includes the Macros:

Enable Write
Disable Write
Read
Write - With 6ms delay
Write - With polling to see end of write
Read Status
Write Status
Sleep
Wake
Chip Erase

The block write is a simple extension of write and depends upon how large the user block is, so is not included.
Similary, for many users the Block Protect effect can be achieved simply by Disable Write.
The page and sector erase seem niche so I have just written chip erase.

Hopefully the code may be useful to other users of the Forum.

I suggest downloading the test routine, exporting the Macro's wanted and then importing them to where they are to be used.
The Macro's are NOT interlinked, they can all be used in isolation.
SPI Memory Routines.fcf
(24.64 KiB) Downloaded 366 times
Go with the Flow.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI Memory, 25LC1024 and SPI Component

Post by Benj »

Hi Mark,

That's great, thanks for sharing the working macros for the device. Glad its all working correctly for you now.

Post Reply