How to use the Pro Mini XL or Atmega 1284p with PlatformIO
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.
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.
The follow quick access menu should appear…
Step 3: Select the Platforms option from the PlatformIO Quick Access menu.
The following new window should appear next to the quick access menu…
Note: Any existing platforms you have already installed will be listed here.
Step 4: Click on the blue Install Embedded Platform button.
The Embedded tab should now be displayed in the existing 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.
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.
Step 7: Click the blue Install button to download and install 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.
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.
You should see something like the following displayed about the Atmel AVR platform under the Installed tab:
Step 9: Click on the blue Reveal button to open the directory where the Atmel AVR platform has been installed.
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.
Step 10: Navigate up one level to the .platformio directory – it should look something like the following:
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:
Step 12: Select the Open option from the PlatformIO Quick Access menu.
The PlatformIO home page should now be displayed:
Step 13: Click the New Project button under the Quick Access options.
The PlatformIO Project Wizard should now be displayed:
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 will now create a new project using the Atmel AVR platform default templates for the selected board (ATmega1284P) and framework (Arduino).
After PlatformIO has finished, the Explorer window will show the project structure and the right hand window will return to the PlatformIO home page.
Step 15: Click on the platformio.ini file in the Explorer window to open the file for editing.
The platformio.ini file should be opened and shown in a new tab in the right hand window.
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.
Step 17: Open the project “src” (Source) listing in the Explorer window.
You should see the listing expand with a main.cpp file in the Explorer window.
Step 18: Select the main.cpp file from the “src” listing in the Explorer window to view the source code.
You should see the main.cpp source code displayed in a tab on the right hand window.
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.
Step 20: Click on the PlatformIO extension button.
You should now see a list of PlatformIO Project Tasks together with the previous list of Quick Access options:
Click on the Upload and Monitor option in the Project Tasks list:
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:
You should now be able to use your Pro Mini XL with PlatformIO.
0 Comments