Hi All,
I have just updated my EMX’s to 4.2.8.0 - for the much anticipated UDP fix.
All looks good so far - however - some previously working PWM code (backlight fade in / fade out) now throws an exception:
In the implementation below the following exception is thown when declaring:
var pwm = new PWM(PWM_BACKLIGHT, PWM_BACKLIGHT_FREQUENCY, PWM_BACKLIGHT_FADEOUT_START, false);
The output and exception trown is:
Assembly: mscorlib (4.2.0.0) Assembly: Microsoft.SPOT.Native (4.2.0.0) Assembly: Microsoft.SPOT.Security.PKCS11 (4.2
.0.0) Assembly: System.Security (4.2.0.0) Loading Deployment Assemblies.
Attaching deployed file.
Assembly: Microsoft.SPOT.Hardware.OneWire (4.2.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Touch (4.2.0.0) Attaching deployed file.
Assembly: System.Xml (4.2.0.0) Attaching deployed file.
Assembly: Intellitouch.Repository (1.0.0.0) Attaching deployed file.
Assembly: GHI.Premium.Net (4.2.8.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Net (4.2.0.0) Attaching deployed file.
Assembly: GHI.Premium.IO (4.2.8.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Hardware.PWM (4.2.0.1) Attaching deployed file.
Assembly: Microsoft.SPOT.Hardware.SerialPort (4.2.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Ink (4.2.0.0) Attaching deployed file.
Assembly: Intellitouch.Common (1.0.0.0) Attaching deployed file.
Assembly: GHI.Premium.System (4.2.8.0) Attaching deployed file.
Assembly: System (4.2.0.0) Attaching deployed file.
Assembly: Intellitouch.Domain (1.0.0.0) Attaching deployed file.
Assembly: Intellitouch.IO (1.0.0.0) Attaching deployed file.
Assembly: Intellitouch.Services (1.0.0.0) Attaching deployed file.
Assembly: GHI.Premium.Hardware (4.2.8.0) Attaching deployed file.
Assembly: MFDpwsExtensions (4.2.0.0) Attaching deployed file.
Assembly: Intellitouch.UI (1.0.0.0) Attaching deployed file.
Assembly: Intellitouch.HTTP (1.0.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.TinyCore (4.2.0.0) Attaching deployed file.
Assembly: System.IO (4.2.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Hardware (4.2.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Graphics (4.2.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.IO (4.2.0.0) Resolving.
GC: 1msec 39696 bytes used, 7299972 bytes available
Type 0F (STRING ): 24 bytes
Type 15 (FREEBLOCK ): 7299972 bytes
Type 17 (ASSEMBLY ): 35556 bytes
Type 1E (BINARY_BLOB_HEAD ): 4044 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
GC: performing heap compaction…
The debugging target runtime is loading the application assemblies and starting execution.
Ready.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\mscorlib.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Native.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Security.PKCS11.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Security.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.OneWire.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Graphics.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Touch.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Xml.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.System.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\James\Desktop\Intellitouch.UI\Intellitouch.ZigBee\bin\Debug\le..\GHI.Premium.IO.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.TinyCore.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\James\Desktop\Intellitouch.UI\Intellitouch.Common\bin\Debug\le\Intellitouch.Common.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.IO.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.IO.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\James\Desktop\Intellitouch.UI\Intellitouch.ZigBee\bin\Debug\le\Intellitouch.IO.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\James\Desktop\Intellitouch.UI\Intellitouch.Domain\bin\Debug\le\Intellitouch.Domain.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\MFDpwsExtensions.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\James\Desktop\Intellitouch.UI\Intellitouch.Repository\bin\Debug\le\Intellitouch.Repository.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Net.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Ink.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\James\Desktop\Intellitouch.UI\Intellitouch.Services\bin\Debug\le\Intellitouch.Services.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Hardware.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\James\Desktop\Intellitouch.UI\Intellitouch.HTTP\bin\Debug\le\Intellitouch.HTTP.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\James\Desktop\Intellitouch.UI\Intellitouch.UI\bin\Debug\le\Intellitouch.UI.exe’, Symbols loaded.
The thread ‘’ (0x2) has exited with code 0 (0x0).
*** Application is starting up ***
Configuring display
#### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1) ####
#### Message:
#### Microsoft.SPOT.Hardware.Port::ReservePin [IP: 0000] ####
#### Microsoft.SPOT.Hardware.PWM::.ctor [IP: 004d] ####
#### Intellitouch.IO.LCD.LCDBacklightManager::FadeIn [IP: 0020] ####
#### Intellitouch.UI.Program::StartApplication [IP: 0049] ####
#### Intellitouch.UI.Program::Main [IP: 0008] ####
A first chance exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.dll
#### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1) ####
#### Message:
#### Microsoft.SPOT.Hardware.Port::ReservePin [IP: 0000] ####
#### Microsoft.SPOT.Hardware.PWM::Dispose [IP: 0017] ####
#### Intellitouch.IO.LCD.LCDBacklightManager::FadeIn [IP: 0020] ####
#### Intellitouch.UI.Program::StartApplication [IP: 0049] ####
#### Intellitouch.UI.Program::Main [IP: 0008] ####
A first chance exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.dll
The program ‘[2] Micro Framework application: Managed’ has exited with code 0 (0x0).
Any ideas guys?
Cheers,
James
#region Using Directives
using System.Threading;
using Microsoft.SPOT.Hardware;
using GHI.Premium.Hardware;
using GHI.Premium;
#endregion
namespace Intellitouch.IO.LCD
{
public class LCDBacklightManager : ILCDBacklightManager
{
#region Private Members
private const Cpu.PWMChannel PWM_BACKLIGHT = Cpu.PWMChannel.PWM_4;
private const double PWM_BACKLIGHT_FADEIN_START = 0.001;
private const double PWM_BACKLIGHT_FADEOUT_START = 0.999;
private const double PWM_BACKLIGHT_FREQUENCY = 10000;
private const int BACKLIGHT_TIMEOUT = 30;
private Timer _lcdFadeTimer = new Timer(Timer_Tick, null, BACKLIGHT_TIMEOUT * 1000, BACKLIGHT_TIMEOUT * 1000);
private static bool _lcdOn;
#endregion
#region Public Methods
public void TouchGestureReceived()
{
_lcdFadeTimer = new Timer(Timer_Tick, null, BACKLIGHT_TIMEOUT * 1000, BACKLIGHT_TIMEOUT * 1000);
if (!_lcdOn)
FadeIn();
}
public void FadeOut()
{
if (_lcdOn)
{
var pwm = new PWM(PWM_BACKLIGHT, PWM_BACKLIGHT_FREQUENCY, PWM_BACKLIGHT_FADEOUT_START, false);
var i = PWM_BACKLIGHT_FADEOUT_START;
while (i >= PWM_BACKLIGHT_FADEIN_START)
{
pwm.DutyCycle = i;
pwm.Start();
i -= 0.002;
Thread.Sleep(5);
}
}
_lcdOn = false;
}
public void FadeIn()
{
if (!_lcdOn)
{
var pwm = new PWM(PWM_BACKLIGHT, PWM_BACKLIGHT_FREQUENCY, PWM_BACKLIGHT_FADEIN_START, false);
var i = PWM_BACKLIGHT_FADEIN_START;
while (i <= PWM_BACKLIGHT_FADEOUT_START)
{
pwm.DutyCycle = i;
pwm.Start();
i += 0.002;
Thread.Sleep(1);
}
}
_lcdOn = true;
}
#endregion
#region Private Methods
private static void Timer_Tick(object sender)
{
if (_lcdOn)
{
var pwm = new PWM(PWM_BACKLIGHT, PWM_BACKLIGHT_FREQUENCY, PWM_BACKLIGHT_FADEOUT_START, false);
var i = PWM_BACKLIGHT_FADEOUT_START;
while (i >= PWM_BACKLIGHT_FADEIN_START)
{
pwm.DutyCycle = i;
pwm.Start();
i -= 0.002;
Thread.Sleep(5);
}
}
_lcdOn = false;
}
#endregion
}
}