A apresentação está carregando. Por favor, espere

A apresentação está carregando. Por favor, espere

Microprocessadores 8051 – Aula 3 Interrupção

Apresentações semelhantes


Apresentação em tema: "Microprocessadores 8051 – Aula 3 Interrupção"— Transcrição da apresentação:

1 Microprocessadores 8051 – Aula 3 Interrupção
Prof Afonso Ferreira Miguel

2 Interrupções Mecanismos de Interrupção Introdução
Durante a execução normal de um programa um dispositivo pode requisitar a atenção (IRQ); Para atender a IRQ do dispositivo, este suspende a execução do programa e desvia para uma rotina de tratamento de interrupção (RTI) criada pelo usuário; Ao término da RTI, o processador continua a execução do programa principal anteriormente suspenso.

3 Interrupções Mecanismos de Interrupção Introdução Main Program RTI IRQ
x

4 Interrupções Mecanismos de Interrupção RTI (recomendações) Rápida;
Pequena; Salvar contexto; Para algoritmos complexos, utilizar máquinas de estado (Finite State Machine).

5 Interrupções Estrutura de uma RTI
Salvar o contexto Código da RTI Restaurar o contexto RETI Estrutura de uma RTI Salvar o contexto: salvar variáveis comuns a RTI e programa principal ou outras RTIS (utiliza geralmente PUSHs); Código da RTI: atende as requisições do dispositivo que solicitou a RTI; Restaurar o contexto: recuperar o valor das variáveis salvas no item anterior; RETI: instrução que retorna da RTI.

6 Microcontrolador 8051 (MCS-51)
TCON (0x88) IE (0xA8) IP (0xB8) SCON (0x98)

7 Microcontrolador 8051 (MCS-51)
The 8051 provides 5 interrupt sources INT0 INT1 TF0 TF1 RI/TI External Interrupts and can be either level or transition activated Timer 0 and 1 overflow/rollover activated Serial Port both receive and transmit Since both TX and RX are the same interrupt, the service routine will have to determine which it was. All the bits that generate interrupts can be set or cleared by software, with the same results as if they had been set or cleared by hardware.

8 Microcontrolador 8051 (MCS-51)

9 Microcontrolador 8051 (MCS-51)

10 Microcontrolador 8051 (Interrupções)
Todas as fontes de interrupção podem ser individualmente habilitadas ou desabilitadas, ativando ou desativando bits em IE.

11 Microcontrolador 8051 (MCS-51)
Interrupts flags are sample at S5P2 of every machine cycle.

12 Microcontrolador 8051 (MCS-51)
O 8051 realiza um LCALL para a correspondente RTI, exceto nas seguintes condições: Uma interrupção de igual ou maior prioridade está em execução; Uma instrução ainda não está completa; A instrução em progresso é uma RETI ou está sendo realizada uma escrita em IE ou IP.

13 Microcontrolador 8051 (MCS-51)
Priority can be set by the software; All interrupts can either be set to a high or low priority.

14 Microcontrolador 8051 (MCS-51)
Priority works as follows High-priority interrupts can not be interrupted; Low-priority interrupts can be interrupted ONLY by high-priority interrupts; If two request of different priorities occur ‘simultaneously’, the request with the higher priority is serviced;

15 Microcontrolador 8051 (MCS-51)
Priority works as follows If request with the same priority occur ‘simultaneously’, then an internal polling sequence is used:

16 Microcontrolador 8051 (MCS-51)
If none of the previous conditions have violated, then the 8051 will generate a LCALL to the appropriate serving routine. In most cases it also clears the flag that generated the interrupt. Note: Serial Port flag is never cleared and as such must be handled by software

17 Microcontrolador 8051 (MCS-51)
LCALL pushes the current contents of the Program Counter onto the stack and reloads an address that depends on the source of the interrupt; Execution proceeds until RETI is encountered. The execution of this command allows the 8051 to know that the current interrupt routine is no longer in progress The 8051 then reloads the Program Counter from the stack and continues from where is left off.

18 Microcontrolador 8051 (MCS-51)
Interrupção: Estrutura em Assembly


Carregar ppt "Microprocessadores 8051 – Aula 3 Interrupção"

Apresentações semelhantes


Anúncios Google