SAMG55 + OLED1 Xplained Pro Hello World!

AMG55 - recognition in the field

If you are considering working on SAMG55 Xplained Pro board here you will find some basic know-how to quickly get you started.

What you will need?

In this example I will be using SAMG55 Xplained Pro with OLED1 extension board, and Atmel Studio 7.0 with Data Visualizer addon, which requires Windows to work. This however should be similar for other board with EDBG debugger.

img

Word of explanation

Before we start taking any action:

  • EDBG - on board debugger, that will simplify debugging process, and allow us to easily program chip without any external tools.
  • ASF - Atmel Studio Framework, used for downloading and installing useful stuff, like libraries and APIs for specific extensions.

Getting started

To get to know the code, and typical project setup check out example projects, you can find there samples for many boards, their extensions and their usages. e.g. getting MAC address from WIPC1500 or finding available AP using same board.

Adding Support for extensions

Get some extension to work with your code may be tricky, and not always will work out of the box. Let’s follow the process of enabling OLED1 Xplained Pro on SAMG55 Xplained Pro, using ASF Wizard. As a starting point, im going to use example project Getting-Started Application on SAM - SAMG55 which gives us simple code that will blink on-board led (LED0). This action however can be disabled using on-board button (SW0). Our goal is to print on OLED1 display whether function is currently on, or off. To do that, we will need to add OLED1 libraries first. You could add them by hand, but there is a tool that will do that for you. Open ASF Wizard, and find there

1
SSD1306 OLED controller (component)

select it, and apply changes.

img

Now your Solution Explorer got few more files. You may add simple chunk of code in the main function:

1
2
3
4
5
6
ssd1306_init();
ssd1306_display_on();
ssd1306_clear();
ssd1306_set_column_address(40);
ssd1306_set_page_address(2);
ssd1306_write_text("Hello World");

But this will not work yet, you sill need to do some configuration. Both files to change you can find in config/ folder first one is conf_board.h In there you have to add these lines:

1
2
3
4
#define BOARD_FLEXCOM_SPI FLEXCOM5
#define CONF_BOARD_OLED_UG_2832HSWEG04
#define CONF_BOARD_SPI
#define CONF_BOARD_SPI_NPCS1

Second one is conf_ssd1306.h In which you have to change:

1
2
3
4
# define SSD1306_SPI SPI5
# define SSD1306_DC_PIN UG_2832HSWEG04_DATA_CMD_GPIO
# define SSD1306_RES_PIN UG_2832HSWEG04_RESET_GPIO
# define SSD1306_CS_PIN UG_2832HSWEG04_SS

Note, that these values are there twice, one time in if, that check whether your board is XMEGA_C3_XPLAINED or XMEGA_E5_XPLAINED, if it is, then change these values. For every other board, values can be found at the end of the file. In the same place you will find comment explaining their meaning. comment. After these changes, all you have to do is connect the board, using microUSB and connecting it to EDBG USB port, wait for Atmel Studio to find board, select tool EDBG, interface SWD and program the chip. After short amount of time, you will see “Hello World” on display, and blinking led. To make it show whether function is active or inactive, change last while loop in main.c to something like this

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
while (1) {
    if (g_b_led0_active) {
        ioport_toggle_pin_level(LED0_GPIO);
        ssd1306_clear();
        ssd1306_set_column_address(40);
        ssd1306_set_page_address(2);
        ssd1306_write_text("Function is active!");
        printf("1 ");
    }else {
        ssd1306_clear();
        ssd1306_set_column_address(40);
        ssd1306_set_page_address(2);
        ssd1306_write_text("Function is inactive!");
    }
    mdelay(500);
}

You might have noticed that printf("1 ");, and was wondering where you can find it’s output? Serial console can be opened using Data Visualizer which is in tools menu (if you have it installed), on the left side of it is configuration option, that will open panel, with several options to chose terminal can be opened selecting External Connection and Serial Port. Before connecting, remember to change baudrate to 115200. Now you are all set up, and ready to code.

Sources

SAMG55 Xplained Pro documentation

OLED1 Xplained Pro Documentation

Summary

img

As you can see, starting with Atmel SAMG55 Xplained Pro can be easy. I hope that provided information are easy to read, and useful. If they are not, please leave a comment. Thanks for reading.


Piotr Król
Founder of 3mdeb, a passionate advocate for open-source firmware solutions, driven by a belief in transparency, innovation, and trustworthiness. Every day is a new opportunity to embody the company's vision, emphasizing user liberty, simplicity, and privacy. Beyond business, a casual chess and bridge player, finding peace in nature and nourishment in theology, philosophy, and psychology. A person striving to foster a healthy community, grounded in collaboration and shared growth, while nurturing a lifelong curiosity and a desire to deeply understand the world.