Getting Started with nanoFramework – The Infinite Loop (Part 3)

Introduction

Having reached here itself is a huge achievement. Congratulations for successfully completing Part 1 and Part 2 of this blog series. You are just one step away from writing code and debugging your code.

Preparation required

First, you need to install the nanoFramework visual studio extension. So start Visual Studio, search for the nanoFramework extension and install it.

Next, you need a way to connect the MCU with Visual Studio. Remember, in Part 2 you flashed the nanoBooter.hex and nanoCLR.hex using the STLink utility. But to code, deploy and debug on the MCU using Visual Studio (for now), if you are using the NUCLEO boards, you need to do a bit more.

Take a USB cable with at-least one side having USB-A connector. This will go into the PC. Don’t just yet plug it in. Cut one side and expose the 4 wires. Hopefully, they should be color coded appropriately (Red is +Vcc, White is D-, Green is D+ and Black is Gnd). Strip the wires and solder breadboard pins on the ends. Take a breadboard and plug-in the 4 pins. Against the green and white pins, put a 33 Ohm resistor (they are used for current limiting. If you do not use them, you run the risk of bricking your STM32 MCU). See the image below:

vs-nanofw-board-connection

Now do the following:

  1. Connect point #1 (marked in image above) , the D- pin of the USB, with PA11 of your NUCLEO board. The PA11 pin is USB_DM/USART6_TX
  2. Connect point #2 (marked in image above), the D+ pin of the USB, with PA12 of your NUCLEO board. The PA12 pin is USB_DP/USART6_RX
  3. Connect point #3 (marked in image above) with any Gnd pin of your Nucleo board.
  4. Do not connect the “Red” pin (Vcc).
  5. Now connect the USB A with your PC.

The above connections will enable Visual Studio and MCU connection for code deployment and debugging. We need to power the board though. So, we will continue to use the on-board mini-B connector for powering. Thus, connect another USB-A to your PC and the other end to the on-board mini-B connector. (You can also provide external power to Nucleo board, but again, keep that for later)

With the above scheme, you should now have your Nucleo board connected to your PC via 2 USB cables. One for power (via mini B) and one for Visual Studio communication via PA11/PA12.

Open visual studio and open the device explorer. You should see something similar to the image below:

nanofw_device_explorer

If you see this, you are in good shape ! Click on the ping button (first one) and you should see success message in the output window. Click on the next button (device capabilities) and you should see messages logged in the console.

Now you are ready to code. I wrote a simple while loop to test debugging and it looks like the one shown below:

nano_debug

I know I have skipped over many smaller details, but then, you can write to me in case you face issues, and I will try to help.

Thanks and enjoy embedded C# !

Advertisements

2 thoughts on “Getting Started with nanoFramework – The Infinite Loop (Part 3)

  1. Just a note : the hardware preparation above is only needed for Nucleo boards that don”t expose a second USB connector (which is the case for the 411RE, for example).
    Other Nucleo’s like F746ZG (again for example) do not need that : you simply connect the two USB connectors to your PC and Visual Studio Device explorer will see your nanoFramework board.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s