Calendar

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

Active supporter of WikiPedia
Support Wikipedia

Geocaching

Profile for uwezi

VSCode for everything

Atmel Microchip Studio

1 1/2 years ago now I have finally abandoned Microchip (Atmel) Studio for programming AVR microcontrollers.

I have been using Atmel Studio from the very first day I have been programming AVR microcontrollers and I have been following it through the version 4 to 7. But already a couple of years ago I had been looking into PlatformIO, but I failed to configure it for anything but Arduino-programming, which I didn’t want to do primarily.

PlatformIO

However, in the meantime I have been programming more and more Python as well, and discovered the advantages VSCode has over IDLE which I had been using so far. So together with my students I looked again into VSCode and PlatformIO. By default it is still configured for the Arduino framework ans as such it should completely replace the Arduino IDE – honestly, I cannot understand why anyone still uses the classic Arduino IDE, when VSCode with PlatformIO offers great syntax highlighting, auto-completion, inline-help,…

But how can I use PlatformIO for my full toolchain from writing the code to uploading it using avrdude? The secret lies in the configuration file platformio.ini, which is part of every PlatformIO project.  A student of mine showed me how to configure platformio and I had to find out that the avrdude which comes with platformio is somewhat limited in its functionality.

Configuration

The necessary changes to the project’s platformio.ini which I use are:

For an ATmega328 with 1 MHz

[env:ATmega328P] 
platform = atmelavr 
board = ATmega328P 
board_build.f_cpu = 1000000UL 
upload_protocol = custom 
upload_flags = -pm328p 
  -Pusb 
  -B4 
  -cusbasp 
upload_command = "C:\Program Files (x86)\AVRDUDESS\avrdude.exe" $UPLOAD_FLAGS -U flash:w:$SOURCE:i

For an ATmega328 with 8 MHz

[env:ATmega328P] 
platform = atmelavr 
board = ATmega328P 
board_build.f_cpu = 8000000UL 
upload_protocol = custom 
upload_flags = -pm328p 
  -Pusb 
  -B4 
  -cusbasp 
upload_command = "C:\Program Files (x86)\AVRDUDESS\avrdude.exe" $UPLOAD_FLAGS -U flash:w:$SOURCE:i

For an ATtiny25 with 8 MHz

[env:ATmega328P] 
platform = atmelavr 
board = attiny25 
board_build.f_cpu = 8000000UL 
upload_protocol = custom 
upload_flags = -pt25 
  -Pusb 
  -B4 
  -cusbasp 
upload_command = "C:\Program Files (x86)\AVRDUDESS\avrdude.exe" $UPLOAD_FLAGS -U flash:w:$SOURCE:i

For an ATtiny13 with 1.2 MHz

[env:ATmega328P] 
platform = atmelavr 
board = attiny13 
board_build.f_cpu = 1200000UL 
upload_protocol = custom 
upload_flags = -pt13 
  -Pusb 
  -B4 
  -cusbasp 
upload_command = "C:\Program Files (x86)\AVRDUDESS\avrdude.exe" $UPLOAD_FLAGS -U flash:w:$SOURCE:i
My videos on the topic


 

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>