I have had no problems with Win8 or 8.1. Check you driver version, and see how it shows up in Device Manager. Sometimes NETMF devices will show up as something not properly identified. Trying connecting and disconnecting to see if something appears/disappears. Then see how it is identified.
- Netduino Forums
- → rockybooth's Content
There have been 16 items by rockybooth (Search limited from 05-July 19)
I was able to use leiba's suggestion of monitoring the conversion complete signal with this:
Public Function ReadVolts() As Single _spi.Dispose() Dim cs As New OutputPort(_pin, False) Dim adcout As New InputPort(Pins.GPIO_PIN_D12, False, Port.ResistorMode.Disabled) While adcout.Read = True End While cs.Dispose() adcout.Dispose() SetupSPI() Write7799Reg(&H58) Return ReadAD7799Volts() End Function
Has anyone had success with a different method?
I reproduced this bug on another Netduino 2+ card with 1GB Sandisk card.
I would really appreciate if someone could reproduce or not reproduce this issue. At this point I am wondering if the SD card read is dependable (at least in VB). Alternately if anyone has a test sequence in VB that I could try, I would appreciate it.
Here is some more information on my toolchain:
In looking at both the logic analyzer and scope, I have attached a scope trace showing what happens. Ignore the yellow (reply from device or MISO) - the green is CS(bar), pink MOSI, and blue is the clock. You can see that the clock goes low before CS, but then after CS seems to go high impediance (made an input?), then finally reaches a "1" and works fine after that. However, the external device (and logic probe) thinks the drift higher is a clock edge, and thus gets nine clock cycles, not eight.
Adding an external pull up on the clock seems to help.
This seems a clear bug in the SPI, but one that will only show up on the first write. Some applications and external devices may not show a problem. The AD7799 that I am targeting has Schmit triggers on its inputs, so the slow rise work "just fine" (not).
It would be nice to get a response from Chris on this.
I am working on adding an spi device and only the first write after initialization appears corrupted, with subsequent writes being correct. Perhaps I do not have the latest firmware or drivers. Since this is simply writing, it is my understanding that it should not depend on if a device is attached. My full code did not work, so I have reduced this to this simplest task hoping that someone might help.
Here is the code, and at the bottom are the versions of the tool chain.
Option Explicit OnOption Strict OnImports System.IOImports System.ThreadingImports System.IO.PortsImports Microsoft.SPOT'Imports Microsoft.SPOT.Hardware'Imports Microsoft.SPOT.Net.NetworkInformationImports SecretLabs.NETMF.HardwareImports SecretLabs.NETMF.Hardware.NetduinoImports Microsoft.VisualBasic.ConstantsNamespace TestADC7799 Public Module Module1 Dim _spi As SPI Sub Main() Debug.Print("Startup") SetupSPI() For j As Byte = 0 To 254 Write7799Reg(j) Next j Debug.Print("Finished") End Sub ''' <summary> ''' Configures SPI parameters particular to ths ADC 7799 ''' </summary> ''' <remarks></remarks> Sub SetupSPI() Dim _csht As UInteger = 1 ' _chipselect holdtime mS (time that CD must remain active before unselecting, or time after the read write completion) Dim _csas As Boolean = False ' Chip select active state Dim _csst As UInteger = 10 ' Chip select Setup Time mS (time acter cs before reading) Dim _ce As Boolean = True ' If true, data is sampled on the rising edge, else falling edge Dim _cis As Boolean = True ' click idle state, high if true Dim _cr As UInteger = 100 ' clock frequency in kHz Dim spiConfig As New SPI.Configuration(Pins.GPIO_PIN_D10, _csas, _csst, _csht, _cis, _ce, _cr, Microsoft.SPOT.Hardware.SPI.SPI_module.SPI1) _spi = New SPI(spiConfig) End Sub Sub Write7799Reg(something As Byte) Dim b(0) As Byte Debug.Print("Writing Register 1 byte " & something.ToString("X")) b(0) = something _spi.Write(b) End Sub End ModuleEnd Namespace
The output window shows:
HalSystemInfo.halVendorInfo: Netduino Plus 2 (v188.8.131.52) by Secret Labs LLC
The logic analyzer shows that the initial idle state of the CLK line does not match the settings.
My code is attached.
I have been having mixed success with SD. I can usually write to the SD card, and read the contents in my PC. However, when I execute the code below, it will ALWAYS crash during the read segment (ReadFile). It always crashed with this being displayed in the debug window: A first chance exception of type 'System.IndexOutOfRangeException' occurred in System.IO.dll
I am using the latest 4.2 firmware, Visual Studio 2012 Pro, Visual Basic, NetFramework 4.2.
I am using a SanDisk 128MB microSD card.
As this fails after different number of reads, perhaps the hardware is bad. On this assumption I ordered another Netduino Plus 2 which I will try tonight.
I see in the forums that there seem to be quite a bit of problems with the SD card. If anyone has any suggestion on how to resolve this, please comment!
Imports System.netImports System.Net.SocketsImports System.IOImports System.TextImports System.ThreadingImports System.IO.PortsImports Microsoft.SPOTImports Microsoft.SPOT.HardwareImports Microsoft.SPOT.Net.NetworkInformationImports Microsoft.SPOT.IOImports SecretLabs.NETMF.HardwareImports SecretLabs.NETMF.Hardware.NetduinoImports Microsoft.VisualBasic.ConstantsNamespace CFcardUsage Public Module Module1 Dim cardPresent As Boolean = True Sub Main() ' eject handler suggested by Stephan at http://forums.netduino.com/index.php?/topic/5076-detect-eject-sd-card-in-vbnet/ AddHandler SPOT.IO.RemovableMedia.Eject, AddressOf RemovableMedia_Eject AddHandler Microsoft.SPOT.IO.RemovableMedia.Insert, AddressOf RemovableMedia_Insert Debug.Print("Startup CF Card Usage") ' Define path and filename Dim strPath As String = "SD" & DateTime.Now.ToString("yyyyMM") Dim strFileName As String = strPath & "" & DateTime.Now.ToString("yyyyMMdd") & ".log" ' make sure disk is there and create directory if needed Try If Not File.Exists(strFileName) Then ' ** This shows a System.io.ioexception AND the following line executes, also throwing an exception If Not Directory.Exists(strPath) Then '** This also shows a System.IO.IOexception in debugger, and the following line executes Directory.CreateDirectory(strPath) ' ** the exception appears to be thrown her and goes to the catch End If End If Catch ex As Exception Debug.Print("Exception thrown - " & ex.Message) Debug.Print("Presumably there is no readable card present") cardPresent = False End Try ' if no card is found, wait for one to be inserted Do While True If cardPresent Then Exit Do Debug.Print("insert card") Threading.Thread.Sleep(1000) Loop Debug.Print(strFileName) ' open the streamwriter Dim sw As StreamWriter = New StreamWriter(File.OpenWrite(strFileName)) sw.WriteLine("This is to write the files to the netduino card") 'lets learn how fast we can write to these cards Dim StartTime As DateTime = DateTime.Now Dim excp As Boolean = False For i As Integer = 0 To 10000 Dim t As String = DateTime.Now.ToString Dim EndTime As TimeSpan = DateTime.Now.Subtract(StartTime) Try ' if this fails, lets get the error, and stop writing so I can see if prior data is ok sw.Write("Memory usage " & Microsoft.SPOT.Debug.GC(False).ToString & "; Elapsed time " & EndTime.Seconds.ToString & "." & EndTime.Milliseconds.ToString) sw.WriteLine("; line number " & i.ToString & " at " & t & ", ms counter = " & DateTime.Now.Millisecond.ToString & ", tics= " & DateTime.Now.Ticks.ToString & ", machine time " & Hardware.Utility.GetMachineTime.Ticks.ToString) Catch ex As Exception Debug.Print("Exception " & ex.Message & ", at i=" & i.ToString & ", ET= " & EndTime.ToString) ' exit the write loop Exit For End Try If i Mod 1000 = 0 Then Debug.Print(i.ToString) Next ' try everything possible to make sure the writes are complete to the card sw.Flush() sw.BaseStream.Flush() sw.BaseStream.Close() sw.Dispose() ' if there was a write error, just exit, otherwise read back the contents If Not excp Then ReadFile(strFileName) End Sub Sub ReadFile(filename As String) ' this will read and display the contents of the card. If File.Exists(filename) = False Then Debug.Print("File does not exist") Return End If Dim sr As StreamReader = New StreamReader(filename) Dim s As String = "" Do Try s = sr.ReadLine() ' crashes with index out of range exception (system.io.dll) after some number of reads Catch ex As Exception ' must use a try/catch or file will be deleted or not found. Does not seen to always work Debug.Print("Error in ReadFile; " & ex.Message) Exit Do End Try Debug.Print("Mem now: " & Microsoft.SPOT.Debug.GC(False).ToString & "; Recorded data: " & s) Loop Until sr.EndOfStream Debug.Print("Last line read was: " & s) sr.Close() sr.Dispose() End Sub Sub RemovableMedia_Eject(sender As Object, e As Microsoft.SPOT.IO.MediaEventArgs) Debug.Print("Ejected") cardPresent = False End Sub Sub RemovableMedia_Insert(sender As Object, e As Microsoft.SPOT.IO.MediaEventArgs) Debug.Print("Inserted or present") cardPresent = True End Sub End ModuleEnd Namespace
That may be the problem. When I look in the Framework folders, I see the different versions of the frameworks, each with a tools folder, but the only one with the tool present is 4.3. I originally installed 4.3 because I use Visual Studio 2012 Pro and I want to work in VB. The tools documentation for the Netduino 2 Plus say you must use C# Express 2010. If I try to install the Framework 4.2 it refuses as I do not have Visual Studio 2010.
Version 4.3 is rated a "stable" version at codeplex, so I do not understand why I would have to use the tool for 4.2.
Update- I was able to flash with the DFU file, and execute simple programs. I still have not been able to set the MAC address with the same symptom that I posted in the previous message's screengrab.
I follwoed the instructions to erase the firmware, and then flash the DFU file, with verify, successfully (I thought),
When I got to the step to set the MAC address I get the following:
Unable to erase configuration sector memory. (see screengrab)
I saw another post from someone who had the same problem but flashed with the wrong file. I verified that I used the correct file.
I attempted to program a simple app using visual studio but got the error "An error has occurred please check your hardware."
Can anyone suggest a next step?
No sure what you mean by filter driver. This is a driver for a specific USB device that has in encrypted code that lock execution of the compiler to the computer with the device installed. The driver is digitally signed, and I am using the current driver. The driver was developed for Win7. My takehome message is that the WinDgb application in the windows SDK is very handy!
Well, I got past GO.
I installed WinDgb and examined the crash memory dump. It turns out that it pointed to a driver:
"Probably caused by : sparkey.sys ( sparkey+44f2 )"
Removing the device allowed me to again access
This is used by a compiler for PIC devices (ProtonBasic) and is a software protection "dongle". If anyone is interested, I found the BSOD investigation instructions at http://www.networkwo...ash-268274.html
Now if I can just get my Netduiino Plus2 working again...
I am just getting started with the NP2, and after several successful "blink-the-LED" efforts I switched to try the PWM functions, and started getting compile warnings (overflow will not throw exception), I was unable to reprogram the device.
I tried the deployment tool, and find that while I can ping the device and get back the following:
Thanks for the tips - I am quite enthused about this new (to me) platform.
After my problems on my main PC, I tried an old laptop that had Win8/32, and was able to load, build, deploy, and run on a NetDuino Plus 2!
Back at my main PC, I can compile, load, run a Net Micro Framework Console Application without problem.
I BSOD with if I select a Netduino Plus 2 Application. If I change the Target framework to .NET Micro Framework 4.2 in Project/Application tab, an then go to the References tab, I verify that .NET 4.2.xx files are selected. I even close and re-open the project and again verify 4.2.
When I then go to the .NET Micro Framework tab, immediate BSOD, every time!
Any suggestions what to try next?
I just purchased a netduino plus 2, but can't get past go...