Work in Progress - Winbond Flash / Microchip SRAM driver + FemtoBasic
Mike Green
Posts: 23,101
For those interested in experimenting, here's my current working copy of FemtoBasic modified for use with TriBlade#1 and a 2MB Winbond
flash memory chip.
There's a subset VT100 terminal emulator included and tested low level support for a 2MB to 8MB Winbond flash memory chip.
You can erase 4K blocks (FERASE) and read (FREAD) data and write (FWRITE) small amounts of data to flash. The DUMP statement
works with flash as well.
There's the ability to create, open, and delete files and read and write data to files, but this is not tested yet. Once this works, the SAVE,
LOAD, FILES, and COPY statements will be implemented for flash so they look and work much like for an SD card. Have a look at the
"Winbond Driver".
Note that the source is set up for a 6MHz crystal. You can change that and recompile. It's also set up for a VGA display. I've included the
half-height 40 x 30 TV text driver modified to be able to substitute for the VGA driver including the VT100 support. I haven't tested it yet,
but it compiles and looks like it should work.
6 May 09: Corrected error in FWRITE
7 May 09: Corrected error in findFile. Added code for SAVE, LOAD, FILES ... tested & seem to work.
7 May 09: v4.005 - Corrected error in eraseFile and DELETE
9 May 09: v4.008 - Corrected errors in eraseFile, FILES, DELETE, COPY. Sped up some operations.
10 May 09: V4.009 - Corrected errors in readFile and writeFile. Now files >4K work properly.
At this point, everything flash related appears to work except the SPIN statement to load and execute Spin programs.
The Winbond Driver is designed to not use a central directory. This slows things down, but helps reduce the number of times a 4K sector has to be erased or written. Because of the way flash memory is implemented, once you write to a portion of the file, you can't write again to that portion until that 4K block is erased. The Winbond Driver is intended to provide for sequential files where you write sequentially to the file, then read the file sequentially one or more times. Next step is to finish the PASM routines so the SPIN statement will work and the whole Winbond Driver will run faster.
Post Edited (Mike Green) : 7/4/2009 5:03:53 AM GMT
flash memory chip.
There's a subset VT100 terminal emulator included and tested low level support for a 2MB to 8MB Winbond flash memory chip.
You can erase 4K blocks (FERASE) and read (FREAD) data and write (FWRITE) small amounts of data to flash. The DUMP statement
works with flash as well.
There's the ability to create, open, and delete files and read and write data to files, but this is not tested yet. Once this works, the SAVE,
LOAD, FILES, and COPY statements will be implemented for flash so they look and work much like for an SD card. Have a look at the
"Winbond Driver".
Note that the source is set up for a 6MHz crystal. You can change that and recompile. It's also set up for a VGA display. I've included the
half-height 40 x 30 TV text driver modified to be able to substitute for the VGA driver including the VT100 support. I haven't tested it yet,
but it compiles and looks like it should work.
6 May 09: Corrected error in FWRITE
7 May 09: Corrected error in findFile. Added code for SAVE, LOAD, FILES ... tested & seem to work.
7 May 09: v4.005 - Corrected error in eraseFile and DELETE
9 May 09: v4.008 - Corrected errors in eraseFile, FILES, DELETE, COPY. Sped up some operations.
10 May 09: V4.009 - Corrected errors in readFile and writeFile. Now files >4K work properly.
At this point, everything flash related appears to work except the SPIN statement to load and execute Spin programs.
The Winbond Driver is designed to not use a central directory. This slows things down, but helps reduce the number of times a 4K sector has to be erased or written. Because of the way flash memory is implemented, once you write to a portion of the file, you can't write again to that portion until that 4K block is erased. The Winbond Driver is intended to provide for sequential files where you write sequentially to the file, then read the file sequentially one or more times. Next step is to finish the PASM routines so the SPIN statement will work and the whole Winbond Driver will run faster.
Post Edited (Mike Green) : 7/4/2009 5:03:53 AM GMT
zip
173K
Comments
Right, I've been jolted out of my stupor, and am off to the shed to solder up a triblade.
Re femtobasic, sooner or later any program seems to grow bigger than the available memory. One way around that is Shell and Chain, to pass control to another program. Does femtobasic have these commands? (I must do some more research, it sounds intriguing).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index)
· Search the Propeller forums (via Google)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
FemtoBasic also has the ability to run a new Spin/PASM program using the SPIN statement. Parallax used FemtoBasic for a kiosk for Propeller demo programs that would let you choose a demo from a menu, then execute it. The demo would do a reboot when it finished, restarting FemtoBasic.
I want to become more like Mike when I grow up . I am sure Mike's patients appreciate his approach as well.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
This driver also supports the Microchip 23K256 32K byte SRAM. It allows for up to 2 SRAM chips for a total of 64K. The included version of FemtoBasic is used for development and testing of this driver and has statements for low level access to the flash memory and SRAM. You can save Basic programs to the flash and can use the COPY and SPIN statements to handle Spin programs the same way you'd use an SD card. The only limitation is that you can't replace (overwrite) a file. You have to delete it first, then recreate it. This is a limitation of the flash memory, something the SD card internal controller takes care of.
Added a comment to FemtoBasic.spin describing the connections for the Flash and SRAM memories.
Corrected use of "dev" in Winbond_Driver.spin. Not allowed under Propeller Tool 1.2.6. Works with BradC's BST.
I think I've really corrected it this time. Sorry.
Post Edited (Mike Green) : 5/26/2009 2:54:16 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
My sample devices include:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔FM24L256-G
FM24C512-G
FM25V10
JMH
Module: WinBond Driver
Routine: PRI sendRecv(dev, sD, rCt, rA) | i, m ' Send and possibly receive
..................................^^^ Error cursor at dev
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
There's some kind of new error in the Propeller Tool 1.2.6 with the use of "dev". It compiles fine with BradC's compiler. Try replacing the 3 uses of "dev" with "d" and recompiling. It should work.
All 3 FRAM devices you mentioned are I2C devices as I recall and they should work fine with the existing I2C drivers as direct replacements for ordinary EEPROM. Some of them are 5V-only devices and you'd need some kind of voltage interface (3.3V to 5V for SCL and SDA). Usually just a 1K series resistor will work.
Now _that_ is interesting. Sounds like the compiler is being updated and they are adding a new block type to it.. time to get out the disassembler again [noparse];)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"VOOM"?!? Mate, this bird wouldn't "voom" if you put four million volts through it! 'E's bleedin' demised!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propalyzer: Propeller PC Logic Analyzer
http://forums.parallax.com/showthread.php?p=788230
Oh, in which case I won't bother. Perhaps its a reserved word we did not know about.
I guess I should make it a reserved word in my compiler to save the incompatibility. Is it documented anywhere?
<edit>
Nyaaaahaaa.. further investigation shows it to be used in constructs similar to this
DEV ARCHIVE "FILENAME"
DEV PRECOMPILE "FILENAME"
I was wondering what those two directives were.. now I need to see if they are actually hooked up in the compiler or just remnants. My gut feeling is they provide some sort of interface between the compiler and the IDE. In any case, I won't hijack Mikes thread any further [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"VOOM"?!? Mate, this bird wouldn't "voom" if you put four million volts through it! 'E's bleedin' demised!
Post Edited (BradC) : 5/25/2009 9:54:15 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propalyzer: Propeller PC Logic Analyzer
http://forums.parallax.com/showthread.php?p=788230
This correction does not appear in my freshly downloaded version. Still uses "dev".
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
Change all the instances of "dev" to something else. Dev is a reserved word (a block) in the Parallax compiler.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"VOOM"?!? Mate, this bird wouldn't "voom" if you put four million volts through it! 'E's bleedin' demised!
I have done so yesterday. This was meant to inform Mike that he still needs to change the source for the unsuspecting.
He states that he corrected this, but the code remains the same.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
Thanks for the updated code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
Next step is to modify "createFile" so it will erase any existing copy of the specified file. This will make it work more like an SD card.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
The size of the chip is read correctly but I can't write to the chip (either that or I can't read from the chip).· Here's the code.
The DO, /WP, DIO, and /Hold pins all have 10K pullup resistors.
What am I doing wrong?
I don't post often but I'm a fequent reading of this forum.· Most of my questions have already been asked and answered here.· Thanks for all of your help.
Duane Degn