I am planning a design based on the Netduino Plus 2 (tentative) and I created a custom emulator (nothing fancy really) project in VS.2013 Ultimate on Windows 7 Ultimate x64. As pointed out in a previous question this is targetted to a desktop framework (.NET 4.5) and it seems to work well.
I also created the Microframework application (SDK 4.3). Basically the application sends commands to the device (as emulated) via the SPI bus, It sends 16 bit commands to control a MAXIM 7219 chip.
I seem to have gotten the communication between emulator an app right from the examples. So, I can click on a button on the emulator which causes an interrupt to be processed on the app (Emulator to App comms). Also the application sends commands via SPI to the emulator (no actual device yet). My emulator receives the SPI commands and acts accordingly to update the custom UI. I also have a form that shows the registers of the device which has SPI (slave) and see that the commands are received.
The problem is... If I add initialization code in the app that sends initialization commands via SPI then the whole thing crashes. If I omit the initialization code (sent by SPI) and simply assume everything is initialized then I can interact with the emulator.
So to my question, how can one debug these things? when I enabled the initialization code sent to my device the emulator UI appears, I see in the Output Windows "found emulator!..." and then I briefly see a bunch of messages, the thing crashes and the whole output window is ERASED leaving me with absolutely no clue as to what went wrong.
I put a breakpoint on the call to the initialization code which is invoked in Program.cs then it doesn't even break, it craps out erases all output and no clue.... If I remove that call to the initialization then 99% of the times it starts and works. But usually the 1st time it crashes (same modus operandi of erasing all useable output) and the next time it runs fine.
How can I debug this???? I am not even using an actual hardware device. Why are the breakpoints ignored in DEbug mode?