Difference between revisions of "Glu-MCU"

From RevSpace
Jump to navigation Jump to search
(Programming)
 
(4 intermediate revisions by the same user not shown)
Line 20: Line 20:
  
 
===== Programming =====
 
===== Programming =====
 +
Most of this has been figured out by Denni, so thank you Denni for helping me with this!
 +
 +
You first need to install pymcuprog through python, you can use pip for instance.
  
 
For programming I've used platformio. Install the following platforms Atmel AVR and Atmel megaAVR.
 
For programming I've used platformio. Install the following platforms Atmel AVR and Atmel megaAVR.
 
When starting a new project, use the AVR64DD32 board.
 
When starting a new project, use the AVR64DD32 board.
  
Change the platformio.ini file
+
Change the platformio.ini file after creating a new project.
  
 
<source>
 
<source>
Line 56: Line 59:
 
In the file "wiring_analog.h" replace line 72 with: <source>if (!(pin == ADC_DAC0 || pin == ADC_GROUND || pin == ADC_TEMPERATURE || pin == ADC_DACREF0 || pin == ADC_VDDDIV10 || pin == ADC_VDDIO2DIV10))</source>
 
In the file "wiring_analog.h" replace line 72 with: <source>if (!(pin == ADC_DAC0 || pin == ADC_GROUND || pin == ADC_TEMPERATURE || pin == ADC_DACREF0 || pin == ADC_VDDDIV10 || pin == ADC_VDDIO2DIV10))</source>
  
Why this works and if it can cause problems (with other chips of) this series is not clear.
+
Why this works and if it can cause problems with (other chips of) this series is not clear.
  
 
Now try to upload again, it should succeed.
 
Now try to upload again, it should succeed.
 +
 +
===== Example program =====
 +
This program prints a line over and over again to serial port 0. (Pin A0 = TxD, pin A1 = RxD.)
 +
 +
<source>
 +
#define F_CPU  24000000
 +
 +
#include <Arduino.h>
 +
 +
void setup(void){
 +
    //Set clock to 24MHz
 +
    CCP = CCP_IOREG_gc;
 +
    CLKCTRL.OSCHFCTRLA = CLKCTRL_FREQSEL_24M_gc;
 +
 +
    //Set up UART0
 +
    Serial0.begin(9600);
 +
    sei();                                  //Global interrupt enable
 +
}
 +
 +
int main(void)
 +
{
 +
    setup();
 +
 +
    while(1){
 +
        Serial0.println("OwO you are cute! <3");
 +
    }
 +
}
 +
</source>

Latest revision as of 17:05, 9 October 2022

Project Glu-MCU
Glu-mcu.jpg
General purpose MCU board with the AVR64DD32 controller
Status In progress
Contact Glu
Last Update 2022-10-09
I use the Glu-MCU as a better replacement for Arduino pro mini boards

The Atmega328 or Atmega32U4 boards nowadays are either hard to get or expensive. And the microcontroller is kinda old.

That's why I decided to make a nice and simple alternative board with the much more powerful AVR64DD32 microcontroller.


There is not much on this board, only the necessities. For programming the UPDI is broken out on the top of the PCB. There is a resistor on the PCB as well so you can connect it directly to any TTL USB serial converter. For programming connect VDD to 3,3V or 5V, GND to GND, OUT to the Rx and IN to the Tx of the serial converter. pymcuprog can program the device in a few seconds.


On the photo I already connected a 4 pin header to VDD, GND, A0 and A1, I use it for debugging via serial. The pin A0 is the standard Tx pin and A1 is the standard Rx pin of USART0.

Programming

Most of this has been figured out by Denni, so thank you Denni for helping me with this!

You first need to install pymcuprog through python, you can use pip for instance.

For programming I've used platformio. Install the following platforms Atmel AVR and Atmel megaAVR. When starting a new project, use the AVR64DD32 board.

Change the platformio.ini file after creating a new project.

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:AVR64DD32]
platform = atmelmegaavr
board = AVR64DD32
framework = arduino

# Everything from here is NOT auto-generated
upload_protocol = custom
upload_port = /dev/ttyUSB0 # Define this yourself, for some reason when upload_protocol = custom, $UPLOAD_PORT does not get defined automatically, no clue why

# Wipe and write .hex using pymcuprog
upload_command = pymcuprog write -d $BOARD_MCU -t uart -u $UPLOAD_PORT -f $SOURCE --erase --verify

Then upload your project.

It will show some errors in files. In the file "core_devices.h", linked in the errors, replace line 419 with:

#elif   (PROGMEM_SIZE == 0x20000 && (defined(__AVR_DA__) || defined(__AVR_DB__))) || (PROGMEM_SIZE == 0x10000 && (defined(__AVR_DD__) || defined(__AVR_DU__)))

In the file "wiring_analog.h" replace line 72 with:

if (!(pin == ADC_DAC0 || pin == ADC_GROUND || pin == ADC_TEMPERATURE || pin == ADC_DACREF0 || pin == ADC_VDDDIV10 || pin == ADC_VDDIO2DIV10))

Why this works and if it can cause problems with (other chips of) this series is not clear.

Now try to upload again, it should succeed.

Example program

This program prints a line over and over again to serial port 0. (Pin A0 = TxD, pin A1 = RxD.)

#define F_CPU   24000000

#include <Arduino.h>

void setup(void){
    //Set clock to 24MHz
    CCP = CCP_IOREG_gc;
    CLKCTRL.OSCHFCTRLA = CLKCTRL_FREQSEL_24M_gc;

    //Set up UART0
    Serial0.begin(9600);
    sei();                                  //Global interrupt enable
}

int main(void)
{
    setup();

    while(1){
        Serial0.println("OwO you are cute! <3");
    }
}