/Modules/Sensors/ALTIMET01A/SW/PIC/PIC16F887/main.c |
---|
1,73 → 1,73 |
#include <main.h> |
/* |
MPL115A1 SDN - +5V (always power on) |
MPL115A1 CSN - PIN_C2 |
MPL115A1 SDO - PIN_C4 (twisted?) |
MPL115A1 SDI - PIN_C5 (twisted?) |
MPL115A1 SCK - PIN_C3 |
MPL115A1 GND - GND |
MPL115A1 VDD - +5V |
*/ |
#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); |
} |
} |
#include <main.h> |
/* |
MPL115A1 SDN - +3.3V (always power on) |
MPL115A1 #CS - PIN_C2 |
MPL115A1 DOUT - PIN_C4 (twisted?) |
MPL115A1 DIN - PIN_C5 (twisted?) |
MPL115A1 SCLK - PIN_C3 |
MPL115A1 GND - GND |
MPL115A1 VDD - +3.3V |
*/ |
#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 \r\n"); |
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 \r\n", data); |
//uiTadc = (unsigned int) data << 8; |
//printf("%u\n\r", uiTadc); |
delay_ms(100); |
} |
} |
/Modules/Sensors/ALTIMET01A/SW/PIC/PIC16F887/main.hex |
---|
0,0 → 1,52 |
:1000000000308A00D3280000533A613974100D057E |
:10001000000083168613831286130830F800102818 |
:100020000000F8172128F813A70C03188617031CE3 |
:100030008613781721287813F80B14281F2800003E |
:1000400086173F308400840B23280000F81B1328F8 |
:10005000781B1B280800831603178C170C1400004C |
:10006000000083120C087F3903196F280313A400C2 |
:1000700003170D080313A50003170F080313A600A9 |
:100080002408A7000920250803178D00031326085C |
:1000900003178F0083168C170C14000000008312C6 |
:1000A0000C0D0E0D7F3903196F280313A4000317DD |
:1000B0000D080313A50003170F080313A600240857 |
:1000C000A7000920250803178D000313260803172E |
:1000D0008F008D0A03198F0A03132B2803170313AC |
:1000E0008A110A12F72824308400831300080319A8 |
:1000F00086280230F800F701F70B7C28F80B7B28E4 |
:100100009730F700F70B8228800B79280800270822 |
:10011000F801260203188F282608F7009B28F7010C |
:100120000830A800A60DF70D270877020318F7007E |
:10013000F80DA80B9228080078082408A60064305F |
:10014000A70087207708A40078083030031DAF2867 |
:10015000A51CB628A519B628251A2030B228A51145 |
:1001600025122514F8077808A70009202408A600FE |
:100170000A30A70087207708A40078083030031DD4 |
:10018000C728A519CB28251CCB28251A2030F8070D |
:100190007808A70009203030A4072408A700092008 |
:1001A0008A110A126D29840183131F30830571306F |
:1001B00083168F000F088613831286178316031782 |
:1001C0000908C039890003131F129F12003003175A |
:1001D00088008312870188018901FF300313A3007F |
:1001E000043003178D0000308F0003132B28941266 |
:1001F000A31223088316870083122316230883166D |
:1002000087008312A31123088316870022308312EC |
:100210009400403083169400831223112308831620 |
:100220008700831207156430A40073200530A200F4 |
:100230002430A000A0132311230883168700831203 |
:1002400007110130A4007320200893008316140CBA |
:10025000031C272901308312A40073201308930183 |
:100260008316140C031C312901308312A40073205F |
:100270002311230883168700831207150230A40078 |
:100280007320A001A017231123088316870083126F |
:1002900007110130A4007320200893008316140C6A |
:1002A000031C4F2901308312A4007320130893010B |
:1002B0008316140C031C592983121308A200013061 |
:1002C000A4007320231123088316870083120715C7 |
:1002D0002208A4001B30A5009C282030A70009207C |
:1002E0000D30A70009200A30A70009206430A400BF |
:0602F000732016296300D3 |
:04400E00F52CFF3F4F |
:00000001FF |
;PIC16F887 |
;CRC=E2BF CREATED="23-II-13 01:55" |
/Modules/Sensors/ALTIMET01A/SW/PIC/PIC16F887/main.pjt |
---|
19,13 → 19,13 |
1=main.c |
2= |
3=C:\Program Files\PICC\devices\16F887.h |
4=C:\Program Files\PICC\drivers\lcd.c |
4= |
5=..\ds1820.c |
6=..\1wire.c |
7= |
[Target Data] |
OptionString=-p +FM |
FileList=D:\MLAB\Designs\Thermometer\SW\PIC16F887\main.c |
FileList=D:\MLAB\Modules\Sensors\ALTIMET01A\SW\PIC\PIC16F887\main.c |
[Units] |
Count=1 |
1=main (main) |