jueves, 25 de octubre de 2012

sdcc easypic2 main n_n

JMQ01.c
#include <pic16f877a.h>
#include "timer.h"
#include "lcd.h"
#include "jmq.h"
#include "adc.h"
#include "i2c.h"
#include "pcf8583.h"

volatile unsigned int band_a=0, B_LED=0,LED=0,opcion=1;
volatile unsigned int TdC=0;

#define DIR_I2C   0x8


void isr() interrupt 0 
{                                                                                                   /* rutina de servicio de interrupciones */
  if (RBIF==1){
   if (RB7==0){
    delay(5);
    if (RB7==0){
     if (B_LED==0){
      LED=1;
      B_LED=1;
     }else{
      LED=0;
      B_LED=0;
     }
    }
   }

   if (RB6==0){
    delay(5);
    if (RB6==0){
     opcion++;
     if (opcion>8)opcion=8;     
    } 
   }

   if (RB5==0){
    delay(5);
    if(RB5==0){ 
     opcion--;
     if (opcion<1)opcion=1;
    }
   } 
   
   if (RB4==0){
    delay(5);
    if(RB4==0){ 
      band_a=1;
      i2c_write_byte(DIR_I2C, 0x0,opcion);
    }
  
   }
  } 
  RBIF=0;
}

/*--------------------------------*/

void main(void)
{
  
  unsigned int a,b,c,d,CONTROL=0b10101100;  
  unsigned int direccion=0,temp;
  unsigned char datol,datoh;
 
  
  RBIE=1;
  GIE=1;
  TRISD=0b00000000;
  TRISB=0b11111111;
  
  TRISA=0b00000000;
  ADCON1 = 0b00000110;
  
  PORTA=0;PORTD=0;
  band_a=0;

  config_timer();
  delay(1000);
  i2c_configure();  
  delay(100);
  
  lcd_cmd(SET,LED);
  lcd_cmd(MODO,LED);
  lcd_cmd(CLS,LED);
  lcd_cmd(CurOFF,LED);


  print_xy(0,LED);
  print_lcd("easypic 2",1);
  print_xy(40,LED);
  print_lcd("   V1.0 JMQ   ",1);
  delay(2000);
  lcd_cmd(CLS,LED);
  

  LED=0;
  

  
  while(1){
   print_xy(0,LED);print_lcd("Rele Nro:",LED); 
   temp=opcion;   
   INT_BCD(temp,&a,&b,&c,&d);
   print_xy(11,LED);lcd_write(BCD_ASCII(d),LED); 
   
   i2c_read_byte(DIR_I2C, 0x02, &datol);
   INT_BCD(datol,&a,&b,&c,&d);
   print_xy(40,LED);lcd_write(BCD_ASCII(b),LED);    
   print_xy(41,LED);lcd_write(BCD_ASCII(c),LED);
   print_xy(42,LED);lcd_write(BCD_ASCII(d),LED);
   
   LeerLM75(0b10010111, &datoh, &datol);
   INT_BCD(datoh,&a,&b,&c,&d);
   print_xy(44,LED);lcd_write(BCD_ASCII(c),LED);
   print_xy(45,LED);lcd_write(BCD_ASCII(d),LED);
   
   
   /*direccion++;      
   if(direccion>256){
     CONTROL=0b10101110;
     if(direccion==512)direccion=0;
     datoh=0;
   }else{
     CONTROL=0b10101100;
     if(direccion==512)direccion=0;
     
   }  
   
   i2c_write_byte(CONTROL,direccion,datoh);
   INT_BCD(direccion,&a,&b,&c,&d);
   print_xy(49,LED);lcd_write(BCD_ASCII(a),LED);
   print_xy(50,LED);lcd_write(BCD_ASCII(b),LED);
   print_xy(51,LED);lcd_write(BCD_ASCII(c),LED);
   print_xy(52,LED);lcd_write(BCD_ASCII(d),LED);*/
   hora(LED);
   
  }
  
}

No hay comentarios:

IRC

#freenode->#usljujuy

Seguidores

Eventos n_n

Tira Ecol Nano,Bilo y Luca