/Designs/Measuring_instruments/AWS01B/SW/PIC16F887/i2c_wind_sensor/main.c
1,5 → 1,5
#include "main.h"
#use i2c(Slave,Fast,sda=PIN_B1,scl=PIN_B4,force_hw,address=0xA2) // Motor 2
#use i2c(Slave,Fast,sda=PIN_C4,scl=PIN_C3,force_hw,address=0xA2) // Motor 2
 
#define H1 PIN_A1
#define L1 PIN_A2
15,17 → 15,17
 
output_a(0); // vypnuti vsech budicu
 
state = i2c_isr_state();
state = i2c_isr_state();
 
if(state < 0x80) //Master is sending data
{
command = i2c_read();
}
if(state < 0x80) //Master is sending data
{
command = i2c_read();
}
 
if(state == 0x80) //Master is requesting data
{
i2c_write(command);
}
if(state == 0x80) //Master is requesting data
{
i2c_write(command);
}
}
 
 
/Designs/Measuring_instruments/AWS01B/SW/PIC16F887/i2c_wind_sensor/main.h
1,18 → 1,27
#include <16F88.h>
#include <16F887.h>
#device adc=8
 
#FUSES WDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES PUT //Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOIESO //Internal External Switch Over mode disabled
 
 
//#FUSES WDT // Watch Dog Timer
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES NOPUT //No Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOCPD //No EE protection
#FUSES NOBROWNOUT //No brownout reset
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOWRT //Program memory not write protected
#FUSES BORV40 //Brownout reset at 4.0V
 
#use delay(clock=8000000)
 
//set I2C
//#use i2c(Master,Slow,sda=PIN_C4,scl=PIN_C3)
 
//set RS232
#use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)