Microcontroladores PIC => Lenguaje C para microcontroladores PIC => Mensaje iniciado por: gaitan en 14 de Noviembre de 2018, 03:42:28
Título: pic16f877a
Publicado por: gaitan en 14 de Noviembre de 2018, 03:42:28
Buenas amigos de foro: bueno programe un reloj con ds1307 y pic 16f877a y muestra en la lcd normalmente pero necesito encender un led cuando llegue a los 11 minutos adjunto el codigo y como lo intente hacer resaltado para que me puedan ayudar, gracias de antemano cualquier colaboracion.
sbit LCD_RS at RB2_bit; sbit LCD_EN at RB3_bit; sbit LCD_D7 at RB7_bit; sbit LCD_D6 at RB6_bit; sbit LCD_D5 at RB5_bit; sbit LCD_D4 at RB4_bit;
// Pin direction sbit LCD_RS_Direction at TRISB2_bit; sbit LCD_EN_Direction at TRISB3_bit; sbit LCD_D7_Direction at TRISB7_bit; sbit LCD_D6_Direction at TRISB6_bit; sbit LCD_D5_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB4_bit;
sbit Soft_I2C_Scl at RC3_bit; sbit Soft_I2C_Sda at RC4_bit;
sbit Soft_I2C_Scl_Direction at TRISC3_bit; sbit Soft_I2C_Sda_Direction at TRISC4_bit;
Write_value(0,0X00);//segundos Write_value(1,0X00);//minutos Write_value(2,0X00);//horas Write_value(3,0X00);//day Write_value(4,0X00);//date Write_value(5,0X00);//mes Write_value(6,0X18);//year Write_value(7,0X00);//control de 1 Hz para config 32678 Hz Lcd_Out(1,6,": :"); //hora Lcd_Out(2,3,"Dia:"); //fecha
ADCON1=0b11000001; ADC_Init(); UART1_Init(57600); Lcd_Init(); Lcd_Cmd(_LCD_CURSOR_OFF); TRISB.F1=0; PORTB.F1=0; while(1){ Delay_us(1000); PORTC.F0=0; Delay_us(19000); Soft_I2C_Start(); Soft_I2C_Write(0xD0); //id Soft_I2C_Write(0);//posicion 0 Soft_I2C_Start(); Soft_I2C_Write(0xD1); segundos=Soft_I2C_Read(1);//leer segundos minutos=Soft_I2C_Read(1);//leer minutos horas=Soft_I2C_Read(1);//leer horas day=Soft_I2C_Read(1);//leer dias date=Soft_I2C_Read(1);//leer date mes=Soft_I2C_Read(1);//leer meses year=Soft_I2C_Read(0);//leer año Soft_I2C_Stop(); display(); conversor(); transmisor(); intToStr(Temp,txt); Lcd_Out(2,11,txt); Lcd_Out(2,10,"T"); delay_mS(500);
}
}
Título: Re:pic16f877a
Publicado por: KILLERJC en 14 de Noviembre de 2018, 08:06:37
Mi pregunta antes de leer todo el codigo...
Sobre el LCD te dice bien la hora ? Si es asi entonces lo tenes ya realizado. Porque le haces esperar 1 segundo cuando es mayor a 18segundos ?... Peor aun, cuando es mayor a 29, esperas 2 segundos, ya que entra a los 2 if, me refiero a la funcion "display"
De la misma forma que hiciste con esos segundos, pero sin delays :
Código: C
if(minutos10>=0x01&& minutos>=0x01){
PORTB.F2=1;
}else{
PORTB.F2=0;
}
Para este caso, cuando minutos sean igual a 11, la salida va a estar en 1, en cualquier otro minuto va a estar en 0.
Título: Re:pic16f877a
Publicado por: gaitan en 14 de Noviembre de 2018, 15:56:47
muchas gracias por el aporte amigo ya esta funcional.