Improved Interrupt Handling in Microchip’s ATtiny817

Discover the new features of ATtiny 817, Microchip’s newest microcontroller, and find out how you can use this feature-rich solution for your applications.

Interrupt handling in the new ATtiny817

Written by: Arild Rodland, product marketing for MCU08 division of Microchip Technology Inc.

Interrupt handling got a whole lot smarter in the new AVR® microcontrollers (MCUs), and the ATtiny817 from Microchip is the first AVR device to take advantage of these changes.

Those familiar with the different AVR families should know that, traditionally, interrupt handling for tinyAVR® and megaAVR® devices has been very straight forward where all interrupts have a predefined priority, in which the lowest interrupt vector address will have highest priority. For the bigger XMEGA® MCU family, the interrupt system contains a programmable multilevel controller (PMIC), which allows the user to assign interrupts to three priority levels, making it possible to tailor the priority queue.

The new interrupt controller on the ATtiny817 is a cross between these two. So let’s look at it and find out what is new.

Interrupt Priority

Default settings on the ATtiny817 will be set up with an interrupt vector table with static priority where the lowest interrupt vector address has highest priority. See Figure 1. This is identical to other tinyAVRs.

FIGURE 1: INTERRUPT PRIORITY USING STATIC PRIORITY SCHEME

There are a couple of potential issues with static priority. First, if you have many interrupts with high priority, you may come into a situation where high-priority interrupt constantly blocks low-priority interrupts. The result is interrupt starvation. This means you do not have enough time to service all interrupts, and the lowest priority ones will never get any service. To fix this, ATtiny817 allows for a dynamic (round-robin) priority scheme. If you enable this round-robin scheme, the last serviced interrupt will get lowest priority next time an interrupt occurs. See Figure 2.

FIGURE 2: DYNAMIC ROUND-ROBIN PRIORITY SCHEME

Two Level Interrupt Controller

The round-robin priority scheme solves interrupt starvation, but what should be done if you want to give a peripheral higher priority than is defined in the interrupt vector table?

Even though the design team has made a very sensible, hardwired priority between the peripherals, we do understand that there is always the possibility that some people need to give an interrupt higher priority than what is defined by the default interrupt priority.

In the ATtiny817 we have the option to elevate a selectable interrupt vector to have priority over all others. To use this feature, simply write the desired vector address to the LVL1VEC register and this interrupt will have priority.

Compact Vector Table

There is a new feature on tinyAVR, called Compact Vector Table (CVT). Using this feature will truncate all interrupts into three vectors. One for non-maskable interrupts (for ATtiny817: CRC error interrupt) one for all Level0 interrupts (for ATiny817: All interrupts are default level0) and one for level1 interrupts (for ATtiny817: A single interrupt can be given higher priority by inputting its vector address into the LVL1VEG register).

This can be a useful feature when you only use a few interrupts. Reducing the vector table to only three vectors means that the interrupt table will occupy fewer Flash locations, essentially freeing this space to be used for user code. Be aware however, if you use this approach, you will need to add additional code in the interrupt handler to find out which interrupt is actually requesting service. This will add time, for both code writing and verification testing, to the completion of your design. For this reason, the compact vector table is most useful if only a few interrupts are used.

Advanced Feature: If round-robin is not enabled, the LVL0PRI register is still active, and will still define the starting point for the lowest priority interrupt, so if you want, you can statically shift the priority in the vector table. As an example, you could shift it to give USART the highest priority. Default value of this register is 0x00, so after reset, the lowest interrupt vector will have highest priority as expected.

Shifting the Vector Table Priority

I will round out this article with a trick/feature not explicitly mentioned in the datasheet. When using round-robin priority, there is a register called LVL0PRI which will contain the address of the last executed interrupt. This will be the interrupt with the lowest priority when selecting which interrupt to execute next. If we change this value, we directly affect which interrupts have lowest and highest priority.

As shown here, the new ATtiny187 MCU offers powerful interrupt management features that allow designers to control interrupt priority and response time to fit their design requirements. Now the only question is, what will you create to leverage these capabilities?

관련 상품 참조

ATTINY817-XPRO

Microchip Technology Sistema integrato, schede e kit di sviluppo 보기

microchip technology logo

최신 뉴스

Sorry, your filter selection returned no results.

개인정보 보호정책이 업데이트되었습니다. 잠시 시간을 내어 변경사항을 검토하시기 바랍니다. 동의를 클릭하면 Arrow Electronics 개인정보 보호정책 및 이용 조건에 동의하는 것입니다.

당사의 웹사이트에서는 사용자의 경험 향상과 사이트 개선을 위해 사용자의 기기에 쿠키를 저장합니다. 당사에서 사용하는 쿠키 및 쿠키 비활성화 방법에 대해 자세히 알아보십시오. 쿠키와 추적 기술은 마케팅 목적으로 사용될 수 있습니다. '동의'를 클릭하면 기기에 쿠키를 배치하고 추적 기술을 사용하는 데 동의하는 것입니다. 쿠키 및 추적 기술을 해제하는 방법에 대한 자세한 내용과 지침을 알아보려면 아래의 '자세히 알아보기'를 클릭하십시오. 쿠키 및 추적 기술 수락은 사용자의 자발적 선택이지만, 웹사이트가 제대로 작동하지 않을 수 있으며 사용자와 관련이 적은 광고가 표시될 수 있습니다. Arrow는 사용자의 개인정보를 존중합니다. 여기에서 당사의 개인정보 보호정책을 읽을 수 있습니다.