Hello,
I had am trying to use the SPI communication on my G30 TH module. I am following the example on this link:
https://www.ghielectronics.com/docs/14/spi
but, when i try to deploy the code to my G30, i get the follwoing error
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 following is my code
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHI.Pins;
namespace NETMFBook
{
public class Program
{
public static void Main()
{
SPI.Configuration Dig_Setpoint_SPI = new SPI.Configuration(GHI.Pins.G30HDR.Gpio.PC10,
false, // ChipSelect Active State
0, // CLK Setup Time
0, // CLK Hold Time
true, // Clock Idle State
false, // Clock Edge
1000, // Clock Rate kHz
SPI.SPI_module.SPI2);
SPI MySPI = new SPI(Dig_Setpoint_SPI);
ushort[] Wiper_Pos_EN = new ushort[] { 0x1802 };
ushort[] Dig_Setpoint_25C = new ushort[] { 0x0600 }; // Halfway Point
ushort[] Dig_Setpoint_1 = new ushort[] { 0x0500 }; // 1/2 scale
ushort[] Dig_Setpoint_2 = new ushort[] { 0x0700 }; // 3/4 scale
ushort[] rx_data = new ushort[1];
MySPI.Config = Dig_Setpoint_SPI;
MySPI.WriteRead(Wiper_Pos_EN, rx_data);
MySPI.WriteRead(Dig_Setpoint_25C, rx_data);
Debug.Print("Done");
}
}
}
I think the problem comes when the following tries to run
SPI MySPI = new SPI(Dig_Setpoint_SPI);
Any idea why that would be?
Thank You