Preparing a project to use the Serial Port in either Release or Debug mode

by Visual Micro 29. August 2013 10:57

This document applies more to boards such as Maple than Arduino but is a useful reference for all

Arduino is quite tollerant but boards such as Maple will crash if we use the SerialUSB.begin() command in our code more than once. Since the debugger, whichever port is it using, issues a SerialUSB.begin() we need our user code to only issue a SerialUSB.begin() when in release mode (non-debug)

The examples below show how to conditionally add code to a project based upon the release/debug (Micro Debug=True) setting using a define called VM_DEBUG.

Another example shown below is the use of a delay when the board first starts. Normally Arduino boards do not need this delay but we found that boards such as maple only work reliably over serial with an initial delay. The debugger automatically enforces this delay so the example shows how to add the delay for normal release mode use of the serial port. The example shows a 2 second delay (2000 milis)

void setup()

{

//     pinMode(BOARD_LED_PIN, OUTPUT);

//if we are not starting in debug mode we can optionally do stuff

//maple gets very upset if both the debugger and user code issue a "begin()" request

//so for maple we let the debugger initialise the port

//for arduino it doesn't matter so much. we can use the project property called RemoteSpeed to force the debugger to use something other than 115200

#if !defined(VM_DEBUG)

//maple uses SerialUSB by default

       SerialUSB.begin();

//for arduino and hardware that requires a baud rate

       //Serial.begin(115200); 

//maple likes this delay for Serial or the first serial messages are lost

       delay(2000);           

//an example

       SerialUSB.println("Starting Maple in release mode");

//for arduino/teensy/msp430

       //Serial.println("Starting Arduino in release mode");

#endif

}

void loop()

{

// Turn the LED from off to on, or on to off   

//toggleLED();          

#if defined(VM_DEBUG)

       SerialUSB.println("Running in debug mode");

#else

       SerialUSB.println("Running in release mode");

#endif

       delay(200);

}

//The example above also demonstrates use of the Visual Micro "Debug Mode" define (VM_DEBUG)

Maple Leaflabs and STM32 for Visual Studio

by Visual Micro 27. August 2013 14:30

2013: Editors Note: Our impression of the Maple Ide is that it is not yet as mature as some of the other solutions and the usb drivers stop working frequently. Maple has been added to the free plugin and the debugger by user request. Our personal option is that Maple is not very easy to use or support and might lead to fustration for less experienced users. If you find this not to be the case then please contact us.

14th Jan 2013: Apparently build and upload now fully supported for maple REV6 boards (thanks Yuri). Debug trace/break is supported. Other maple ide boards have not been tested. We would appreciate feed back to the forum from experienced users. 

Our Personal Maple Observations and Tips

When working with Maple SerialUSB in your code and also using the debugger please read these important tips

On windows 7 64 bit we found that the leaflabs serial port would periodically stop working. We have not tested other versions of windows

On windows 8 the Maple usb can completely disappear.

Maple authors have announced reduced support for windows

The Maple IDE can be downloaded from here

To install the usb drivers from the maple ide folder, win8 users will need to switch to allowing unsigned usb driver installation

 

Stm32 Usb Debug - Trace Mode

To use Leaflabs compatible hardware with Visual Micro please download the Maple Ide

Known Debugger Issue on Stm32 (will be resolved asap)

The Hit Count >= settings can be used at the moment with Stm32 because it does not initialize variables correctly when in the Global space.


For example:

unsigned long myLong1 = 0L;
bool myBool = 0;

void setup() {
}

The example above will result in garbage in all bits except the first

unsigned long myLong1;
bool myBool;

void setup() {
myLong1 = 0L;
myBool = 0;
}

The example above would result in all bits being cleared and correct values of zero

Force clean compile when project defines change

by Visual Micro 22. August 2013 10:30

By default, "project defines" do not normally cause core and libraries to re-compile unless defines that are listed in boards.txt (arduino config file) have changed.

If the automatic re-build detection is not accurate enough for your needs then there are two features that will be useful:-

1) Manual

Clicking "Build>Clean" clears the cache and forces the next compile to be a full compile.

2) Automatic

It is also possible to switch on the these two project properties which will force a re-compile if any of the project defines change.


Code:

Project Defines Affect Core = True
Project Defines Affect Libraries = True

Tags:

General

How to configure Arduino for a specific Visual Studio version

by Visual Micro 19. August 2013 14:24

The Visual Micro is installer caters for Visual Studio 2008, 2010, 2012 and Atmel Studio.

It is quite common to see different versions of Visual Studio installed on the same computer, therefore it is useful to have the ability to elect which version of Visual Studio or Atmel Studio will be used for Arduino.

  • Click "Tools>Addin Manager" and you will see Visual Micro in the list along with 3 checkboxes.
  • Un-check all the checkboxes and re-start the ide to disable Visual Micro.
  • To re-enable Visual Micro the two left most checkboxes must be checked, the third checkbox is unimportant.

tip: Visual Micro user interface menus or tool bar controls might sometimes be missing after re-enabling the addin-in. In which case please click "Tools>Reset User Interface" (in ver 1308.18+). If problems persist then please follow this guide and report the problem to the forum. Thanks!

 

 

 

Energia IDE for Visual Studio

by Visual Micro 2. August 2013 16:33

August 2016 - Energia 1.6 Release w/ Board Manager and Library Manager

Important Installation Bullets

  • This documention is in the process of being rewritten and updated. Energia is support in Visual Studio 2-12 to the latest v15. Gdb debug is currently only supported in Visual Studio 2015 although might work in the new version v15
  • note: Microsoft have shortened the Visual Studio version number and aligned with their internal version numbers. This is why the latest version is called 15, when the previous version was called 2015. It's going to be a bit confusing for a year or so.
  • Install Tip: Visual Studio 2015 and above, the C++ compiler is optional during installation. Energia and Arduino use C++ so you need to make sure C++ is installed. If you didn't install c+ when VS was installed then update via "control panel>add or remove programs>visual studio>change>custom". And while you doing that install the Android Tools for Visual Studio so you can try the GDB debugger.
  • Download the Energia IDE - Arduino Compatible. Texas Instruments Quality.

Review of Tiva C Series 123G

I don't sell hardware at visualmicro.com and don't benefit from recommending hardware. I just post about the things that we have personally found impressive which is rare :)

The Tiva C Series is certainly the best workhorse I have seen for years. Flexible, fast, accurate, well designed, well packaged and at a fraction of the cost of significantly inferior boards.

I paid $15 USD for my board from a retailer! I have never seen a program build and upload so quicky. Impressive. Never seen GDB debugging launch so quickly.

Code Sample - Change the LED color

//RED

analogWrite(PF_1, 700);

//GREEN

analogWrite(PF_2, 250);

//BLUE

analogWrite(PF_3, 50);

 

Example Features

The ARM Cortex-M4F Based MCU TM4C123G LaunchPad Evaluation Kit (EK-TM4C123GXL) offers these features:

  • High Performance TM4C123GH6PM MCU:
    • 80MHz 32-bit ARM Cortex-M4F CPU
    • 256KB Flash, 32KB SRAM, 2KB EEPROM
    • Two Controller Area Network (CAN) modules
    • USB 2.0 Host/Device/OTG + PHY
    • Dual 12-bit 2MSPS ADCs, motion control PWMs
    • 8 UART, 6 I2C, 4 SPI
    • Ultra Bright RGB LED (Analog Pins: PF_1, PF_2, PF_3)
    • 2 x User Buttons SW1/SW2
  • On-board In-Circuit Debug Interface (ICDI)
  • USB Micro-B plug to USB-A plug cable
  • Preloaded RGB quick-start application
  • ReadMe First quick-start guide

You can try the debug for the 123 and 129 boards in the cureent release of Visual Micro. In the next release the following settings are automatically applied based on selected board but here is how to manually configure.

If you are using the paid/pro version add one of these properties to the local project board.txt. Make sure the Andoid Tools for Visual Studio are installed which means you have a gdb debugger installed. then press "F5" or "Debug>Start Debugging".


#LaunchPad (Tiva C) w/ tm4c123 (80MHz)
build.openocdscript=board/ek-tm4c123gxl.cfg

OR (depending on your board model)

#LaunchPad (Tiva C) w/ tm4c129 (120MHz)
build.openocdscript=board/ek-tm4c1294xl.cfg

note to existing users. visual micro .vcxproj project files created prior to 22 of July 2016 will show an error when attempting to start gdb. A simple fix adding two lines into older vcxproj files is described in the draft GDB Debugging release notes (alternatively the project can be deleted and the sketch re-opened which recreates the project file backup the project before deleting).

  • Tiva™ C Series TM4C123G LaunchPad

 

 

msp430 (LaunchPad)

The Energia installation guide provides most of the information that you require. It can be found here

If upload fails after install we can view "windows device manager" to determine if you have unknown devices showing (after connecting your board). LaunchPad 430 usb drivers are available via the getting started link above but can also be found here

Stellaris (StellarPad)

When we plugged a StellarPad into a windows 7 64 machine we found that in device manager there were 3 "debug" drivers showing with yellow exclaimation marks.

Attempts to upload a program to the board failed with this error:-

Error claiming interface -12

Failed!

The solution was to update the driver for each of the 3 entries using the TI drivers available here

Options: Visual Micro + USB or GDB Debugging


 

Switch off Arduino Automatic Prototype Generation

by Visual Micro 5. June 2013 07:59

It is possible to turn off automatic prototype generation in Visual Micro by setting the project property called "Auto Generate Prototypes=False".

The following code will not compile with Arduino or the default Visual Micro, because the function prototype for doLogic() would be automatically inserted before the enum definition.

The only way around this previously was to define your enum in a header which you then included in the main sketch, which is annoying if you want to keep everything all tidy in one file.

Code:


typedef enum {RANDOM, IMMEDIATE, SEARCH} StrategyType;

void doLogic(StrategyType s)
{
//code
}

void loop()
{
doLogic(RANDOM);
doLogic(IMMEDIATE);
doLogic(SEARCH);
}


Extract via capnBry in the forum

How to start the Atmel Studio Arduino simulator

by Visual Micro 5. June 2013 07:44

Visual Micro has a new facility due soon to make this process easier.

In the meantime this document describes how you can run the Atmel Studio simulator with an Arduino project.

NOTE: in 1406+ version of Visual Micro step 1) can be ignored because the compiler copies the output files to the local sketch debug/release folder

1) Switch Tools>Options>Visual Micro>Compiler>Always Show Build Path

2) Build your Arduino project, copy the path that appears in the output window to the windows clipboard (without the file:// prefix)

3) In a new instance of Atmel Studio, click "File>Open Object File For Debugging".

4) When prompted paste the build path and "name of your sketch.elf" into the "Specify Object F To Debug" field (example: c:\user\appdata\vmicro\sketch1\board\sketch1.elf). Give the sim project a name and click OK

4) When Atmel opens the new sim project click "No Tool" on the tool bar and select "Simulator" from the "Debugger/Programmer" drop down list.

5) Start debugging (Debug>Start debugging and break),  the sim will run with your Arduino program

That's it!

nb: Some avr processors are not yet supported by the Atmel Studio Sim

Arduino Code Snippets

by Visual Micro 2. June 2013 18:14

Visual Studio has a powerful snippet and macro system but the VisualAssistX snippet manager in Atmel Studio is just awsome!

Extracted from http://www.wholetomato.com/products/features/vasnippets.asp

Introduction to VA Snippets

VA Snippets are reusable code templates that allow you to quickly insert commonly used code fragments or to surround selected portion of code in the text editor. Used code templates may contain placeholders replaced dynamically, when the snippet is applied, by the meaningful blocks of code. VA Snippets are easy to create, simple to use and allow you to apply extra parameters taken from the context of the surrounding code, from environment variable or simply from your input.

The main advantage of VA Snippets is that they can be modified easily (no XML) to satisfy current needs and used immediately after modifications. Also by modification of specialised VA Snippets you can change behavior of each refactoring and code autocompletion related feature of Visual Assist.

Snippet definition in VA Snippet Editor:
Snippet applied in text editor:

 

Groups of snippets

VA Snippets can be divided into following groups:
Note: one snippet may appear in multiple groups if it meets the requirements of the each individual group.

 

  • Snippets using clipboard- Snippets with $clipboard$
    Includes snippets, where $clipboard$ placeholder is used within the body of the snippet definition.
    During applying of these snippets, a text contained in the clipboard is used as a source for the replacement of the$clipboard$ placeholders.
    User can define new such snippets.

      

 

  • Snippets for Surround With - Snippets with $selected$
    Includes snippets, where $selected$ placeholder is used within the body of the snippet definition.
    During applying of these snippets, the current selection in the text editor is used as a source for the replacement of the$selected$ placeholders.
    User can define new such snippets.

      

 

  • Snippets for Suggestion Lists - Snippets with shortcut
    Includes all snippets with the assigned shortcut.
    Their entries appear in suggestions list when you type their shortcuts in text editor.
    The result is inserted (replaces a written shortcut) after user’s confirmation of the selected snippet entry by pressing Tab orEnter key on keyboard.
    User can define new such snippets.

      

 

  • Refactoring snippets
    Specialized snippets used by Visual Assist X for refactoring purposes.
    Code templates contain context and refactoring operation specific placeholders.
    Titles of these snippets always begin with word Refactor.
    User can customize, but cannot create new such snippets.

      

 

  • Smart Suggestions
    Highly context-aware code hints suggesting text you're likely to type in the current context.
    With Smart Suggestions, C++ users enjoy C#-like autocompletion for several common scenarios.
    Code of snippets contains lines, where each line of code means one entry in suggestions lists.
    Each of these lines represents individual code template, so you can use expandable placeholders in their definitions.
    User can edit all such snippets, but can create only those for datatypes, so can not create context related.
    Title of these snippets must begin with keyword SuggestionsForType.

 

Supported placeholders

Placeholders in VA Snippets are keywords to be replaced by meaningful code enclosed by markers. There are two main types of placeholders - those enclosed in dollar '$' signs and Environment Variables enclosed in percent '%' signs.  Remember, that those enclosed in dollar signs are case-sensitive and Environment variables are case-insensiteve, so take care of it during editing or creating snippets.

Supported placeholders are:

  • Reserved Strings
    Predefined placeholders maitained by Visual Assist, their name is enclosed in $ signs.
    User can affect their content only by current IDE settings, project properties, system settings or by positioning caret to specific code context.
    For example, $clipboard$ will always expand to the content of clipboard, $DATE$ will always expand to current system date and so on.
    This group also inlcudes special placeholders usable only within Refactoring snippets.
    Click here to see the complete list of reserved strings with their meaning
  • User Prompts
    User-defined placeholders placed by enclosing meaningful keyword in $ signs.
    To work properly, used keyword must be equal to all its references within snippet definition, and must not be included inReserved strings.  
    During applying process of snippets containing such placeholders, user is prompted for actual values to be used as a result of their expansion.
    The maximum number of user prompts within one snippet is limited to eight.
    Click here for more info about User prompts in VA snippets.
  • Environment Variables 
    In VA Snippets, environment variables are placed as their names enclosed in % signs.
    Unlike other placeholders are case-insensitive, and are expanded before applying of another types of placeholders.
    That enables also a usage of environment variables as a default values in the user defined placeholders.
    Click here for more info about Environment Variables in VA snippets.

 

First touch - "for" loop

To try how to use VA Snippets to place a “for" loop do following:

  • Ensure that you have opened a C/C++ or a C# project.
  • Place the caret in the text editor to position, where you want to insert a new “for" loop.

    

  • From IDE’s main menu choose VAssistX -> Insert VA Snippet...

      

  • In appeared menu choose VA Snippets with shortcuts and then select entry “for loop forward”.

  • Dialog with two input boxes opens:
    The input box labeled “Index” asks for a name of the index variable for the scope, usually programmers use “i”.
    The input box labeled “Length” asks for a number of iterations, so insert for example 100.

    

  • Click on OK button or press Enter key on keyboard to confirm.
    This is the result:

    

Now you are ready to insert a “for" loop in simpler way - using shortcut.

  • Move the caret to the position, where you want to insert another “for" loop.
  • In the text editor write “forr” (double “r”) - the shortcut of the predefined For loop snippets.
  • In the suggestion list (which is a Visual Assists’s replacement of intellisense in Visual Studio)
    you should see entries: For loop forwardFor loop reverse and perhaps some other suggestions.
  • Select entry For loop reverse and confirm by pressing Tab or Enter key.

    

  • Similar dialog as in previous case opens, so insert “i” for index and 100 for length.

  • Click on OK button or press Enter key on keyboard to confirm.
    Follows both results together (current on bottom):

    

Differences between Arduino in Visual Studio and Atmel Studio

by Visual Micro 26. May 2013 16:12

This document is designed to be my own personal observations of note worthy functional differences between the development of Arduino programs in Visual Studio and Atmel Studio.

Both Visual Studio and Atmel Studio provide indentical Arduino compile, upload and debugging features.

Visual Studio Pro has more features for advanced users and if you already own a copy of Visual Studio it would be prefered.

Visual Studio 2008 and 2013 both open quickly and provide high speed intellisense (not perfect but good)

The plugin for Atmel Studio is currently lacking a few minor features such as "project>show all arduino files". This feature is very useful for explore library sources within the project and also aids the class explorers.

Atmel Studio lacks some of the customization features of Visual Studio such as macros.

Visual Studio "disables" source code based on #defined conditions, this is very useful but can also be fustrating because it also disabled intellisense within the disabled code. Atmel Studio does not do this.

Visual Studio intellisense code suggestions are more accurate. Example: you will see Serial,Serial1 etc for mega 2560 and just "Serial" for Uno, Atmel will show Serial,serial1 etc for all boards.

Atmel Studio has the simulator and various other tools.

Visual Studio intellisense understands only C++, Atmel Studio is naturally aware of the micro-controllers native language.

Visual Studio provides web authoring tools within an Arduino sketch project for web based boards such as the Yun (both Ide's support web/network compile and upload). Visual Studio Express or other web design tool can be used so this is not a huge weakness for Atmel Studio.

Atmel Studio is knows about its own micro-controllers and might have a brighter future than Visual Studio for Visual Micro

Visual Studio is required for other "non-atmel" architecures such as Energia and Chipkit

Arduino Robot and TFT Display

by Visual Micro 22. May 2013 19:22

I just read the article below about the new arduino tft that shows the code to draw a sensor value on the screen instead of serial debug :)

It is a nice little Arduino shield http://arduino.cc/en/Tutorial/TFTDisplayText

I recon the visual micro debugger could have an option to print some breakpoint data to the screen for the users. It would be a hell of a  lot easier :)

Maybe a debugger visualization can be created in c# to replicate the shield? Any offers anyone? 

#include <TFT.h>  // Arduino LCD library
#include <SPI.h>

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8  

// pin definition for the Leonardo
// #define cs   7
// #define dc   0
// #define rst  1 

// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

// char array to print to the screen
char sensorPrintout[4];

void setup() {
  
  // Put this line at the beginning of every sketch that uses the GLCD:
  TFTscreen.begin();

  // clear the screen with a black background
  TFTscreen.background(0, 0, 0);
  
  // write the static text to the screen
  // set the font color to white
  TFTscreen.stroke(255,255,255);
  // set the font size
  TFTscreen.setTextSize(2);
  // write the text to the top left corner of the screen
  TFTscreen.text("Sensor Value :\n ",0,0);
  // ste the font size very large for the loop
  TFTscreen.setTextSize(5);
}

void loop() {

  // Read the value of the sensor on A0
  String sensorVal = String(analogRead(A0));
 
  // convert the reading to a char array
  sensorVal.toCharArray(sensorPrintout, 4);

  // set the font color
  TFTscreen.stroke(255,255,255);
  // print the sensor value
  TFTscreen.text(sensorPrintout, 0, 20);
  // wait for a moment
  delay(250);
  // erase the text you just wrote
  TFTscreen.stroke(0,0,0);
  TFTscreen.text(sensorPrintout, 0, 20);
}

Arduino Advanced Build Examples

by Visual Micro 2. May 2013 12:26

Note: In releases after in 1305.01 arduino 1.5 build {variables} can optionally be used

This document is draft and subject to change. Currently using diydrones apm example

##############################################################

apm_1280.name=APM Arduino Mega 1280

apm_1280.upload.protocol=arduino

apm_1280.upload.maximum_size=126976

apm_1280.upload.speed=57600

apm_1280.bootloader.low_fuses=0xFF

apm_1280.bootloader.high_fuses=0xDA

apm_1280.bootloader.extended_fuses=0xF5

apm_1280.bootloader.path=atmega

apm_1280.bootloader.file=ATmegaBOOT_168_atmega1280.hex

apm_1280.bootloader.unlock_bits=0x3F

apm_1280.bootloader.lock_bits=0x0F

apm_1280.build.mcu=atmega1280

apm_1280.build.f_cpu=16000000L

apm_1280.build.core=arduino

apm_1280.build.variant=mega

apm_1280.build.option1=-mcall-prologues

apm_1280.build.linkoption1=-mcall-prologues

##############################################################

mytest1.name=APM Arduino Mega 2560 

mytest1.upload.protocol=wiring

mytest1.upload.maximum_size=258048

mytest1.upload.speed=115200

mytest1.bootloader.low_fuses=0xFF

mytest1.bootloader.high_fuses=0xD8

mytest1.bootloader.extended_fuses=0xFD

mytest1.bootloader.path=stk500v2

mytest1.bootloader.file=stk500boot_v2_mega2560.hex

mytest1.bootloader.unlock_bits=0x3F

mytest1.bootloader.lock_bits=0x0F

mytest1.build.mcu=atmega2560

mytest1.build.f_cpu=16000000L

mytest1.build.core=arduino

mytest1.build.variant=mega

mytest1.build.option1=-mcall-prologues

mytest1.build.linkoption1=-mcall-prologues

##############################################################

apm1_1280HAL.name=Arduino Mega 1280 HAL (Apm 1)

apm1_1280HAL.upload.protocol=arduino

apm1_1280HAL.upload.maximum_size=126976

apm1_1280HAL.upload.speed=57600

apm1_1280HAL.bootloader.low_fuses=0xFF

apm1_1280HAL.bootloader.high_fuses=0xDA

apm1_1280HAL.bootloader.extended_fuses=0xF5

apm1_1280HAL.bootloader.path=atmega

apm1_1280HAL.bootloader.file=ATmegaBOOT_168_atmega1280.hex

apm1_1280HAL.bootloader.unlock_bits=0x3F

apm1_1280HAL.bootloader.lock_bits=0x0F

apm1_1280HAL.build.mcu=atmega1280

apm1_1280HAL.build.f_cpu=16000000L

apm_SITL.build.nocore=true

apm_SITL.build.noarchive=true

apm1_1280HAL.build.option1=-mcall-prologues

apm1_1280HAL.build.option2=-DCONFIG_HAL_BOARD=HAL_BOARD_APM1

apm1_1280HAL.build.option3=-DEXCLUDECORE

apm1_1280HAL.build.linkoption1=-mcall-prologues

apm1_1280HAL.build.noarchive=true

##############################################################

apm1_2560HAL.name=Arduino Mega 2560 HAL (Apm 1)

apm1_2560HAL.upload.protocol=wiring

apm1_2560HAL.upload.maximum_size=258048

apm1_2560HAL.upload.speed=115200

apm1_2560HAL.bootloader.low_fuses=0xFF

apm1_2560HAL.bootloader.high_fuses=0xD8

apm1_2560HAL.bootloader.extended_fuses=0xFD

apm1_2560HAL.bootloader.path=stk500v2

apm1_2560HAL.bootloader.file=stk500boot_v2_mega2560.hex

apm1_2560HAL.bootloader.unlock_bits=0x3F

apm1_2560HAL.bootloader.lock_bits=0x0F

apm1_2560HAL.build.mcu=atmega2560

apm1_2560HAL.build.f_cpu=16000000L

apm1_2560HAL.build.nocore=true

apm1_2560HAL.build.noarchive=true

apm1_2560HAL.build.option1=-mcall-prologues

apm1_2560HAL.build.option2=-DCONFIG_HAL_BOARD=HAL_BOARD_APM1

apm1_2560HAL.build.option3=-DEXCLUDECORE

apm1_2560HAL.build.linkoption1=-mcall-prologues

apm1_2560HAL.build.noarchive=true

##############################################################

apm2_2560HAL.name=Arduino Mega 2560 HAL (Apm 2)

apm2_2560HAL.upload.protocol=wiring

apm2_2560HAL.upload.maximum_size=258048

apm2_2560HAL.upload.speed=115200

apm2_2560HAL.bootloader.low_fuses=0xFF

apm2_2560HAL.bootloader.high_fuses=0xD8

apm2_2560HAL.bootloader.extended_fuses=0xFD

apm2_2560HAL.bootloader.path=stk500v2

apm2_2560HAL.bootloader.file=stk500boot_v2_mega2560.hex

apm2_2560HAL.bootloader.unlock_bits=0x3F

apm2_2560HAL.bootloader.lock_bits=0x0F

apm2_2560HAL.build.mcu=atmega2560

apm2_2560HAL.build.f_cpu=16000000L

apm2_2560HAL.build.nocore=true

apm2_2560HAL.build.noarchive=true

apm2_2560HAL.build.option1=-mcall-prologues

apm2_2560HAL.build.option2=-DCONFIG_HAL_BOARD=HAL_BOARD_APM2

apm2_2560HAL.build.option3=-DEXCLUDECORE

apm2_2560HAL.build.linkoption1=-mcall-prologues

apm2_2560HAL.build.noarchive=true

##############################################################

apm_SITL.name=Apm SITL

apm_SITL.upload.protocol=wiring

apm_SITL.upload.maximum_size=258048

apm_SITL.upload.speed=115200

apm_SITL.bootloader.low_fuses=0xFF

apm_SITL.bootloader.high_fuses=0xD8

apm_SITL.bootloader.extended_fuses=0xFD

apm_SITL.bootloader.path=stk500v2

apm_SITL.bootloader.file=stk500boot_v2_mega2560.hex

apm_SITL.bootloader.unlock_bits=0x3F

apm_SITL.bootloader.lock_bits=0x0F

apm_SITL.build.mcu=atmega2560

apm_SITL.build.f_cpu=

apm_SITL.build.core=

apm_SITL.build.nocore=true

apm_SITL.build.noarchive=true

apm_SITL.build.noeep=true

apm_SITL.build.nohex=true

apm_SITL.build.nosize=true

apm_SITL.build.toolset=cygwin

apm_SITL.build.architecture=

apm_SITL.build.toolchain.path=

apm_SITL.build.command.gcc=gcc-?

apm_SITL.build.command.g++=g++-?

apm_SITL.build.command.link=g++-?

apm_SITL.build.command.run="%SKETCH_BUILD_PATH%\%SKETCH%.exe"

apm_SITL.build.default.cpp.options=-g -DF_CPU=   -Wa,-adhlns="%SOURCE_BUILD_PATH%\%SOURCE_FILE%.lst" -O0 -g -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wformat=2 -Wno-reorder -MD -MT "%SOURCE_BUILD_PATH%\%SOURCE_FILE_W_EXT%.o" -ffunction-sections -fdata-sections -fno-exceptions -fsigned-char -c -I"%SKETCH_PATH%" 

apm_SITL.build.default.c.options=-g  -DF_CPU= -Wa,-adhlns="%SOURCE_BUILD_PATH%\%SOURCE_FILE%.lst" -O0 -g -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wformat=2 -Wno-reorder -MD -MT "%SOURCE_BUILD_PATH%\%SOURCE_FILE_W_EXT%.o" -ffunction-sections -fdata-sections -fsigned-char -c -I"%SKETCH_PATH%" 

apm_SITL.build.default.s.options=-g  -assembler-with-cpp -DF_CPU= -Wa,-adhlns="%SOURCE_BUILD_PATH%\%SOURCE_FILE%.lst" -O0 -g  -MD -MT "%SOURCE_BUILD_PATH%\%SOURCE_FILE_W_EXT%.o" -c -I"%SKETCH_PATH%" 

apm_SITL.build.option1=-DCONFIG_HAL_BOARD=HAL_BOARD_AVR_SITL

apm_SITL.build.option2=-DSKETCH="\"%SKETCH%\""

apm_SITL.build.option3=-D_GNU_SOURCE

apm_SITL.build.default.link.options=-g -D_GNU_SOURCE -O0 -g -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wformat=2 -Wl,--gc-sections -Wl,-Map -Wl,"%SOURCE_BUILD_PATH%\%SKETCH%.map" -o "%SOURCE_BUILD_PATH%\%SKETCH%.exe"

Apm SITL - Cygwin Installation

by Visual Micro 27. April 2013 18:47

How to install cygwin (download the cygwin setup.exe and run using windows cmd)

setup.exe -q -R [DIR here you want it] -l [dir for packages]packages -s http://box-soft.com -P ca-certificates,make,wget,git,gcc-core,gcc-g++,gcc,git,libintl2 


If you do not have APM sources and want them ....

https://github.com/ArduPilot/ardupilot

ApmRover, copter etc. is here:  https://github.com/diydrones

Example sitl compile, just go into APMrover2, and ...

make configure

make sitl

or

make APM

But in the latter case you need the arduino environ installed and in your configure.mk file.

Resulting build location will be [cygwin]\tmp\APMrover2.build

Recommended: "remake" clone of make, because with the -n option, you can see all the commands the make file will try to issue.  Helps you see exactly what is going on.

Tags:

OEM Projects

Debug Arduino - Different USB Serial Port or SoftwareSerial?

by Visual Micro 26. April 2013 14:01

The project properties has an optional override of the serial port used for debug. LocalPort/RemotePort. For example LocalPort=COM10 and RemotePort=Serial2. Leave empty for the default which uses the standard Arduino usb/serial connection used for upload.

The local port relates to the pc and the remote port relates to the port the arduino will use for serial debug. Please note that some arduino boards have a single hardware Serial port, such as the Arduino Uno. Others such as the Leonardo have Serial, Serial1 and some such as the mega2560 have Serial,Serial1-4. For advanced users, LocalPort can also contain the name of a valid pre instantiated (prior to setup()) "compatible" object.

It is also possible to override the port speeds (LocalSpeed/RemoteSpeed). Normally the Remote and Local speeds will be the same unless remote devices such as xbee modules are being used.

If hardware serial port(s) are unavailble or if you prefer to debug using software serial then select “SoftwareSerial” from the RemoteTransport property.

Software serial defaults rx/tx to pins 7 and 8 but you can use the RemoteRX and RemoteTX project property to change to something else. (tip: In this case leave RemotePort empty)

It is recommended that speeds of 57k (recommended) or 19k are specified when using SoftwareSerial (especially if altering variables on a running microprocessor)

When using SoftwareSerial, leave the RemotePort property empty unless you already have a custom SoftwareSerial object in your code that you want the debugger to use (not recommended or tested).

You do not need to add the Arduino SoftwareSerial library to your project to debug using SoftwareSerial.

If you change the local port to a fixed value then that port will always be opened as a debugger after clicking F5 (or menu "Debug>Start Debugging").

If you want to use, for example, Serial2 for debug instead of the main serial port for debug then enter "Serial2" (without quotes) into the "Remote Port" property.

As stated earlier, SoftwareSerial allows you to define the pins to use for TX and RX. FastSerial works the same as HardwareSerial. To use FastSerial you must already have a project that initialises it then you can use the "Remote Port" property to define the name of the serial object. If "Remote Port" is empty then the "Serial" object is used by default

note: any property can be empty for defaults to apply

apm: If you are using the hardware serial ports of arducopter or arduplane then use the“FastSerial” option. 

How to connect arduino pins to the computer using rx and tx pins (or serial1,serial2, etc)

There are lots of different cables and usb/serial converts.

FTDI 5v Cable (there is also a 3v version)

...

(you might find it cheaper or a better alternative elsewhere)

Use the schematic to detrmine which two pins (rx and tx) to connect.

Rember to cross the rx/tx between pc and Arduino (rx>tx and tx>rx)

 


Usage Disclaimer

by Visual Micro 19. April 2013 16:34

THE Visual Micro SOFTWARE IS PROVIDED TO YOU "AS IS," AND WE MAKE NO EXPRESS OR IMPLIED WARRANTIES WHATSOEVER WITH RESPECT TO ITS FUNCTIONALITY, OPERABILITY, OR USE, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR INFRINGEMENT. WE EXPRESSLY DISCLAIM ANY LIABILITY WHATSOEVER FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR SPECIAL DAMAGES, INCLUDING, WITHOUT LIMITATION, LOST REVENUES, LOST PROFITS, LOSSES RESULTING FROM BUSINESS INTERRUPTION OR LOSS OF DATA, REGARDLESS OF THE FORM OF ACTION OR LEGAL THEORY UNDER WHICH THE LIABILITY MAY BE ASSERTED, EVEN IF ADVISED OF THE POSSIBILITY OR LIKELIHOOD OF SUCH DAMAGES.

Tags:

Installation

Project Property Window

by Visual Micro 13. April 2013 10:59

In versions of Visual Micro since Sept 2013 clicking the yellow question mark ? icon on the toolbar, when a sketch is open, will select the project and display the project properties (tool window).

Visual Micro currently uses the Arduino project properties tool window to provide additional settings that affect compile and/or debug

note: The property window is a dockable tool window and should not be confused with the Visual Studio "Property Pages" dialog window

How to open the project properties window?

How to manually view the proeperties window for any Visual Studio item. note: Visual Micro only provides properties when a project is selected. note: If a project is not selected the properties window can still be seen but it will contain only a few standard Visual Studio properties so ignore.

Click the project name in the solution explorer then click "View>Project Properties". In some instances of Visual Studio the properties are available on the "View>Other Windows" menu item (see below). Sometime the short cut key is F4 sometimes Ctrl+Enter. 


Arduino -D compiler defines and constants

by Visual Micro 13. April 2013 07:35

Optional defines and constants for the Arduino compiler can be specified using either of two project properties.

Defines - Project

Global defines are included in all compilations

MYDEFINE=10;MYDEFINE2=30;SOMETHING

Defines - Configuration

 

Confirguration specific defines are included in the compilation for a specific configuration such as "Release", "Degug" etc.

MYDEFINE=10;MYDEFINE2=30;SOMETHING

Note

During compilation all defines are applied as -D compiler options, so you must ensure they are unique

-DMYDEFINE=10 -DMYDEFINE2=30 -DSOMETHING 

 

Control Execution Speed With Hit Counters

by Visual Micro 16. January 2013 12:00

The Arduino Debugger can be used in a more advanced mode allowing you more control over the frequency of Break and Trace control/messages. Keep in mind that behind the scenes this debugger uses serial messages. Allowing too many messages will cause either the arduino or your pc to loose or corrupt messages and a possible slow down of cpu(s).

Placing a trace point in a fast loop() would produce too many messages. For this reason Visual Micro throttles the messages and forces the arduino to slow down.

By default, Visual Micro imposes a wait of up to 80 milliseconds between breakpoints. This value can be altered using the project property called "Throttle (ms)". A value of 0 uses the current default which is 80 ms.

The Throttle is designed for new users and/or quick tests in applications that do not require the arduino to run at full speed (except for when transmitting a debugger message).

Using the Throttle is not the recommended solution!

Instead of using the Throttle, the debugger "Hit Count" facility should be used to "smooth" debugger breakpoints and/or tracepoint message. 

Depending on the frequency and position of your Arduino breakpoints you might want to ensure the Throttle is disabled. To do this you set the project property called "Throttle Enabled=False"

You will see on the options menu for each Breakpoint a menu item called "Hit Count". Normally in windows debugging the hit count is a count of how many times the point in the code has been hit. This is the same for Visual Micro except that a counter is often not very useful. Instead we can optionally switch from a count to a millisecond interval timer.

For example:- Setting the option "Break when hit is a multiple of x" to 200 would cause the arduino to break or trace when the code it hit every 200 times. However setting the project property called "Hit Counter" to milliseconds will cause the break/trace point to execute every 200 milliseconds. 

note: when using non-breaking tracepoints the stream of debug messages are processed on the pc in batches of up to 10 per second (also depends on the amount of data). The time displayed in the pc debug trace is the time each message is processed on the pc, not the time the message was sent from the micro-controller. For example, we might use a tracepoint at 4hz (every 250ms). In this case the debug data will be an accurate reflection of the micro_controller every 4hz however the millisecond values in the pc trace might not appear enitrely consitent. 

Basic Hit Counter Information

How to disable auto update check for new plugin versions

by Visual Micro 30. December 2012 10:33

As of 30th Dec 2012 the plugin checks for updates in the background. Your private information is not transmitted during the update check however you can disable the feature via "Tools>Options>Visual Micro>System"

Alternative Serial Monitors - Arduino Project Settings Remain Unaffected

by Visual Micro 25. October 2012 13:18

The standard "Serial Port" option for Arduino performs two functions. The first to set the upload port of the current project to the selected port, the second is to set the port that the "Serial Monitor" short cut buttons open.

The "Other Serial Ports" menu allows us to open any serial port monitor without changing the current projects upload settings. This is useful if we need to quickly monitor ports other than the port used for uploads without upsetting the current arduino projects' upload settings. 

As with all Visual Micro commands each of the available serial ports will be found in Visual Studio macro list and can be used to assign shortcut keys and quick access menus and buttons. Read more Customizing the Arduino IDE in Visual Studio

Tools>Arduino>Other Serial Ports>Minotor COM[n]

Monitor other serial ports without affecting the arduino upload settings

Other port monitors may still be opened on an Arduino upload port and will be automatically detected, closed and re-opened during upload to an arduino. In this respect they work the same way as the standard serial monitor.

Modify Arduino Variables During a Debug Session

by Visual Micro 24. October 2012 14:57

Update Arduino MCU Variables During A Debug Session

 

There are three modes a breakpoint can work:

  • Disabled
    In this mode, breakpoints have no effect at all, but you can leave them in your sketch, if you want to.
  • Enabled, not halting execution
    In this mode, the breakpoint updates expression windows, trace and code windows but execution of your sketch continues without interruption.
  • Enabled, halting execution
    In this mode, when a breakpoint is hit, it halts execution of your sketch until you press [F9].

To disable Debugging/Breakpoints completely...

To enable Breakpoints...

To make breakpoints halt sketch execution when passed...

To let breakpoints continue execution of your sketch when passed...

 

Note 1: These settings become effective after a recompile/upload of your sketch
Note 2: These settings become effective immediately in your debugging session
Note A: These settings are global for all Visual Micro projects
Note B: These settings are project and configuration specific and apply to all breakpoints in the project
Note C: These settings are breakpoint specific

 

 Note:

If you chose Break/Pause = True and your sketch is halted in a breakpoint, see the link below in the "See also" section to find out how to stop the sketch at that point, recompile and upload.

Related Topics

Miscellaneous Topics

Tip: Use =? to change the value of an Arduino variable

 

The debugger supports two different modes that allow variables to be updated. It is important to understand the difference between the two modes:-

Mode 1) Debug with "Enable Break/Pause=False" - Arduino does not stop

In this mode we can alter any of the assigned writable variables at any time however the change in value will only be recognised when the BreaPoint/TracePoint is hit/passed. The order that variables are updated corresponds to the order that you update them. For example if you update var1 which is in a breakpoint hit every 10 minutes then no other updates will be applied to any other variables until the 10 minutes has been reached.

If you are updating variables in a fast loop() then, subject to your code, the updates should also be applied immediately.

Mode 2) Debug with "Enable Break/Pause=True" and "WhenHit Continue Execution = False" - Arduino stops and waits for F5/Continue

In this mode only the variables of the current breakpoint can be changed.

With the mouse, select and hover over a breakpoint in the expression window to see information about the breakpoint

In the image below the breakpoint configuration specifies variables 'i' and 'a' to be read/write and 'c' is read-only. This configuration is specified using the "WhenHit" property of the breakpoint. 

Update Arduino MCU Variables During A Debug Session