I need help to get started with FEZ Cobra III and Display

I’m trying to run the code example from GHI Electronics website, when I try to run it from visual studio it compiles fine then display deploying to device, target initialized successfully and then immediately exits. No brake points getting hit when ruining on the board, but when I switch to emulator it hits the breakpoints.

Please help, this is my first FEZ board and first display.


using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

public class Program : Application
{
    private Bitmap lcd;

    public static void Main()
    {
        Program app = new Program();

        app.Run();
    }

    public Program()
    {
        this.lcd = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);

        Touch.Initialize(this);

        this.MainWindow = new Window();

        this.MainWindow.TouchDown += MainWindow_TouchDown;
        this.MainWindow.TouchUp += MainWindow_TouchUp;
        this.MainWindow.TouchMove += MainWindow_TouchMove;
    }

    private void MainWindow_TouchMove(object sender, TouchEventArgs e)
    {
        Debug.Print("Touch move at (" + e.Touches[0].X.ToString() + ", " + e.Touches[0].Y.ToString() + ")");

        this.lcd.DrawEllipse(Colors.Blue, e.Touches[0].X, e.Touches[0].Y, 5, 5);
        this.lcd.Flush();
    }

    private void MainWindow_TouchUp(object sender, TouchEventArgs e)
    {
        Debug.Print("Touch up at (" + e.Touches[0].X.ToString() + ", " + e.Touches[0].Y.ToString() + ")");
    }

    private void MainWindow_TouchDown(object sender, TouchEventArgs e)
    {
        Debug.Print("Touch down at (" + e.Touches[0].X.ToString() + ", " + e.Touches[0].Y.ToString() + ")");
    }
}

hardware:
[ul]FEZ Cobra III (the board identify itself to visual studio debugger as G120_Gadgeteer)
GXP Gadgeteer Bridge
Display NHVN Module
4.3" with capacitive touch newhaven display
WiFi RS21 Module[/ul]
Board connected to mini USB and 12v power supply.

Project output type is: Console Application , Framework is:.NET Micro Framework 4.3
References are:
[ul]Microsoft.SPOT.Graphics
Microsoft.SPOT.Native
Microsoft.SPOT.TinyCore
Microsoft.SPOT.Touch
mscorlib[/ul]

Which method is the entry point for the program? Where do you put the break points that don’t get hit?

try putting a Thread.Sleep at the end of the main function. When you exit the main function, your program is finished.

First guess, look at the output window after it fails. My guess is the library version on your PC doesn’t match the firmware version on the Cobra. A simple update w FEZ Config will fix that.

He’s using Program so pretty sure app.Run() doesn’t return and similar to a Gadgeteer programme.

@ EvoMotors, can you put a breakpoint in Program() and see if it breaks?

I also don’t see any code where you initialise the LCD itself, only touch.

@ Mr. John Smith -
Entry point should be “Main” method of a “Program” class.
I have breakpoints in every method. None of them get hit.

@ Mike -
Thread.Sleep(Timeout.Infinite); on the end of Main function does not help as I guess it’s not getting executed.

@ Skewworks -

Here is the output:
Found debugger!

Create TS.

Loading start at a0e69394, end a0e98828

Assembly: mscorlib (4.3.1.0) Assembly: Microsoft.SPOT.Native (4.3.1.0) Assembly: Microsoft.SPOT.Security.PKCS11 (4.3
.1.0) Assembly: System.Security (4.3.1.0) Assembly: Microsoft.SPOT.Hardware (4.3.1.0)
Assembly: Microsoft.SPOT.Graphics (4.3.1.0) Assembly: Microsoft.SPOT.TinyCore (4.3.1.0)
Assembly: Microsoft.SPOT.IO (4.3.1.0) Assembly: System.IO (4.3.1.0) Assembly: Microsoft.SPOT.Hardware.Usb (4.3.1.0)
Assembly: Microsoft.SPOT.Hardware.SerialPort (4.3.1.0) Assembly: Microsoft.SPOT.Touch (4.3.1.0)
Assembly: Microsoft.SPOT.Ink (4.3.1.0) Assembly: Microsoft.SPOT.Hardware.PWM (4.3.1.0)
Loading Deployment Assemblies.

Resolving.

GC: 1msec 284784 bytes used, 7054884 bytes available

Type 0F (STRING ): 24 bytes

Type 15 (FREEBLOCK ): 7054884 bytes

Type 17 (ASSEMBLY ): 21180 bytes

Type 1E (BINARY_BLOB_HEAD ): 263508 bytes

Type 34 (APPDOMAIN_HEAD ): 72 bytes

GC: performing heap compaction…

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

Cannot find any entrypoint!

Done.

Waiting for debug commands…

‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Native.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Security.PKCS11.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.Security.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Graphics.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.TinyCore.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.IO.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.IO.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.Usb.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Touch.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Ink.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Microsoft.SPOT.Debugger.CorDebug.14.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll’, Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
The program ‘[20] Micro Framework application: Managed’ has exited with code 0 (0x0).

@ Dave McLaughlin -
Dave, I’m just trying to run a sample code from the website, The Program class is direct copy and paste from the example code on this website. I was under assumption that the the sample code should work as it.

@ EvoMotors - Yea dude, there it is in the error message “Cannot find any entrypoint!” Post a screen shot of which method you have as startup.

@ Mr. John Smith -
I recreated the project with the same configuration and program runs. However, the TouchMove event getting triggered without me touching the display. Anyway looks like I’m using wrong example since I’m using Display NHVN Module I probably should be using the touch controller example from [url]https://www.ghielectronics.com/docs/338/display-nhvn-developers-guide[/url]

In the guide it say to initialize the display using

using GHI.Processor.Display;

//4.3" Displays
Display.Width = 480;
Display.Height = 272;
Display.OutputEnableIsFixed = false;
Display.OutputEnablePolarity = true;
Display.PixelPolarity = false;
Display.PixelClockRateKHz = 20000;
Display.HorizontalSyncPolarity = false;
Display.HorizontalSyncPulseWidth = 41;
Display.HorizontalBackPorch = 2;
Display.HorizontalFrontPorch = 2;
Display.VerticalSyncPolarity = false;
Display.VerticalSyncPulseWidth = 10;
Display.VerticalBackPorch = 2;
Display.VerticalFrontPorch = 2;
Display.Type = Display.DisplayType.Lcd;

But when I’m adding reference to the DHI.Hardware to have access to Display class I’m getting following output:

Found debugger!

Create TS.

Loading start at a0e69394, end a0e98828

Assembly: mscorlib (4.3.1.0) Assembly: Microsoft.SPOT.Native (4.3.1.0) Assembly: Microsoft.SPOT.Security.PKCS11 (4.3
.1.0) Assembly: System.Security (4.3.1.0) Assembly: Microsoft.SPOT.Hardware (4.3.1.0)
Assembly: Microsoft.SPOT.Graphics (4.3.1.0) Assembly: Microsoft.SPOT.TinyCore (4.3.1.0)
Assembly: Microsoft.SPOT.IO (4.3.1.0) Assembly: System.IO (4.3.1.0) Assembly: Microsoft.SPOT.Hardware.Usb (4.3.1.0)
Assembly: Microsoft.SPOT.Hardware.SerialPort (4.3.1.0) Assembly: Microsoft.SPOT.Touch (4.3.1.0)
Assembly: Microsoft.SPOT.Ink (4.3.1.0) Assembly: Microsoft.SPOT.Hardware.PWM (4.3.1.0)
Loading Deployment Assemblies.

Attaching deployed file.

Assembly: Gadgeteer (2.43.1.0) Attaching deployed file.

Assembly: GHI.Hardware (4.3.8.0) ***********************************************************************

  •                                                                 *
    
  • ERROR!!! Firmware version does not match managed code version!!! *

  •                                                                 *
    
  •                                                                 *
    
  • Invalid native checksum: GHI.Hardware 0x452A2614!=0x9E02C59C *

  •                                                                 *
    

Resolving.

Link failure: some assembly references cannot be resolved!!

Assembly: Gadgeteer (2.43.1.0) needs assembly ‘Microsoft.SPOT.Net’ (4.3.1.0)

Error: a3000000

Waiting for debug commands…

The program ‘[6] Micro Framework application: Managed’ has exited with code 0 (0x0).

and again, the debugging output tells you what is going on. Please run Fez Config and install the correct firmware onto your device, so that it matches the SDK that you have installed.

@ Brett -
What is fez config? What do you mean correct firmware? There is no information that I can find. I installed everything that per start guide from GHI
Explain please.

The only board from GHI I used before was G120 TH, I didn’t have to install any firmware on the board.

Look in START and GHI and you will find Fezconfig or just search for it. This is used to update your board to the latest firmware.

@ Dave McLaughlin -
Thank you, this helped.

Can you point me to the complete example of using the display with capacitive touch? I’m still a little lost.

@ Dave McLaughlin -
I was able to configure the display, but still have an issue with touch.

I’m using CapacitiveTouchController class from this website and not sure what pin should be be passed to the CapacitiveTouchController constructor. The description says its pin 3 on the I socket. But what pin is it from the Pins enum?

CapacitiveTouchController touch = new CapacitiveTouchController(???);
touch.ScreenPressed += Touch_ScreenPressed;
touch.ScreenReleased += Touch_ScreenReleased;

Found with trial and error
it is Cpu.Pin.GPIO_Pin6

Sorry, I just posted on your other posting as you cross posted the request. Best to only post in one place.

There is nothing documented so you have to look through schematics to find things. :slight_smile: