N18 display and Cerbot

Got the Cerbot and various modules for xmas.
So bit of a noob so please be gentle…
Compass and cerbot itself work fine.
Plugged the N18 display into port 3.
Get Invalid Operation Exception at this line:

private void InitializeModules() {
this.compass = new GTM.Seeed.Compass(4);
this.cerbotController = new GTM.GHIElectronics.CerbotController();
this.display_N18 = new GTM.GHIElectronics.Display_N18(3); << exception

A first chance exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.dll

Assembly: mscorlib ( Assembly: Microsoft.SPOT.Native ( Assembly: Microsoft.SPOT.Hardware (
Assembly: Microsoft.SPOT.Graphics ( Assembly: Microsoft.SPOT.TinyCore (
Assembly: Microsoft.SPOT.Hardware.SerialPort ( Assembly: Microsoft.SPOT.IO (
Assembly: System.IO ( Assembly: Microsoft.SPOT.Hardware.OneWire (
Assembly: Microsoft.SPOT.Hardware.Usb ( Assembly: System.Xml (
Assembly: Microsoft.SPOT.Hardware.PWM ( Assembly: Microsoft.SPOT.Net (
Assembly: System ( Loading Deployment Assemblies.

Attaching deployed file.

Assembly: GTM.GHIElectronics.Display_N18 ( Attaching deployed file.

Assembly: GHI.OSHW.Hardware ( Attaching deployed file.

Assembly: Gadgeteer ( Attaching deployed file.

Assembly: Gadgeteer.SPI ( Attaching deployed file.

Assembly: GTM.Seeed.Compass ( Attaching deployed file.

Assembly: GadgeteerApp2 ( Attaching deployed file.

Assembly: GTM.GHIElectronics.CerbotController ( Attaching deployed file.

Assembly: GHIElectronics.Gadgeteer.FEZCerbot ( Resolving.

Thanks in advance.

I too am having the same issue.

Something inside module’s constructor throwing the exception.

Try this:

  1. Download N18 driver code from codeplex (just on .cs file)
    http://gadgeteer.codeplex.com/SourceControl/latest#Main/Modules/GHIElectronics/Display N18/Software/Display N18/Display_N18_42/Display_N18_42.cs

  2. Remove the reference for N18 from your project

  3. Add the downloaded file to your project

At this point you should be able to compile and step into the module constructor and see exactly which line throwing the exception.

public Display_N18(int socketNumber)
: base(WPFRenderOptions.Intercept)

… // socket - 3 for cerbot

        this.spi = new GTI.SPI(this.socket, this.spiConfig, GTI.SPI.Sharing.Shared, this.socket, Socket.Pin.Six, this); // throws the error

I am in the process of rewriting my BLE pimping of my Cerbot so i decided to have a look at the problem here.

The issue is the CerbotController is setting up the LED’s to use SPI.

The N18 is then trying to do the same and here in lays the problem.

Quick and dirty fix is yo add the CerbotController source to your project and comment out the following :

//private SPI forwardLEDs;
//private SPI.Configuration spiConfig;


And then it’s “Bob’s and uncle and Fannies your aunt”


Thanks…that was it! Now on to the next hurdle :slight_smile:

Shouldn’t it be shareable?

It should be, i only spent a couple of minutes on it as i was in the middle of pimping my Cerbot…

It appears to be throwing a reserved pin error - needs a wee bit more digging…

1 Like

@ Kwaugh32 - keep us posted with progress :slight_smile:

@ Justin - That is some serious pimping.

I have some of the other samples now running (display battery usage etc). Next goal is pulling the serial camera image onto the Display N18. I bet, I will need to grab the source code (sercam_42) and use it (eg. tweak).

This is fun but frustrating at the same time.

We can reproduce the issue. It occurs because the CerbotController does not currently use Gadgeteer interfaces, so an exception is thrown when a second NETMF SPI instance is created by Gadgeteer after our first inside the CerbotController driver.

Until we update the driver to use the Gadgeteer interfaces, if you need to use the LEDs and a another SPI device, you could update the LEDs to use the Gadgeteer SPI interface instead.