This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
pt:examples:timer:periodic_interrupt [2015/12/14 22:59] – Criação deste novo documento. artica | pt:examples:timer:periodic_interrupt [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 9: | Line 9: | ||
===== Teoria ===== | ===== Teoria ===== | ||
- | The goal of this chapter is to demonstrate the usage of the interrupts on the example of the counters. The interrupts are program parts which are reacting to the events taking place in the microcontrollers. They are usually used for quick response to an event, but they can also be used for completing several parallel processes, precisely timed action and saving power. For example, it is possible to make a LED blinking using interruptions, so that blinking frequency does not depend on what is happening in the program at the moment. When the interrupt occur then main program execution stopped and the interrupt priority check of the interrupt vector table happen, after that the program of the interrupt function has been executed. While the interrupt program will be executed then the main program execution continues on the state where it left off. | + | O objetivo deste capítulo é demonstrar o uso das interrupções no exemplo dos contadores. As interrupções são partes do programa que reagem aos eventos que têm lugar nos microcontroladores. São usadas normalmente para uma resposta rápida a um evento, mas podem também ser usadas para completar vários processos paralelos, acções precisas no tempo e de poupança energética. Por exemplo, é possível fazer um LED piscar com interrupções, de modo a que a freqüência do piscar não dependa do que acontece no programa em execução. Quando a interrupção ocorre a execução do programa principal pára e acontece a verificação da prioridade de interrupção na tabela de vectores de interrupção. Depois disso, dá-se então por concluída a função de interrupção. Depois da interrupção, |
- | ===== Practice | + | ===== Prática |
- | The following program shows how the counter is set up to make an interrupt. There are 2 LEDs of the Digital i/o module in the program, the state of the red LED is changed periodically with software | + | O programa seguinte mostra como o contador é configurado para fazer uma interrupção. Existem |
- | The following shows the use of interrupts of the xmega controller. In the beginning of the program, the 16-bit counter/timer E1 has been set up. First, the timer period will be set, so the maximum value of the count function | + | O que se segue mostra o uso de interrupções do controlador |
period = (32000000 Hz / 1024 / 1) - 1 = 31249 | period = (32000000 Hz / 1024 / 1) - 1 = 31249 | ||
- | After allowing the interrupt to achieve the maximum value of the counter | + | Depois de permitir que a interrupção atinja o valor máximo do contador |
<code c> | <code c> | ||
Line 64: | Line 64: | ||
</ | </ | ||
+ | Os exemplos de interrupção são bastante diferentes entre as séries de controladores ATmega (neste exemplo usamos o ATmega2561), | ||
- | Example of interrupt is quite different between ATmega series (in this example ATmega2561) controllers, because the timers, compared to the xmega series controllers, | + | No início do programa, o contador/ |
- | + | ||
- | In the beginning of the program, the 16-bit counter/ | + | |
f = 14745600 Hz / 1024 / 14400 = 1 | f = 14745600 Hz / 1024 / 14400 = 1 | ||
Line 112: | Line 111: | ||
</ | </ | ||
- | At the start of the program it is seen that regardless of what the microcontroller is doing in the main program, the interrupts are taking place and the green LED is blinking. | + | No início do programa confirma-se que, independentemente do que o microcontrolador está a executar no programa principal, as interrupções ocorrem e o LED verde pisca. |