I’m trying to add a 2nd I2C device to my system and have a weird problem. I’ve had a class to read a pressure/temperature/humidity (PTH) board that has 2 separate I2C devices on it that has been running fine for a long time. Now I’d like to read my GPS over its I2C port. Since there is only one I2C port on the Raptor, I moved the I2C device instantiation to my main()
public static I2CDevice g400I2C = new I2CDevice(null);
and I do this in the PTH class
private static I2CDevice.Configuration configTH = new I2CDevice.Configuration(0x40, 400); //device address is 0x40 or 1000000 (7 bit address)
private static I2CDevice.Configuration configP = new I2CDevice.Configuration(0x5D, 400);
and this before I execute the I2C transactions
Program.g400I2C.Config = configP;
when I want to read Pressure and this when I want to read Temperature and Humidity
Program.g400I2C.Config = configTH;
and this in the GPS class when I want to read the GPS
private static I2CDevice.Configuration evk7I2CConfig = new I2CDevice.Configuration(0x42, 100);
Program.g400I2C.Config = evk7I2CConfig;
The weird thing is before I ever call any PTH or GPS methods, I get this exception
Program Started
#### Exception System.Exception - 0xffffffff (1) ####
#### Message:
#### GHI.IO.Storage.SDCard::NativeConstructor [IP: 0000] ####
#### GHI.IO.Storage.SDCard::.ctor [IP: 0017] ####
#### CPF.EngrLogger::init [IP: 025f] ####
#### CPF.Program::Main [IP: 0037] ####
A first chance exception of type ‘System.Exception’ occurred in GHI.Hardware.dll
An unhandled exception of type ‘System.Exception’ occurred in GHI.Hardware.dll
and it points at this part of my code where I set up the SD card.
sdCard = new SDCard();
sdCard.Mount();
sdVol = new VolumeInfo("SD");
How is my messing around with the I2C port causing an error when I try to mount the SD card? Isn’t the SD card on a SPI channel?