Panda IO to USBizi IO

I am converting code that runs fine on the Panda over to a custom board using the USBizi 100 chip. I changed the referenced assembly from the Panda assembly to the USBizi assemblly in the project window.

The problem is I cannot get the proper reference to the USBizi pin in the variable passed to the function. In the oc statement, I cannot figure out the correct reference to the USBizi pin.
The specific code is:

       public SerialLCD(Cpu.Pin pin)
        {
            BYTE_TIME_MS = (int)Math.Ceiling((double)BIT_TIME_US *AX_TIMINGS_BUFFER_SIZE / 1000);
            oc = new OutputCompare((Cpu.Pin) pin, true, MAX_TIMINGS_BUFFER_SIZE);

            // Initilaize LCD
            SendCommand(DISPLIGHTON);
            SendCommand(CLR_DISP);
        }

Any help would be gratefully appreciated.
Thanks.

If suing USBizi then you should use the USBizi pinout document along with USBizi DLL. Do not refer to anything from FEZ boards for example. See download section on USBizi page on GHI’s online catalog.

Please code-tag your code so it is readable

Thanks Gus!

This is the code. I know the physical pin from the USBizi documentation. I cannot get the compiler to accept my attempts at proper reference for the pin, ie does Cpu.pin change to USBizi.pin? I cannot get anything to work.

public SerialLCD(Cpu.Pin pin)
{
BYTE_TIME_MS = (int)Math.Ceiling((double)BIT_TIME_US *AX_TIMINGS_BUFFER_SIZE / 1000);
oc = new OutputCompare((Cpu.Pin) pin, true, MAX_TIMINGS_BUFFER_SIZE);

// Initilaize LCD
SendCommand(DISPLIGHTON);
SendCommand(CLR_DISP);
}

Can you give us more details on the error you are receiving?

Cannot convert to static type 'GHIElectronics.NETMF.Hardware.USBizi’The best overloaded method match for ‘GHIElectronics.NETMF.Hardware.OutputCompare.OutputCompare(Microsoft.SPOT.Hardware.Cpu.Pin, bool, int)’ has some invalid arguments

Argument 1: cannot convert from ‘GHIElectronics.NETMF.Hardware.USBizi’ to ‘Microsoft.SPOT.Hardware.Cpu.Pin’

Use the icon for code tags please (binary numbers). I edited your code so it is readable.

You posted code that is not what is causing the error :slight_smile: Where is the line of code that actually give you an error?

I am guessing all you have to do is cast the type. This is done on many examples codes everywhere, in the book, on code share, on wiki…etc.

add this before the pin name to cast its type what you need (Cpu.Pin)

If the code is exactly as it is in your example, with just the single line before setting the oc variable, i’m not sure what the issue is. You shouldn’t need the Cpu.Pin cast, as pin is already a Cpu.Pin as defined in the method parameter.

As far as the compiler is aware for your code, it should only see a Cpu.Pin.

This compiles for me:


public SerialLCD(Microsoft.SPOT.Hardware.Cpu.Pin pin)
{
BYTE_TIME_MS = (int)System.Math.Ceiling((double)BIT_TIME_US *AX_TIMINGS_BUFFER_SIZE / 1000);
OutputCompare oc = new OutputCompare(pin, true, MAX_TIMINGS_BUFFER_SIZE);
}

Perhaps you can post your whole class here?

FEZ_Components.SerialLCD ThisLCD = new FEZ_Components.SerialLCD((Cpu.Pin)USBizi.Pin.IO5);

This is the instruction I am trying to use to access the function previously shared. Hopefully it is properly code tagged.

I have looked at the many example in an effort to solve my problem. I am no code guru, but someone trying to get a product to a customer that pays the bills.

This is the error message in the output window -

#### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1) ####
#### Message: 
#### GHIElectronics.NETMF.Hardware.OutputCompare::OutputCompare_ctor [IP: 0000] ####
#### GHIElectronics.NETMF.Hardware.OutputCompare::.ctor [IP: 000b] ####
#### GHIElectronics.NETMF.FEZ.FEZ_Components+SerialLCD::.ctor [IP: 0027] ####
#### SatComRadio.Communications::GetIridiumMessage [IP: 0102] ####
#### SatComRadio.Communications::SendIridiumMessage [IP: 0183] ####
#### SatComRadio.Communications::WriteToIridium [IP: 0087] ####
#### Boat.Program::Main [IP: 0004] ####

A first chance exception of type ‘System.InvalidOperationException’ occurred in GHIElectronics.NETMF.Hardware.dll

Help is gratefully appreciated.
Thanks in advance.

I am not seeing anything wrong. Can you send a small but complete code demonstrating the problem please? We will try it on our end.

bdrew, feel free to email me the code and I can take a look at it very quickly. Your code will be kept confidential:
mark@ ascended.com.au

The only possible issue that I can think of is that you have already used that pin with another managed object (InputPort, OutputPort, etc.) and that managed object is not disposed yet, keeping the pin “reserved”.

Thank you for the suggestion!! I will investigate that possibility this evening on return to the office.

Bernard