PIC 16F84A y LED intermitente

hola le queria decir que muchas gracias para la gente que demostro interes en ayudarme a soluciona mi problema!!! les paso a contar que ya lo he solucionado era una bobada el problema que tenia, despues de divagar un rato en internet me di cuenta que me faltaban unas resistencias pull-up nada mas y el programa es para el pic 16f628a
 
Hola, tengo un problema me parece raro e ilogico. Hice un programa de prueba para encender y apagar un led (algo que hasta me da verguenza decirlo) pero en fin. El punto es que todos los voltajes y tierras estan en los pines correctos. El pin MCLR tiene una resistencia pull up de 10k (antes estaba con una de 4.7k), he estado usando un oscilador de 10 y 20 MHz (con condensadores de 22pf y tambien los probe sin ellos), para probar un led en serie con una resistencia de 330ohm. En la simulacion funciona perfectamente pero en el maldito protoboard se queda prendido el led y no oscila, solo una vez oscilo movi el cristal, pero luego lo apague y prendi y no de nuevo lo mismo...No se que puede ser no hay muchas conexiones las he revisado y ya no vuelve a oscilar......

PD. Estoy usando un pic16f877a con un JDM programmer. He seleccionado la opcion HS (High speed) de la misma manera esta configurado en los FUSES del programa.

#fuses HS,NOWDT,NOPROTECT,NOLVP

El programa que voy a hacer maneja otro perifericos y entradas analogas, pero si en el circuito real no funciona eso de hacer oscilar un led. Mucho menos voy a poder manejar señales analogicas y comunicacion serial.

Gracias
 
Última edición:
PHP:
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#device adc=10
#use delay (clock=20000000)
#use rs232 (BAUD = 9600 , XMIT = PIN_C6 , RCV = PIN_C7 , BITS = 8)
#include "LCD.c"
#include "KBD.c"
//declaracion de puertos
#byte PORTA=0x05
#byte TRISA=0x85
#byte PORTC=0x07
#byte TRISC=0x87
#byte PORTD=0x08
#byte TRISD=0x88
#byte PORTB=0x06
#byte TRISB=0x86

#define R_SHUNT   0.01

char valor;
//unsigned long  AD_read=0;

#int_rda
void serial_isr()
{
   valor = getc();
}

void PORT_init(void)
{
   TRISA=0xFF;
   TRISD=0x00;
   TRISC=0x00; 
   TRISB=0x00;
   PORTC=0x00;
   PORTD=0x00;
}

void MCU_Init(void)
{  
   Port_init();
   setup_adc(ADC_CLOCK_DIV_32);
   setup_adc_ports(ALL_ANALOG);
   lcd_init();
   kbd_init();
   port_b_pullups(true);
 }



void main()
{
  int16 q;
  float v1,v2,ISH;
  char k;
  int opt;
  
  MCU_Init();
  enable_interrupts(global);
  enable_interrupts(int_rda);

  printf(lcd_putc,"SENSOR CORRIENTE");
  delay_ms(1000);
  lcd_gotoxy(1,1);
  printf(lcd_putc,"\fElija una opcion");
  lcd_gotoxy(1,2);
  printf(lcd_putc,"Voltajes(1,2)");
   delay_ms(1000);

 
  while(TRUE)
   {
   delay_ms(500);
   output_high(pin_b0);
   delay_ms(500);
   output_low(pin_b0);
    /*k = kbd_getc();
    opt=k-48;
    
    set_adc_channel(0);
    delay_us(20);
    q = read_adc();
    v1 = 5.0*q/1024.0;
    
    set_adc_channel(1);
    delay_us(20);
    q = read_adc();
    v2 = 5.0*q/1024.0;
    
    //calculo de la corriente que pasa por la resistencia Shunt
    ISH = (v1 - v2)/R_SHUNT;
    switch(opt)
    {
      case 1:
      printf(lcd_putc,"\fVoltaje1: %01.2fV",v1);
      delay_ms(50);
      break;
      
      case 2:
      printf(lcd_putc,"\fVoltaje2: %01.2fV",v2);
      delay_ms(50);
      break;
      
      default:
      break;
    }
    printf(lcd_putc,"\fVoltaje1: %01.2fV",v1);
    printf(lcd_putc,"\nVoltaje2: %01.2fV",v2);
    printf("\fCorriente: %01.2fA",ISH);
    delay_ms(100);*/
   }
}
Comente lo que estaba probando con el simulador y descomente la parte que hace oscilar un led en el pin_b0
 
Última edición por un moderador:
Vamonos por partes... si tu programa ya esta simulado y funciona entonces por alli no va la cosa... asi que debe ser por otro lado ... mas probablemente el programador o el PIC

Primero intenta grabando el mismo programa en un PIC nuevo recien comprado... si funciona entonces el problema estaba en el PIC

Despues consige otro programador y graba el mismo programa, asi funciona el problema esta en el programador...
 
yo te diria que primero compares las conexiones con las del simulador luego los voltajes si te programo bien el hex en el micro y no te dio error comproba cargando uno distinto y pone para leerlo a ver si te lo lee despues de eso si graba y lee bien los programas no es el pic son las conexiones fijate que no haya hecho un cortocircuito sin querer entre patas luego cambia en la programacion el port y proba pin 1 de cada uno de los port si te va mal cambia a otro nuevo pic. No se si te sirve la respuesta fijate que tu clock funcione tb sino, podes para prueba usar el clock interno pero tenes que configurar los fuses
 
Gracias por tu aporte, creo que el grabador JDM que estaba usando no hacia bien su trabajo. Finalmente lo probé con un pickit 2 y funciono, ahora ya estoy agregando más cosas a mi programa.
 
Hola buenas noches!!


Un amigo me pidio que le ayudara con un programa:

tiene cuatro leds, estan en el puerto B del pic16f819, cuando inicia el programa se prende el primer led, se espera 20 segundos, se prende el segundo led, se espera 20 segundos, se prende el tercer led, se espera 20 segundos, se prende el cuarto led y ahi se tiene que esperar 3 horas.
Despues de ese tiempo se apaga el primer led, se espera 20 segundos, se apaga el segundo led, se espera 20 segundos, se apaga el tercer led, se espera 20 segundos, se apaga el cuarto led y ahi se tiene que esperar 12 horas y cuando pasa ese tiempo vuele a empezar.


A qui le dejo el codigo de mi programa (el programa en mplab y la simulacion para que vean), algo tiene mal porque en la simulacion en proteus prende bien los 4 leds pero cuando termina el tiempo de las 3 horas (es decir la rutina tiempo) no apaga los leds, los apaga todos y los vuelve a prender.

Ojala puedan decirme que tiene mal y ayudarme para corregirlo, por favor!!!!!

si alguien tiene una mejor opcion y asi evitarme tantos retardos seria muy chido
Código:
list               p=16f819
include        "p16F819.inc"

            
         CBLOCK    0X20

        ENDC

        ORG        0X00
        goto     INICIO
        ORG        0X04

INICIO    
                      ;MOVLW                0x07
        ;MOVWF    CMCON
        BCF        STATUS,6
        BSF        STATUS,5
        MOVLW    B'1111'
        MOVWF    TRISA
        CLRF    TRISB
        BCF        STATUS,5
        BCF        STATUS,6
        CLRF    PORTB



PRENDE
                MOVLW    B'00010000'
                MOVWF    PORTB
                CALL    Retardo_20s
                MOVLW    B'00110000'
                MOVWF    PORTB
                CALL    Retardo_20s
                MOVLW    B'01110000'
                MOVWF    PORTB
                CALL    Retardo_20s
                MOVLW    B'11110000'
                MOVWF    PORTB
                CALL    tiempo  ; se espera 3 horas
                MOVLW    B'11100000'
                MOVWF    PORTB
                CALL    Retardo_20s
                MOVLW    B'11000000'
                MOVWF    PORTB
                CALL    Retardo_20s
                MOVLW    B'10000000'
                MOVWF    PORTB
                CALL    Retardo_20s
                CLRF    PORTB
                CALL    tiempo2 ; se esper 12 horas
                GOTO    PRENDE
                
tiempo2  ;12 horas
                call tiempo
                call tiempo
                call tiempo
                call tiempo
                return

tiempo   ; 3 horas
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s
               call Retardo_20s

return


                    INCLUDE <RETARDOS.INC>
                
                    end
 

Adjuntos

  • prueba1.rar
    53.3 KB · Visitas: 25
Última edición por un moderador:
Hola a todos,

Tengo una pequeña pregunta que quisiera por favor me la puedan responder, realmente se lo agradecería. Si yo aprendo a programa un microncontrolador PIC16F84A en assembler, ¿puedo programar, con el mismo lenguaje que programé el 16F84A, un PIC16F877 por ejemplo o es un lenguaje completamente diferente? Gracias anticipadas por la respuesta.
 
Hola a todos,

Tengo una pequeña pregunta que quisiera por favor me la puedan responder, realmente se lo agradecería. Si yo aprendo a programa un microncontrolador PIC16F84A en assembler, ¿puedo programar, con el mismo lenguaje que programé el 16F84A, un PIC16F877 por ejemplo o es un lenguaje completamente diferente? Gracias anticipadas por la respuesta.

Hola...el lenguaje y el juego de instrucciones es el mismo pero cada PIC tiene distintas particularidades como módulo ADC el 16F877 que el 84 no tiene, etc por lo tanto un programa echo en asembler para el 84 correría perfecto en el 877 contemplando las particularidades de cada uno(registros, puertos, etc).

Saludos.

Ric.
 
Atrás
Arriba