1 / 12

AULA – RTC – Real Time Counter

AULA – RTC – Real Time Counter. Disciplina: Aplicações Avançadas de Microprocessadores (AAM) Profa. Ana T. Y. Watanabe atywata@gmail.com.br.

lali
Télécharger la présentation

AULA – RTC – Real Time Counter

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AULA – RTC – Real Time Counter Disciplina: Aplicações Avançadas de Microprocessadores (AAM) Profa. Ana T. Y. Watanabe atywata@gmail.com.br

  2. “Bem-aventurado aquele que lê e bem-aventurados os que ouvem as palavras desta profecia e guardam as coisas que nela estão escritas; porque o tempo está próximo.” Apocalipse 1:3

  3. RTC – Real Time Counter

  4. RTC – Real Time Counter • O RTC consiste em: • Um contador de 8-bit (RTCCNT); • Um módulo de 8-bit (RTCMOD); • Um comparador 8-bit; • Divisor de prescaler; • Três fontes de clocks: • 1) 1 kHz internal low-power oscillator (LPO) • 2) External clock (ERCLK) • 3) 32 kHz internal clock (IRCLK); • Período de Interrupção programável. • Aplicação: • Relógio, calendário, ou função de scheduling de tarefas, acordar (wake up) de um modo de baixo consumo sem necessidade de componentes externos).

  5. RTC – Real Time Counter - RTCSC RTCPS: Real-Time Clock Prescaler Select. Estes 4 bits selecionam o fator de divisão do clock da fonte; Um Reset limpa RTCPS. RTIE: Real-Time Interrupt Enable. Habilita interrupção de RTC. Se RTIE está setado, então uma interrupção é gerado quando RTIF é setado. Um Reset limpa RTIE. 0 – Solicitação de interrupção por RTC desabilitado; 1 – Solicitação de interrupção por RTC habilitado;

  6. RTC – Real Time Counter - RTCSC RTCLKS: Real-Time Clock Source Select. Estes 2 bits seleciona a fonte do clock; Ao trocar a fonte reseta o contador RTCCNT; Um Reset limpa RTCLKS. 00 - Real-time clock source is the 1-kHz low power oscillator (LPO) 01 - Real-time clock source is the external clock (ERCLK) 1x - Real-time clock source is the internal clock (IRCLK) RTIF:Real-Time Interrupt Flag Este bit indica que o contador RTCCNT atingiu o valor do módulo RTCMOD. Escrever 0 neste bit não tem efeito, mas ao escrever 1 limpa o bit e a solicitação de interrupção; Um Reset limpa RTIF. 0 – O Contador RTCCNT não atingiu o RTCMOD; 1 – O Contador RTCCNT atingiu o RTCMOD;

  7. RTC – Real Time Counter Período do prescaler:

  8. ADC – Conversor Analógico Digital Exemplo de Aplicação:

  9. RTC – Real Time Counter • REGISTRADORES PARA SEREM CONFIGURADOS: • RTCSC • RTCMOD

  10. RTC – Real Time Counter #include <hidef.h> /* for EnableInterrupts macro */ #include "derivative.h" /* include peripheral declarations */ // macros e definições #define Desabilita_COP() SOPT1 &= 0x3F // desabilita COP void main(void) { Desabilita_COP(); PTED = 0xFF; // desligaleds PTEDD = 0xFF; // configuraparasaidas // configura a Interruçãode timer RTC RTCSC = 0x1F; // 1 segInterrupçãohabilitada EnableInterrupts; /* enable interrupts */ for(;;) { } /* loop forever */ /* please make sure that you never leave main */ }

  11. RTC – Real Time Counter interrupt VectorNumber_Vrtc void ISR_RTC(void) { RTCSC_RTIF = 1; // reseta flag do RTC PTED = ~PTED; }

  12. RTC – Real Time Counter Exercício: Utilizar RTC para obter timer nos projetos.

More Related