Today I got my new FezFlea and FezPico and saw lousy problems to get analog inputs working on the Flea.
using System;
using System.Collections;
using System.Diagnostics;
using System.Text;
using System.Threading;
using GHIElectronics.TinyCLR.Devices.Gpio;
using GHIElectronics.TinyCLR.Devices.Adc;
using GHIElectronics.TinyCLR.Native;
using GHIElectronics.TinyCLR.Pins;
namespace FezFlea_Analog_Test
{
class Program
{
static void Main()
{
Debug.WriteLine("Hallo World");
var LED = GpioController.GetDefault().OpenPin(SC13048.GpioPin.PA8);
LED.SetDriveMode(GpioPinDriveMode.Output);
try
{
AdcChannel adcChan =
AdcController.GetDefault().OpenChannel(SC13048.Adc.Controller1.PA5);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
while (true)
{
LED.Write(GpioPinValue.High);
Thread.Sleep(1000);
LED.Write(GpioPinValue.Low);
Thread.Sleep(1000);
}
}
}
}
The program didn’t start:
Found debugger!
Create TS.
Loading Deployment Assemblies.
Attaching deployed file.
Assembly: mscorlib (2.1.0.0) Attaching deployed file.
Assembly: GHIElectronics.TinyCLR.Native (2.1.0.0) Attaching deployed file.
Assembly: GHIElectronics.TinyCLR.Devices.Gpio (2.1.0.0) Resolving.
The debugging target runtime is loading the application assemblies and starting execution.
Ready.
Cannot find any entrypoint!
Done.
Waiting for debug commands…
“GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll” (Verwaltet): “C:\Users\Roland\source\TinyCLR_V2\FezFlea_Analog_Test\FezFlea_Analog_Test\bin\Debug\pe…\GHIElectronics.TinyCLR.Native.dll” wurde geladen, das Laden von Symbolen wurde übersprungen. Das Modul ist optimiert, und die Debugoption “Nur eigenen Code” ist aktiviert.
“GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll” (Verwaltet): “C:\Users\Roland\source\TinyCLR_V2\FezFlea_Analog_Test\FezFlea_Analog_Test\bin\Debug\pe…\GHIElectronics.TinyCLR.Devices.Gpio.dll” wurde geladen, das Laden von Symbolen wurde übersprungen. Das Modul ist optimiert, und die Debugoption “Nur eigenen Code” ist aktiviert.
Das Programm “[31] TinyCLR application: Verwaltet” wurde mit Code 0 (0x0) beendet.
When I commented the command in the try{} catch block it started as expected.
No exception could be cought,
With the FezPico the program started as expected.