Prova aplicada em 25/06/2020 
1) Pisca LEDs  
matrícula = 4230948754   LED1 --> Ex: 7 + 5 + 4 + 50 = 66 Hz
LED1 --> piscar com frequência U + P + A + 50   Hz
LED2 --> piscar com frequência U + P + 50 Hz
LED3 --> piscar com frequência U + 50 Hz
U - Último número da matricula
P - Penúltimo número da matrícula
A - Antepenúltimo número da matrícula
Resolução:
Código feito em CCS C Compiler
#include <main1.h>
#use delay(clock = 20MHz)
//Matricula = 2013178440488
int U = 4 + 8 + 8 + 50;
int P = 8 + 8 + 50;
int A = 8 + 50;
void main(){
   while(TRUE){
         output_high(pin_b0);
         delay_ms(1000/U);
         output_low(pin_b0);
         delay_ms(1000/U);
         output_high(pin_b1);
         delay_ms(1000/P);
         output_low(pin_b1);
         delay_ms(1000/P);
         output_high(pin_b2);
         delay_ms(1000/A);
         output_low(pin_b2);
         delay_ms(1000/A);
   }
}
2) Fazer um programa para bord3 que quando o botão S3 conectado a B1 o PIC grava em sua memória interna seu (aluno) primeiro nome e ao precionar o botão S3 conectado ao B2 O PIC lê o que foi escrito na memória e escreve no LCD com a sequência invertida das letras.
Ex:   
HENRIQUE
EUQIRNEH
Resolução:
Código feito em CCS C Compiler
#include <main.h>
#include <LCD.C>
#include <lcd.c>
#use delay(clock=20MHz)
const char vetor[]= "HENRIQUE";
int i, cont = 0;
void crescente(){
   printf(lcd_putc,"\f");//Limpa tela
   for(i = 0; i < sizeof(vetor)/sizeof(int); i++){
      lcd_gotoxy(i+1, 1);
      lcd_putc(vetor[i]);
      delay_ms(200);
   }
}
void decrescente(){
   printf(lcd_putc,"\f");
   for(i = sizeof(vetor)/sizeof(int) -2; i >= 0; i--){
      //lcd_gotoxy(i+1, 2);
      lcd_putc(vetor[i]);
      delay_ms(200);
   }
}
void main(){
   lcd_init();
   lcd_init();
   while(TRUE){
      if(input(PIN_B0) == true){
         if(cont %2 == 0){//em par, crescente
            crescente();
            cont++;
         }else{//em ímpar, decrescente
            decrescente();
            cont++;
         }
      }
      //TODO: User Code
   }
}
3) Fazer um programa para board3 que lê os valores (inteiro de oito bits) de tensão do potenciômetro, numa frequência de 10 Hz durante 5 segundos. Guarda esses valores na memória 24C04 que esta nessa placa. Quando o botão S3 é pressionado, o PIC envia esses valores via serial. A sequência de valores deve ser precedida pelo seu primeiro nome.
Ex:  ......., 28, 50, 58, 55, 'N', 'A', 'I, 'R', 'I', 'M'    --> PORTA SERIAL
Resolução:
Código feito em CCS C Compiler
#include <main.h>
#include <LCD.C>
#include <lcd.c>
#FUSES HS                   //High speed Osc  (> 4mhz for PCM/PCH) (>1 )
#FUSES NOPUT               //No Power Up Timer
#FUSES NOPROTECT           //Code not protected from readin
#FUSES NODEBUG             //No Debug mode for LCD
#FUSES NOBROWNOUT          //No brownout reset
#FUSES NOLVP               //No low voltage prging, B3(PIC16) or B5
#FUSES NOCPD               //No EE protection
#FUSES NOWRT               //Program memory not write protected
#define lcd_d/ pin_d/d
#use delay(clock = 20MHz)
#use rs232(baud=9600, xmit = PIN_C6, rcv = PIN_C7, parity = N, bits = 8, errors)
#include "2404.C"
void main(){
   unsigned int i, j, aux = 0;
   setup_adc_ports(AN0_AN1_AN3), (ADC_CLOCK_DIV_16);
   setup_psp(PSP_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED, 0, 1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   lcd_init();
   delay_ms(10);
   init_ext_eeprom();
   delay_ms(10);
   printf(lcd_putc,"\f iniciando...");
   delay_ms(2000);
   set_adc_channel(1);
   delay_us(50);
   while(TRUE){
      if(!input(PIN_B0)){
         printf(lcd_putc,"\fLeitura do Potenciometro\n\rEscrevendo em Menor");
         write_ext_eeprom(1, 'H');
         write_ext_eeprom(2, 'E');
         write_ext_eeprom(3, 'N');
         write_ext_eeprom(4, 'R');
         write_ext_eeprom(5, 'I');
         write_ext_eeprom(6, 'Q');
         write_ext_eeprom(7, 'U');
         write_ext_eeprom(8, 'E');
         for(j = 0; j <= 58; j++){
            aux = read_adc();
            write_ext_eeprom(j, aux);
            delay_ms(100);
         }
         delay_ms(3000);
         printf(lcd_putc,"\f");//limpa tela
      }
      if(!input(PIN_B2)){
         printf(lcd_putc,"\fExpedindo informação...");
         for(i = 1; i <= 8; i++){
            printf(lcd_putc, "%c, ", read_ext_eeprom(i));
            delay_ms(100);
         }
         for(i = 9; i <= 58; i++){
            printf(lcd_putc, "%u, ", read_ext_eeprom(i));
            delay_ms(100);
         }
      }
      printf(lcd_putc, "\f");
      //TODO: User Code
   }
}


 
Nenhum comentário:
Postar um comentário