/Modules/Sensors/ALTIMET01A/SW/PIC/PIC16F887/main.c |
---|
0,0 → 1,66 |
#include <16f887.h> |
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP |
#use delay(clock = 20000000) |
#use rs232(baud=57600, xmit=PIN_C6, rcv=PIN_C7) |
#define CSN_SPI PIN_C2 |
int8 address, uiTadc, data ; |
// SPI mode definitions. |
#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H) |
#define SPI_MODE_1 (SPI_L_TO_H) |
#define SPI_MODE_2 (SPI_H_TO_L) |
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H) |
void main() |
{ |
printf("Start\n\r"); |
setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64); |
output_high(CSN_SPI); |
delay_ms(100); |
while(true) |
{ |
data = 5; //just to be sure that the value is updated |
//Start temperature and pressure conversion |
address = 0x24; |
address &= 0x7F; |
output_low(CSN_SPI); |
delay_ms(1); |
spi_write(address); |
delay_ms(1); |
spi_write(0x00); |
delay_ms(1); |
output_high(CSN_SPI); |
delay_ms(2); |
// get MSB for Pressure |
address = 0x00; |
address |= 0x80; |
output_low(CSN_SPI); |
delay_ms(1); |
spi_write(address); |
delay_ms(1); |
data = spi_read(0x00); |
delay_ms(1); |
output_high(CSN_SPI); |
printf("%u\n\r", data); |
//uiTadc = (unsigned int) data << 8; |
//printf("%u\n\r", uiTadc); |
delay_ms(100); |
} |
} |
/Modules/Sensors/ALTIMET01A/SW/PIC/PIC16F887/main.h |
---|
0,0 → 1,20 |
#include <16F887.h> |
#device adc=10 |
#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) |
#use rs232(baud=9600,parity=N,xmit=PIN_B7,rcv=PIN_B6,bits=8) |
/Modules/Sensors/ALTIMET01A/SW/PIC/PIC16F887/main.pjt |
---|
0,0 → 1,31 |
[PROJECT] |
Target=main.hex |
Development_Mode= |
Processor_Text=PIC16F887 |
ToolSuite=CCS |
Processor=0x887F |
[main] |
Type=4 |
Path= |
FileList= |
BuildTool= |
OptionString= |
AdditionalOptionString= |
[mru-list] |
1=main.c |
[Windows] |
0=0000 %S 0 0 796 451 3 0 |
[Opened Files] |
1=main.c |
2= |
3=C:\Program Files\PICC\devices\16F887.h |
4=C:\Program Files\PICC\drivers\lcd.c |
5=..\ds1820.c |
6=..\1wire.c |
7= |
[Target Data] |
OptionString=-p +FM |
FileList=D:\MLAB\Designs\Thermometer\SW\PIC16F887\main.c |
[Units] |
Count=1 |
1=main (main) |