Você está na página 1de 2

source_PIC039_WR.

c 09/02/2018 16:29:26

1: /*
2: Curso de Microcontroladores PIC WR Kits Channel
3:
4: Aula 39: Interrupção por mudança de estado no PORTB<7:4>
5:
6: MCU: PIC16F876A
7:
8: Clock: 16MHz
9:
10: Ciclo de Máquina: 250ns
11:
12:
13:
14:
15:
16:
17: */
18:
19: // --- Função de Interrupção ---
20: void interrupt()
21: {
22: if(RBIF_bit) //Houve a mudança de estado no PORTB<7:4> ?
23: { //Sim...
24:
25: RBIF_bit = 0x00; //Limpa a flag
26:
27: if(RB4_bit) RC4_bit = ~RC4_bit; //Inverte o estado da saída
28:
29: // delay_us(500);
30:
31:
32: } //end if
33:
34:
35: } //end interrupt
36:
37: // --- Função Principal ---
38: void main()
39: {
40: CMCON = 0x07; //Desabilita os comparadores
41: RBIE_bit = 0x01; //Habilita a interrupção por mudança do PORTB<
<7:4>
42: RBIF_bit = 0x00; //flag de indicaçao, Força a flag de sinalizaç
ção a zero
43: GIE_bit = 0x01; //Habilita a interrupção global
44:
45: TRISB = 0xFF; //Todo PORTB será entrada digital
46: TRISC = 0xEF; //Apenas o RC4 será saída digital
47:
48: RC4_bit = 0x00; //Inicia a saída em low
49:
50:
51: while(1)
52: {
53:
54:
55: } //end while

1/2 mikroC PRO for PIC by mikroElektronika


source_PIC039_WR.c 09/02/2018 16:29:26

56:
57:
58: } //end main

2/2 mikroC PRO for PIC by mikroElektronika

Você também pode gostar