More questions about initial setup

Hi

waiting for my Cerbuino package to arrive tomorrow.

Still not clear about adding the correct references to the projects.

In each folder under C:\Program Files (x86)\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies are three DLL files with the same name, in the root and under “le” and “be”.
folders.

What are the differences, which one needs to be included?

Are these the correct paths anyway? I was expecting to have something under the Microsoft sdk.

Thanks!!!

Welcome!

First of all with Cerbuino you can’t use premium assemblies. As for the which assemblies to reference - don’t worry. Visual Studio will add the right one when you use it’s “Add Reference” dialog.

Thank you Architect,

Hmm that is disappointing, I must have overlooked that.

Nevertheless, what are the be and le folders for instance also for instance in C:\Program Files (x86)\GHI Electronics\GHI OSHW NETMF v4.2 SDK\Assemblies\

I am trying to add your cerbuino pin definitions to my code, but somehow the “CPU.PIN” reference in unknown, although I have added the GHI.Hardware.FEZCerb reference

  /// <summary>Digital I/O.</summary>
            public const Cpu.Pin A0 = GHI.Hardware.FEZCerb.Pin.PB1;

            /// <summary>Digital I/O.</summary>
            public const Cpu.Pin A1 = GHI.Hardware.FEZCerb.Pin.PA5;

            /// <summary>Digital I/O.</summary>
            public const [b]Cpu.Pin[/b] A2 = GHI.Hardware.FEZCerb.Pin.PB0;

LED = new OutputPort(Pin.PA13, true); works though.
Button = new InputPort(Pin.PA15, false, Port.ResistorMode.PullUp); also

OK, I found that I have to add using Microsoft.SPOT.Hardware also to get rid of the missing reference.

One thing though: LED and Button have actions attached to it (Interrupt, read, write) while A0 has not…

What good is a pin without the ability to read and write.

“Le” and “be” would have binaries compiled for systems with little endian and big endian orders.

A0 is just a pin a number. Button and LED are instances of classes that have methods and properties.

But what worth do the the definitions for these pins have then. (As published in the Cerbuino developers guide).

If
public const Cpu.Pin A1 = GHI.Hardware.FEZCerb.Pin.PA5;
is “just a Pin”,
do I have to write my own handler in this class to get A1.Write ?

I might as well use plain Microsoft

PIN_A1 = new InputPort(Pin.PA1, false, Port.ResistorMode.PullUp);

and the get PIN_A1.Write “for free”.

What am I not getting?

Thanks

I think what you’re missing is that these two things are DIFFERENT.

public const Cpu.Pin A1 = GHI.Hardware.FEZCerb.Pin.PA5;

is “just a Pin”, but more accurately it’s a CONSTANT definition of a name A1 that maps a CPU.Pin object to the GHI definition of PA5

You will still need an Input Port object to READ the input on that pin; you will need an OutputPort object to WRITE the output on that pin

PIN_A1 = new InputPort(Pin.PA1, false, Port.ResistorMode.PullUp);

Creates a new InputPort object that you can act on. It uses a CPU.Pin definition called “Pin.PA1”. That’s most likely mapped because of a USING statement to GHI.Hardware.FezCerb.Pin.PA1.

Pin_MyPin = new InputPort(A1, false, Port.ResistorMode.PullUp);

creates a new InputPort object that uses your earlier A1 const that at a hardware level is on Pin PA5.

Thanks Brett

it does make more sense now.

Well, my package is here, have to find a power supply that fits.

Even “FEZ” has a learning curve. (As expected).

But it will click sooner or later :wink:

I think it did just click: (kind of, but not completely)

PIN_A1 = new InputPort(Pin.PA1, false, Port.ResistorMode.PullUp); is a generic .NETMF Class that assigns a bunch of actions to a name of a pin, here Pin.PA1

after this I can do Pin_A1.Write(true);

so far so good.

Somehow the statement below maps that to the Cerbuino hardware.

public const Cpu.Pin A1 = GHI.Hardware.FEZCerb.Pin.PA5;

How would this work to match the first statement?

public const Cpu.Pin PIN_A1 = GHI.Hardware.FEZCerb.Pin.PA5; ???

public const Cpu.Pin PIN_A1 = GHI.Hardware.FEZCerb.Pin.PA1; ???

Can you maybe give one working example?

Thanks

public const Cpu.Pin PIN_A1 = GHI.Hardware.FEZCerb.Pin.PA5;

public const Cpu.Pin PIN_A1 = GHI.Hardware.FEZCerb.Pin.PA1;

are both valid, but are only enumerations. They don’t give you anything you can act on. It doesn’t make much sense to use these - they are already defined. If you look at what GHI.Hardware.FEZCerb.Pin.PA1 really means, it converts back to a physical pin/connection on the processor, specifically PA1.

A more sensible approach might be to think of it this way. Say you have a press-button switch on one pin and a toggle switch on another. Then, you might do this:

public const Cpu.Pin Press_button_PIN = GHI.Hardware.FEZCerb.Pin.PA5;

public const Cpu.Pin Toggle_switch_PIN = GHI.Hardware.FEZCerb.Pin.PA1;

And then use

Toggle = new InputPort(Toggle_switch_PIN, false, Port.ResistorMode.PullUp);
PressBut = new InputPort(Press_button_PIN, false, Port.ResistorMode.Pullup);

Then you can do a Toggle.Read() to find the status of the toggle switch, and a PressBut.Read() to find the status of the press button.

What did the CONST definitions give you? Not much. You could have defined the same GHI.Hardware(Etc) definition in the InputPort creation.

You keep mentioning WRITE. The other thing you haven’t yet twigged is that an InputPort object can’t be written to, it can only be read from. It’s an input so it doesn’t make sense to write to an input. You need an OutputPort object to use the Write method. There is also a “tristate” port object that you can both read and write from - but in most cases, objects you’re going to connect are read or write devices not both (note that the READ method on an output port is valid since it reads the current state that you have set the pin to).

hope that helps !!!

Thanks Brett

I think I got it now. ( The Read/Write was just a glitch from copy and paste - sure I can’t writ to an input pin).

If you could help me with one more thing:

The documentation mentions the FEZ Config tool, but for some reason it is not installed on my system (I installed 4.2).
There is a program entry in "all programs-> GHI Electronics -> GHI Net Gadgeteer SDK… there is other stuff there but not the FEZ CONFIG.

I even searched my whole computer for FEZ and Config but no FEZ Config.exe to be found.
What am I missing?

Then I found the “GHI_NETMF_Configuration_Toolv003.exe” in the forum, but that supposedly does not support CebuinoBee.

Thanks

This document may help with the Pin enumeration explantions: http://www.ghielectronics.com/docs/6/locating-ios

Sorry looks like our recent Web site upgrade omits the download link (was found under Support->.NET Micro Framework but until we fix that (soon, glad you spotted it) here’s the direct link: https://www.ghielectronics.com/downloads/bin/FEZ_Config_v013.zip

FYI - FEZ Config will be bundled in the install with the upcoming SDK

Thanks Jeff!

Hi

I cant believe that I am still struggling with these ports…

I tried it with the BUTTON and LED example from the Button module and with the code provided in the last message:

InputPort Toggle ;

Debug.Print(“Step1”);

const Cpu.Pin Toggle_switch_PIN = GHI.Hardware.FEZCerb.Pin.PA1;

Debug.Print(“Step2”);

Toggle = new InputPort(Toggle_switch_PIN, false, Port.ResistorMode.PullUp);

Debug.Print(“Step3”);

As soon as the "Toggle = " is executed I am getting a System Exception:

Using mainboard GHI Electronics FEZCerbuinoBee version 1.2
Step1
Step2
#### Exception System.Exception - CLR_E_PIN_UNAVAILABLE (1) ####
#### Message:
#### Microsoft.SPOT.Hardware.Port::.ctor [IP: 0000] ####
#### Microsoft.SPOT.Hardware.InputPort::.ctor [IP: 0008] ####
#### TEST2.Program::ProgramStarted [IP: 0016] ####
#### TEST2.Program::Main [IP: 0015] ####
WARN: Total initialization time exceeds 10 seconds.
: ProgramStarted is blocking execution, which means events and timers will not run properly.
: Make sure not to use blocking code such as while(true) - use a GT.Timer instead.
A first chance exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Hardware.dll

I see that: CLR_E_PIN_UNAVAILABLE but I do not know what that means.

Also: How do I suppress the annoying "System.NotSupportedException"
for the Cerbuino?

Thanks a lot!

Please show the entire code.

CLR_E_PIN_UNAVAILABLE is pretty self explanatory. You are trying to use a specific pin that is unavailable for some reason - either it is already in use, or it’s undefined. Since we know you’re trying to use PA1, there’s something conflicting with that. The schematics for Cerbuino show that this is pin6 on Socket 2, the AIKUX socket. Have anything there?

As Gus asks, if you post your entire code we can see whether there’s anything there that you’re doing that will cause the problem.

Can you also explain what System.NotSupportedException you’re asking about? That specifically means that the firmware does not support what ever it is you’re doing - so you need to stop doing that and the problem will go away :slight_smile:

1 Like

And I suspect I know what you’ve done now.

It seems like you have created a Gadgeteer project. In that project you have included a button module onto the designer surface, and connected it to Socket 2. As part of that, the Gadgeteer components automatically define the Button module, and as part of the Module Initialisation process, Gadgeteer will assign the pin there. Then when your manual definition comes along, it conflicts and throws the exception.

Two things you can do. Remove the button module from the designer, or remove the manual pin definition. What suits best will depend on what you want to achieve, since it seems you’re in “play” mode I’d just remove the module from the designer.

You can also note in your error message that there’s a warning about ProgramStarted() not finishing:

[quote]WARN: Total initialization time exceeds 10 seconds.
: ProgramStarted is blocking execution, which means events and timers will not run properly.
: Make sure not to use blocking code such as while(true) - use a GT.Timer instead.

[/quote]
And you REALLY need to let that finish to enable the full Gadgeteer dispatcher to work.
http://blogs.msdn.com/b/net_gadgeteer/archive/2011/12/19/why-not-while-true.aspx

Something that may help: read these two documents and pay special attention to the difference in the program examples. One is Gadgeteer (which makes NETMF easy) and the other uses NETMF directly which is closer to the hardware.

http://www.ghielectronics.com/docs/43/first-gadgeteer-project

http://www.ghielectronics.com/docs/7/digital-outputs

Thank guys,

Brett you were absolutely right, I did start with a Gadgeteer project (which also had other modules added and I must have run into a pin conflict with this. When I removed then it did go trough.

Concerning the loop that locks the loader, thanks for pointing me to the article.
My code though was copied straight from one of the support files at the GHI website - just don’t remember where. (Maybe the don’t do it example? :slight_smile: )

The other issue is the exception I am getting 4 time when I start the debugger:

[em]#### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (2) ####

Message:

GHI.OSHW.Hardware.RTC+Hydra+Hydra_RTC_Registers::.cctor [IP: 0008]

An unhandled exception of type ‘System.NotSupportedException’ occurred in GHI.OSHW.Hardware.dll
Uncaught exception [/em]

This error even occurs if I just create a brand new Gadgeteer app with only the Cerbuino board and no modules at all. (And it comes up roughly when the debugger is loaded)
If I search for “CLR_E” through the entire solution, there are no finds.

Thanks again, I will try this tonight.

Your last exception talks about Hydra and RTC. You are using a Cerberus based board, no? Somewhere in your code you have tried to do something from a Hydra, which is not going to work, and it’s throwing an exception. To unravel that, you’re really going to have to show us your code or explain what you’re trying to do and have done???

As for the while(true) loop, yes I know GHI have it on at least one example code, Jeff is doing lots of updates in that area at the moment so this looks like another criteria he needs to add :slight_smile: