2.11 I/O View and Other Bare-Metal Programming References (2024)

This section describes how you would typically write code in Microchip Studio, independentof a software configuration tool or framework, i.e., bare-metal. This description iscovered both as a video (linked below) and a hands-on document. The main focus is on therelevant programming references, how each is accessed, and their use. The projectcontext is to turn ON an LED, then blink with a delay. Although using the ATtiny817Xplained Pro, the principles are general enough to use with any kit inMicrochip Studio, though the principles apply to most devices supported inMicrochip Studio.

Getting Started Topics

2.11 I/O View and Other Bare-Metal Programming References (1)

Video: I/O View and Bare-metal programming references

The list below is an overview of the typically used programming references. Particular emphasisis placed on the I/O view, which provides a way to navigate the data sheet registerdescriptions when editing or debugging and understanding the current configuration whendebugging. This second use of the I/O view when using debugging to test new registerconfigurations.

This topic is closely related to both Debugging 3: I/O View Memory View and Watch as well as Editor: Writing and Re-Factoring Code (VisualAssist).

  • Device data sheet
  • Data sheet (from I/O view)
  • Kit user guide andschematics
  • I/O View (debugging)
  • Editor (Visual Assist)
  • Device header files
  • AVR Libc (AVR specific)
  • Atmel START: ATtiny817project

In the process, the following code is written. The decision process is describedusing the list of programming references above, even if the code is simple.

#include <avr/io.h>#define F_CPU 3333333#include <util/delay.h>int main(void){PORTB.DIR = PIN4_bm; while (1) {_delay_ms(500);PORTB.OUTTGL = PIN4_bm; }}

Warning: Be sure to keep the #include <avr/io.h> line at the top of main.c. This header file will include the correct register map for the selected device, and without this statement, the compiler will not recognize any of the macros referenced in the code above.

Device Data Sheet(PDF)

Although I/O View allows easy access to navigate the data sheet at aregister level, the PDF version still has a role. The device data sheet, in PDF format,tends to be used at least to get an understanding of the peripheral through the blockdiagram and functional description. For example, to understand the PORTperipheral of the ATtiny817, we consulted the PORT Block Diagram andFunctional Description > Principle of operation sections of the datasheet. These two sections (connecting the description to the diagram) give a basicunderstanding of the PORT peripheral.

2.11 I/O View and Other Bare-Metal Programming References (2)

2.11 I/O View and Other Bare-Metal Programming References (3)

Note: We used the device data sheet for theperipheral block diagram and a description of the PORT DIR and OUTregisters.

I/O View Data Sheet

Microchip Studio allows easy access to the data sheet register descriptions by clicking F1 onthe relevant register description. The HTML version of the data sheet opens online(by default). The data sheet will open in the context of the relevant registerdescription.

Note: In this way, we use the Data sheet fromI/O View to understand that:

  1. Writing a '1' toPORT.DIR[n] configures and enables pin n as an output pin.
  2. If OUT[n] is written to'0', pin n is driven low.

2.11 I/O View and Other Bare-Metal Programming References (4)

I/O View (Debugging)

Thisfunctionality can directly be tested by starting a debug session using StartDebugging and Break. So we are now able to begin testing functionality, as shownin the image below.

Debugging 3: I/O View Memory View and Watchdescribes I/O View in more detail.

Note: I/O View when debugging is usedto:

  1. Verify that writing a '1'to PORT.DIR4 sets the pin as OUTPUT, LOW by default to LED turnsON.
  2. Verify that writing a '1'to PORT.OUT4 turns OFF the LED.
Table 2-2. Microchip Studio ButtonFunctionality (Programming and Launching Debug Sessions)
ButtonFunctionalityKeyboard Shortcut

2.11 I/O View and Other Bare-Metal Programming References (5)

Start Debugging and BreakAlt + F5

2.11 I/O View and Other Bare-Metal Programming References (6)

Attach to Target

2.11 I/O View and Other Bare-Metal Programming References (7)

Start DebuggingF5

2.11 I/O View and Other Bare-Metal Programming References (8)

Break AllCtrl + Alt + Break

2.11 I/O View and Other Bare-Metal Programming References (9)

Start Without DebuggingCtrl + F5

2.11 I/O View and Other Bare-Metal Programming References (10)

Downloading Microchip StudioDocumentation

The data sheet can also be downloaded by using the MicrochipStudio help system. In this case, similar functionality will work offline. Downloading Offline Documentationdescribes this.

Microchip Studio Editor (Visual Assist)

The Microchip Studio Editor, powered byVisualAssist, has powerful features to help you write and refactor code and easilynavigate large projects. Suggestion functionality is shown in Figure 2-20, while Figure 2-21 shows an overview ofthe code navigation.. In the next section, Editor: Writing and Re-Factoring Code (VisualAssist), theeditor features are detailed.

2.11 I/O View and Other Bare-Metal Programming References (11)

2.11 I/O View and Other Bare-Metal Programming References (12)

Specifically, in the video related to this section, the editor is used for the following.

Device Header Files

Through the Goto Definition functionality of the editor, it is easy to access the MCUdevice header files, i.e., by clicking on any register and then clicking on the gotobutton or typing Alt+G. Writing PORTB gives a suggestion list of potential registersfrom the PORT structure, shown in figure Suggestion lists and the MCU device header files. For moreinformation about how the AVR header files are structured, see AVR1000.

2.11 I/O View and Other Bare-Metal Programming References (13)

Kit Schematics and UserGuide

The kit schematics and user guide help understand MCU pin connections onthe kit. Complete schematics and kit design files, such as Gerbers, are available onwww.microchip.com, on the kit's product page.

2.11 I/O View and Other Bare-Metal Programming References (14)

2.11 I/O View and Other Bare-Metal Programming References (15)

The LED and button connect to the pins from the ATtiny817 Xplained Pro User Guide, as shown in the tablebelow.
Table 2-3. ATtiny817 Xplained Pro GPIOConnections
Silkscreen TextATtiny817 GPIO Pin
LED0PB4
SW0PB5
The ATtiny817 Xplained Pro design documentation schematic shows the connectionsfor the LED and button, as in the figure below.

2.11 I/O View and Other Bare-Metal Programming References (16)

From the schematics, the conclusion is:
  • The LED can be turned ON bydriving PB4 low
  • SW0 is connected directly to GNDand PB5 through a current limiting resistor
  • SW0 does not have an externalpull-up resistor
  • SW0 will be read as'0' when pushed and as '1' when released,if the ATtiny817 internal pull-up is enabled

AVR® Libc

All the references covered to this point are just as relevant for SAM as for AVR. However, as thename suggests, this one is specific to AVR. AVRLibc is a Free Software project whose goal is to provide a high-quality Clibrary for use together with GCC on AVR microcontrollers. Together, avr-binutils,avr-gcc, and avr-libc form the heart of the Free Software toolchain for the AVRmicrocontrollers. Further, they are accompanied by projects for in-systemprogramming software (avrdude), simulation (simulavr), and debugging (avr-gdb, AVaRICE).

The library reference is usually a quick interface into AVRLibc, as shown in Figure 2-25. One can quicklysearch the page for a relevant library. The module name indicates the relevantheader files added to the project. For example searching for 'interrupts', therelevant include will be #include <avr/interrupt.h>. A list of availablefunctions and relevant interrupt callbacks shows when clicking into the module. Seealso Figure 2-26.

2.11 I/O View and Other Bare-Metal Programming References (17)

2.11 I/O View and Other Bare-Metal Programming References (18)

Atmel START

Atmel START is aweb-based software configuration tool for various software frameworks, which help youget started with MCU development. Starting from either a new project or an exampleproject, Atmel START allows you to select and configure software components (fromASF4 and AVR Code), such as drivers and middleware to tailor yourembedded application in a usable and optimized manner. Once doing an optimized softwareconfiguration, you can download the generated code project and open it in the IDE ofyour choice, including Microchip Studio, MPLAB X, IAR Embedded Workbench, Keil μVision,or set up a make-file.

Although Atmel START is a tool for MCU and software configuration, it can still be helpful evenin bare-metal development, i.e., writing code from scratch using the list of programmingreferences described in this section. Creating a new project for the kit you are usingcan be a helpful alternative to the board schematic, using the PINMUX view. In addition,the CLOCKS view can be of use to check the default clocks of a device. Furthermore,viewing the configuration code, pieces of use can be pasted back into your project. Forexample, the AVR Libc delay functions require that the clock frequency is defined, asshown in Figure 2-29. For the ATtiny817,this default value would be: #define F_CPU 3333333.

2.11 I/O View and Other Bare-Metal Programming References (19)

2.11 I/O View and Other Bare-Metal Programming References (20)

2.11 I/O View and Other Bare-Metal Programming References (21)

2.11 I/O View and Other Bare-Metal Programming References (2024)
Top Articles
Optix2Go
Paris | Definition, Map, Population, Facts, & History
Why Are Fuel Leaks A Problem Aceable
Public Opinion Obituaries Chambersburg Pa
Angela Babicz Leak
Jazmen Jafar Linkedin
Lamb Funeral Home Obituaries Columbus Ga
Jailbase Orlando
Women's Beauty Parlour Near Me
Tyrunt
Computer Repair Tryon North Carolina
30% OFF Jellycat Promo Code - September 2024 (*NEW*)
Athletic Squad With Poles Crossword
What is IXL and How Does it Work?
Culos Grandes Ricos
Busted Newspaper S Randolph County Dirt The Press As Pawns
“In my day, you were butch or you were femme”
Accuradio Unblocked
Belle Delphine Boobs
Nalley Tartar Sauce
2015 Honda Fit EX-L for sale - Seattle, WA - craigslist
Byte Delta Dental
Unlv Mid Semester Classes
Gem City Surgeons Miami Valley South
How Much Is Tay Ks Bail
Where to Find Scavs in Customs in Escape from Tarkov
China’s UberEats - Meituan Dianping, Abandons Bike Sharing And Ride Hailing - Digital Crew
Contracts for May 28, 2020
Reborn Rich Kissasian
Dragonvale Valor Dragon
Plost Dental
Meta Carevr
Best Town Hall 11
What is Software Defined Networking (SDN)? - GeeksforGeeks
Courtney Roberson Rob Dyrdek
Everything You Need to Know About Ñ in Spanish | FluentU Spanish Blog
Www.craigslist.com Syracuse Ny
2024 Coachella Predictions
Upstate Ny Craigslist Pets
The Boogeyman Showtimes Near Surf Cinemas
The TBM 930 Is Another Daher Masterpiece
Andrew Lee Torres
Simnet Jwu
2024-09-13 | Iveda Solutions, Inc. Announces Reverse Stock Split to be Effective September 17, 2024; Publicly Traded Warrant Adjustment | NDAQ:IVDA | Press Release
Anthem Bcbs Otc Catalog 2022
Craigslist Com St Cloud Mn
Atu Bookstore Ozark
60 Days From May 31
'The Nun II' Ending Explained: Does the Immortal Valak Die This Time?
Lux Funeral New Braunfels
Round Yellow Adderall
Where To Find Mega Ring In Pokemon Radical Red
Latest Posts
Article information

Author: Gregorio Kreiger

Last Updated:

Views: 5299

Rating: 4.7 / 5 (77 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Gregorio Kreiger

Birthday: 1994-12-18

Address: 89212 Tracey Ramp, Sunside, MT 08453-0951

Phone: +9014805370218

Job: Customer Designer

Hobby: Mountain biking, Orienteering, Hiking, Sewing, Backpacking, Mushroom hunting, Backpacking

Introduction: My name is Gregorio Kreiger, I am a tender, brainy, enthusiastic, combative, agreeable, gentle, gentle person who loves writing and wants to share my knowledge and understanding with you.