PRÁTICA 2 – PIC ASSEMBLY SEMÁFORO
Objetivos:
- Montar um circuito com 3 leds simulando um semáforo de trânsito:
Tarefa:
- Compilar o programa 1 (abaixo) em ASSEMBLY usando o MPLAB.
- Gravar o PIC usando o gravador
- Montar o circuito e verificar o funcionamento.
Programa 1 – Semáforo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
list P = 16F628A include P16F628A.inc ; CONFIG __CONFIG _INTOSC_OSC_NOCLKOUT &_WDT_OFF & _PWRTE_ON & _BOREN_OFF & _MCLRE_OFF & _LVP_OFF & _CP_OFF org 0x0000 START MOVLW 0x07 MOVWF CMCON BSF STATUS,RP0 MOVLW 0x00 MOVWF TRISA MOVLW 0x00 MOVWF TRISB BCF STATUS,RP0 INICIO ;VERDE BSF PORTA,0 CALL DELAY ;5s CALL DELAY ;5s BCF PORTA,0 ;AMARELO BSF PORTA,1 CALL DELAY ;5s BCF PORTA,1 ;VERMELHO BSF PORTA,2 CALL DELAY ;5s CALL DELAY ;5s BCF PORTA,2 GOTO INICIO DELAY MOVLW 0X19 MOVWF 0X20 VSET1 MOVLW 0XFF MOVWF 0X21 VSET2 MOVLW 0XFF MOVWF 0X22 LOOP DECFSZ 0X22 GOTO LOOP DECFSZ 0X21 GOTO VSET2 DECFSZ 0X20 GOTO VSET1 RETURN END |
Circuito 1 – Semáforo:
Desafio: Modifique o programa para que o led verde fique aceso durante o acendimento do led amarelo.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
list P = 16F628A include P16F628A.inc ; CONFIG __CONFIG _INTOSC_OSC_NOCLKOUT &_WDT_OFF & _PWRTE_ON & _BOREN_OFF & _MCLRE_OFF & _LVP_OFF & _CP_OFF org 0x0000 START MOVLW 0x07 MOVWF CMCON BSF STATUS,RP0 MOVLW 0x00 MOVWF TRISA MOVLW 0x00 MOVWF TRISB BCF STATUS,RP0 INICIO BSF PORTA, 2 CALL DELAY ;5s CALL DELAY ;5s BSF PORTA, 1 CALL DELAY ;5s BCF PORTA, 1 BCF PORTA, 2 BSF PORTA, 0 CALL DELAY ;5s CALL DELAY ;5s BCF PORTA,0 GOTO INICIO DELAY MOVLW 0X19 MOVWF 0X20 VSET1 MOVLW 0XFF MOVWF 0X21 VSET2 MOVLW 0XFF MOVWF 0X22 LOOP DECFSZ 0X22 GOTO LOOP DECFSZ 0X21 GOTO VSET2 DECFSZ 0X20 GOTO VSET1 RETURN END |