Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

FelixEmman

Member Since 02 Feb 2011
Offline Last Active Jun 24 2011 07:57 PM
-----

Topics I've Started

Ethernet and SD won't work when building with GCC 4.2.1

16 March 2011 - 01:19 PM

Has anyone had problems with the Ethernet and SD when building NetduinoPlus with GCC?

I used GCC 4.2.1 to build the latest code available (4.1.0.update6). I loaded the TinyBooterDecompressor via samba (the one available here in the forum) because of its small size. Then I used MFDeploy to upload ER_CONFIG and ER_FLASH produced by GCC.
Blinking the LED works. However the network and SD do not work.

If I try this:

var interface = NetworkInterface.GetAllNetworkInterfaces()[0];

I get this exception:

An unhandled exception of type 'System.IndexOutOfRangeException'  occurred in Netduino1stApp.exe

	#### Exception System.IndexOutOfRangeException  - 0xa9000000 (1) ####
	#### Message: 
	#### Netduino.Program::Main [IP: 0005] ####
A first chance  exception of type 'System.IndexOutOfRangeException' occurred in  Netduino1stApp.exe
An unhandled exception of type 'System.IndexOutOfRangeException'  occurred in Netduino1stApp.exe

Also if I try this:

if (File.Exists(@"\SD\sample.bmp")) Debug.Print("Exists!");

I get this exception:
An unhandled exception of type 'System.IndexOutOfRangeException'  occurred in Netduino1stApp.exe

#### Exception System.IO.IOException - CLR_E_INVALID_DRIVER (1)  ####
	#### Message: 
	#### Microsoft.SPOT.IO.NativeIO::GetAttributes  [IP: 0000] ####
	#### System.IO.File::Exists [IP: 001a] ####
	#### Netduino.Program::Main [IP: 0010] ####
A  first chance exception of type 'System.IO.IOException' occurred in  Microsoft.SPOT.IO.dll


If I load the stock 4.1.0.6 firmware available in the forum, everything works, and these 2 lines of code return the expected result.

SPI.WriteRead() returns junk

16 February 2011 - 01:48 PM

Hello netduino world,

I'm having some trouble with the SPI.WriteRead method. I've seen some older posts that reported issues with this method. I have the latest firmware (4.1.1 alpha7) on my netduino+, but it looks like the data coming back from my device is junk.
I have an LCD which talks SPI and always sends back a MISO status register byte as a response to any MOSI byte sent to it. This byte can change during the transmission of a multi byte command, but certain bits in this byte should always be the same (ie ONLINE bit). So I'd expect precise return bytes after each byte sent. Changing the clock does seem to have an effect, the return bytes change the pattern, but with the configuration in the code below I always get a 27 back. If I send the bytes as an array to a single WriteRead() call (commented code), the return bytes are junk, however they seem to have some kind of pattern (I see some bytes repeat in certain positions).

I don't have a logic analyzer yet to see what's on the wire but since the simple command in the code below is successful, I don't think my code is bad and I know that the device must be sending the expected MISO values back, but SPI.WriteRead() must be reading them wrong. From what I can tell, the Netduino firmware calls the SPI routines directly from NETMF without any alterations. Thoughts? Could SPI.WriteRead() still broken?

using System;
using System.Net;
using System.Net.Sockets;
using  System.Threading;
using Microsoft.SPOT;
using  Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using  SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace NetduinoPlusApplication1
{
	public class Program
	{
    	public static void Main()
    	{
        	var  SPIConfig = new SPI.Configuration(Pins.GPIO_PIN_D10, // CS port
						false,			// SS active when LOW
						0,				// CS Setup time
						0,				// CS Hold time
						true,			// Clock idle is high
						true,			// Data is sampled on rising edge of clock
						6000,			// Clock rate in KHz
						SPI_Devices.SPI1);
        	var SPI = new SPI(SPIConfig);

        	//send some empty bytes first - response should be 0x08 (ONLINE), but always 27 (0x1B)
        	byte[] readBuff = new  byte[] { 0x0 };
        	SPI.WriteRead(new byte[] { 0x00 },  readBuff);
        	Debug.Print("" + readBuff[0]);
        	SPI.WriteRead(new byte[] { 0x00 }, readBuff);
        	Debug.Print("" + readBuff[0]);

        	//simple command - clear screen to red, the return bytes are always 27
        	SPI.WriteRead(new byte[] { 0x13 }, readBuff);
        	Debug.Print("" + readBuff[0]);
        	SPI.WriteRead(new byte[] { 0xEC }, readBuff);
        	Debug.Print("" + readBuff[0]);
        	SPI.WriteRead(new byte[] {  0x00 }, readBuff);
        	Debug.Print("" + readBuff[0]);
        	SPI.WriteRead(new byte[] { 0x01 }, readBuff);
        	Debug.Print("" + readBuff[0]);
        	SPI.WriteRead(new byte[] {  0x09 }, readBuff);
        	Debug.Print("" + readBuff[0]);
        	SPI.WriteRead(new byte[] { 0x55 }, readBuff);
        	Debug.Print("" + readBuff[0]);
        	SPI.WriteRead(new byte[] {  0xAA }, readBuff);
        	Debug.Print("" + readBuff[0]);
        	SPI.WriteRead(new byte[] { 0x00 }, readBuff);
        	Debug.Print("" + readBuff[0]);
       	
        	//sending the same command this way will instead return junk in the readBuff
        	//byte[] writeBuff =  new byte[] { 0x13, 0xEC, 0x00, 0x01, 0x09, 0x55, 0xAA, 0x00 };
        	//byte[] readBuff = new byte[9];
        	//SPI.WriteRead(writeBuff, readBuff);

			
        	//now just blink an led
        	var led = new  OutputPort(Pins.ONBOARD_LED, false);
        	while (true)
        	{
            	led.Write(true);
            	Thread.Sleep(1000);
            	led.Write(false);
             	Thread.Sleep(1000);
        	}
    	}
	}
}

The output is:

27
27
27
27
27
27
27
27
27
27

another SPI speed rant

04 February 2011 - 10:15 PM

While I still eagerly wait for my netplus to arrive... I was speding a lot of time in the forums trying to figure out what the capabilities of the SPI port are, speedwise. And I get mixed impressions, there's a lot of discussion about bit banging, using native code to speed up things and Corey's Fluent Interop which I acually really like (haven't tried it cause .. doh .. I don't have the board yet but to me it looks like a very elegant solution to the problem, maybe because I'm not annoyed by lambdas). But rather than explaining what I think is possible let me explain what I need to do with SPI and then maybe someone can confirm or point me in the right direction. BTW.. I come from coding in Arduino for hardware where certain things are easy, but not having the real IDE power of VStudio makes other things painstakingly slow to debug. Hence my decision to try Netduino.

I will need to use my NetduinoPlus to control 8 LCDs over SPI. They can go up to 10MHz but have some specific timings, for instance a 15us interbyte delay.

These LCDs work with arrays of bytes as commands (a few command bytes in the header and then the data). For instance, a clear screen would be a very short command, just a command, no payload. But a display text command would be a few command bytes, a 2 byte length, and then the actual text which could be several bytes. Or even more complicated, I can send display image commands which have the command header, but the payload can get real big real quick depending on the resolution and color depth of the image displayed (several thousand KBs for a full screen). So for displaying an image I would have to be able to read that from say the ethernet, and flush it down the SPI to be displayed on one of the N LCDs, of course... as fast as possible.
I saw a post where a guy was having trouble with his SPI DAC not being nearly as fast as he needed it, but in other places I saw ChrisW saying that not even native code can beat the .netmf SPI implementation (which i assume is whatever is available in the firmware?).

Let me summarize what I need to do:
  • Talk to these LCDs individually, FAST
  • Control 8 LCDs with 3 wires (was thinking of using a 74hc138 3-to-8 decoder), and possibly 16 of these LCDs in the future. Not sure if this is doable given the signature of that SPIConfiguration class that I've seen around in other posts, but I need to be able to control as many SPI LCDs as I want (16 would seem tops for my needs right now).
  • Set my SPI speed as close as possible to 10MHz to gain as much throughput as possible while staying within spec. Is this doable, or is it always going to be a divider of 48mhz?
  • Make sure I respect their spec timings, specifically: when i send several bytes for a command, i need to leave a 16us delay between bytes.
  • I constantly have to check the MISO byte as I send the MOSI byte for status bits (BUSY, ACK, DATAOK, etc) in case I need to resend a byte, so I don't think an alternative bitbanged SPI version would work for me in case the netduino SPI isn't fast enough.
So hopefully this gives a good feel of my application needs and any comments/clarification/suggestion/insight are welcome.

Change Static IP from code

03 February 2011 - 07:21 PM

While still waiting for my NPlus to arrive, I was wondering if I will be able to set it up to use static IP addresses, but be able to change it according to what the user wants. So for example, i would store a config file on the SD card, which would hold IP address, MAC, gateway, subnet and things like that. Upon start up I would read the config file and set all these settings accordingly. I was looking through topics and its not really apparent what the options are as far as connecting/disconnecting, DHCP/static. Could someone with more knowledge shed some light here... Thanks

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.