Hi, I’m trying to initialize the SPI2 Module for my Fez Cerb to interface with a Serial Flash Device “SST25VF010A”, I’m already using SPI1 successfully for interfacing a custom led driver IC. The error message I keep seeing says “An unhandled exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll”, this doesn’t give me much to go on though, any ideas would be great.
private SPI MySPI;
private SPI.Configuration DeviceConfig;
public Flash()
{
DeviceConfig = new SPI.Configuration(Gadgeteer.Socket.GetSocket(8, false, null, null).CpuPins[6], false, 1, 1, false, true, 20000, SPI.SPI_module.SPI2);
MySPI = new SPI(DeviceConfig);
}
Thanks for your response, I don’t think I can do this, it is a custom PCB that I have, the Flash IC is on the same PCB and it’s “Serial In” pin is hardwired to PB15, the MOSI line for SPI1 is PB5, I guess this was a mistake in the design, I’ll probably have to interface with this IC without using the built-in SPI Module, are there any examples of this that I could use by any chance?
@ andre - I already use SPI1 to interface 4 Led driver ICs, my problem now it that the Flash IC is not physically connected in any way to SPI1 pins so I’ll need to find another solution.
@ chillydk147 - What about MISO and clock lines, are they properly wired to corresponding SPI1 pins?
Can you do a “jumper” wire to PB5 and cut the line to the PB15? Does the Flash chip supports other interfaces?
@ architech - For some background, this PCB is used in a product which I’m have been selling for the past few months, I’ve never used the flash IC and think it may be useful for the software which I’m upgrading, I’ve already had 100 PCBs manufactured with this design, if the only solution is to use jumper wires then I’ll do with using the flash IC. I’m hoping of coarse that it’s possible to come up with some custom code which could somehow interface with the flash IC like SPI1 module does.
If you brave enough you can try to compile the firmware and enable SPI2. GHI provides consulting services as well. May be they can do something about it for a fee.
@ Architech - Just doing some further reading, there is 1MB of Flash on the MCU, I only need to store a few KB, is it possible to use some area of this internal Flash for data storage?
@ Architech - Looks interesting although I’m unable to get the code to run in a debug environment, my MCU has 4.3 SDK loaded whereas the namespace “GHI.OSHW.Hardware” is a 4.2 SDK library, is this the only example or are there any for 4.3 SDK?
@ Architech | Gus - Thanks for your suggestions, I will attempt to use the code for InternalFlash using 4.3 SDK although I’m hitting a stumbling block, I know I need to use the GHI.Hardware assembly but for some wierd reason I’m getting the “are you missing an assembly reference?” error, I’ve added the GHI.Hardware.dll as a reference and I can see it in the bin folder but I still get the error, any idea??
you don’t need a USING reference for GHI.Hardware, as that doesn’t exist. You’ll need GHI.Processor or GHI.Utilities or GHI.IO, because they are within the GHI.Hardware reference. Use Object Browser and look into the referenced DLL and see what namespaces are there…
@ Brett - Thanks, I’ve put together some code based on the “InternalStorage” class I found at https://www.ghielectronics.com/community/codeshare/entry/885 , when I test using the code below, the first read returns the correct bytes but all subsequent reads return the different bytes eventually settling on “48, 48, 48”. Any ideas why this may be happening, I assumed this would work as I’m creating an instance of “InternalStorage” within the method.
public void TestFlash()
{
InternalStorage flashStorage = new InternalStorage(11);
var addr = flashStorage.Length-100;
//Get Random Number
var r = new Random();
var num = r.Next(1000).ToString();
//Write Bytes to Flash
var wBuffer = System.Text.Encoding.UTF8.GetBytes(num.ToString());
flashStorage.Write(wBuffer, addr, 0, 3);
//Read Bytes from Flash
var rBuffer = new byte[3];
flashStorage.Read(rBuffer, addr, 0, 3);
}
@ John - Yes, I’ve started another topic closer to this issue, the bits get AND’d, I’m hoping that Register.SetBits will work, I’ll have to try later today.