How to use the Pro Mini XL or Atmega 1284p with PlatformIO

by | Sep 18, 2020 | 0 comments

Adding a New Board Library

Following the steps below will enable the PlatformIO extension in Visual Studio Code to compile and upload code to an Atmega 1284p chip or Pro Mini XL board.

Note: If you already have the Atmel AVR platform installed in PlatformIO, you can skip ahead to step 8…

Step 1:  Launch Visual Studio Code.

I’m using version 1.49 in the screenshots that follow.

Visual Studio Code with PlatformIO Extension Installed

Step 2:  Click on the PlatformIO extension button.

Note:  If you don’t see the button highlighted below, the PlatformIO extension may not have been installed correctly.  See this link for help.

Visual Studio Code: PlatformIO Extension Button

The follow quick access menu should appear…

PlatformIO Quick Access Menu

Step 3:  Select the Platforms option from the PlatformIO Quick Access menu.

PlatformIO Quick Access Menu: Platforms Option

The following new window should appear next to the quick access menu…

PlatformIO Platforms Window

Note:  Any existing platforms you have already installed will be listed here.

Step 4:  Click on the blue Install Embedded Platform button.

PlatformIO: Install Embedded Platform

The Embedded tab should now be displayed in the existing window.

PlatformIO Embedded Platforms Window

Step 6:  Type the following in the “Filter platforms by name…” dialog box:

avr

And select the Atmel AVR platform when it is displayed.

Filtering for the Atmel AVR Platform

Information about the Atmel AVR platform should now be displayed in the existing Embedded tab.

Note: Atmel AVR platform version 2.2.0 is being shown in the screenshot below.

Atmel AVR Platform Information

Step 7:  Click the blue Install button to download and install the Atmel AVR platform.

Installing the Atmel AVR Platform

The Atmel AVR platform will now be installed and the following message will be displayed if the installation completes successfully:

Note: Click the blue OK button to close the message window.

Atmel AVR Platform Successfully Installed

Step 8:  Click on the Installed tab to display information about the newly installed Atmel AVR platform.

Note: If you have more than one platform installed, you will need to specifically select the Atmel AVR platform by clicking on it in the listing after the tab is clicked.

Atmel AVR Platform: Select Installed Platforms

You should see something like the following displayed about the Atmel AVR platform under the Installed tab:

Atmel AVR Platform: Installed Information

Step 9:  Click on the blue Reveal button to open the directory where the Atmel AVR platform has been installed.

Atmel AVR Platform: Reveal Button

Your operating system should now open a directory listing that looks something like the following:

Note:  If you have any additional platforms already installed, they will be listed here.

Atmel AVR Platform: platforms Directory Listing

Step 10:  Navigate up one level to the .platformio directory – it should look something like the following:

Atmel AVR Platform: platforms Directory Listing

Step 11:  Download and extract the ZIP archive from this Github repository into the above directory.

The ZIP archive contains the following files and internal structure:

Atmel AVR Platform: Pro Mini XL ZIP Archive Listing

Step 12:  Select the Open option from the PlatformIO Quick Access menu.

PlatformIO Quick Access Menu: Open Option

The PlatformIO home page should now be displayed:

PlatformIO Home

Step 13:  Click the New Project button under the Quick Access options.

PlatformIO Home: New Project Button

The PlatformIO Project Wizard should now be displayed:

PlatformIO Project Wizard

Step 14:  Select the following options in the Project Wizard window dialog boxes and then click the blue Finish button:

     Name: (Choose Your Own Project Name)
    Board:  ATmega1284P (Microchip)
Framework:  Arduino
 Location: (Use Your Default Location or Specify a Path)
PlatformIO Project Wizard: Example Project

PlatformIO will now create a new project using the Atmel AVR platform default templates for the selected board (ATmega1284P) and framework (Arduino).

PlatformIO Project Wizard: Creating A New Project

After PlatformIO has finished, the Explorer window will show the project structure and the right hand window will return to the PlatformIO home page.

PlatformIO Project Wizard: New Project Created

Step 15:  Click on the platformio.ini file in the Explorer window to open the file for editing.

Explorer: Select platform.ini File

The platformio.ini file should be opened and shown in a new tab in the right hand window.

Project platform.ini File

Step 16:  Copy-and-paste the contents of this template platformio.ini file and edit the following lines where necessary:

If you will be uploading using your FTDI programmer, you may need to update line #40 with your programmers’ COM port.

; Upload serial port is automatically detected by default. Override by uncommenting the line below
upload_port = COM5

If you will be uploading using your In-circuit Serial Programmer (ISP/ICSP), you may need to update line #51 with your programmers’ protocol and line #53 with your programmers’ COM port.

; Upload using programmer
upload_protocol = avrispv2
; Aditional upload flags
upload_flags = -PCOM4

Note:  You may need to uncomment the lines (removing the semi-colon “;” character) where necessary.

Project platformio.ini File After Editing

Step 17:  Open the project “src” (Source) listing in the Explorer window.

Select Project src (Source) Listing

You should see the listing expand with a main.cpp file in the Explorer window.

Project src (Source) Listing

Step 18:  Select the main.cpp file from the “src” listing in the Explorer window to view the source code.

Select main.cpp File

You should see the main.cpp source code displayed in a tab on the right hand window.

Blank main.cpp Code

Step 19:  Copy-and-paste the contents of this example main.cpp file into the main.cpp source code of the new project:

Note: The example main.cpp file simply blinks the Pro Mini XL’s LED and displays UART messages whilst doing so.  Using this example code will test whether the platform has been configured correctly.

Example main.cpp Code

Step 20:  Click on the PlatformIO extension button.

Select PlatformIO Extension Button

You should now see a list of PlatformIO Project Tasks together with the previous list of Quick Access options:

PlatformIO Project Tasks

Click on the Upload and Monitor option in the Project Tasks list:

PlatformIO Project Tasks: Upload and Monitor

PlatformIO should now compile the project source code and attempt to upload it to the Pro Mini XL via the configured programmer.

Assuming the upload was successful, PlatformIO will then start the monitor to display the UART messages:

Upload and Monitor Successful

You should now be able to use your Pro Mini XL with PlatformIO.

Enjoy!

Any feedback on the above instructions would be much appreciated!

0 Comments

Submit a Comment

Your email address will not be published.