/Modules/Sensors/ALTIMET01A/SW/PIC/PIC16F887/main.c
18,10 → 18,10
#define SPI_MODE_2 (SPI_H_TO_L)
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
 
unsigned int16 a0;
unsigned int16 b1;
unsigned int16 b2;
unsigned int16 c12;
signed int16 a0;
signed int16 b1;
signed int16 b2;
signed int16 c12;
 
 
int MPL_init()
64,8 → 64,8
 
float MPL_get_pressure()
{
int8 LSB_data, MSB_data;
int16 ADC_pressure, ADC_temperature;
unsigned int8 LSB_data, MSB_data;
unsigned int16 ADC_pressure, ADC_temperature;
 
output_low(CSN_SPI); //Start temperature and pressure conversion
spi_write(0x24);
72,7 → 72,7
spi_write(0x00);
output_high(CSN_SPI);
 
delay_ms(3);
delay_ms(10);
output_low(CSN_SPI); // get MSB for Pressure
spi_write(0x80);
79,9 → 79,12
LSB_data = spi_read(0x00);
spi_write(0x82); // get LSB for Pressure
MSB_data = spi_read(0x00);
output_high(CSN_SPI);
 
printf("%lX %lX\r\n", MSB_data, LSB_data);
ADC_pressure = ((int16) MSB_data << 8) + LSB_data; // conversion of 8bit registers to 16bit variable
 
output_low(CSN_SPI);
spi_write(0x84);
LSB_data = spi_read(0x00);
spi_write(0x86); // get LSB for Temperature
89,9 → 92,10
spi_read(0x00);
output_high(CSN_SPI);
 
printf("%lX %lX\r\n", MSB_data, LSB_data);
ADC_temperature = ((int16) MSB_data << 8) + LSB_data; // conversion of 8bit registers to 16bit variable
 
// printf("%lX %lX\r\n", ADC_pressure, ADC_temperature);
printf("%lX %lX\r\n", ADC_pressure, ADC_temperature);
 
return (a0 + (b1 + c12 * ADC_temperature) * ADC_pressure + b2 * ADC_temperature );
}
107,7 → 111,11
 
while(true)
{
printf("%f \r\n", MPL_get_pressure());
delay_ms(100);
// MPL_init();
// printf("%f \r\n", MPL_get_pressure());
// printf("%ld %ld %ld %ld \r\n",a0, b1, b2, c12);
MPL_get_pressure();
 
delay_ms(500);
}
}
/Modules/Sensors/ALTIMET01A/SW/PIC/PIC16F887/main.hex
1,18 → 1,18
:1000000003308A00F22B0000533A613974100D0559
:1000000002308A00FE2A0000533A613974100D054F
:10001000000083168613831286130830F800102818
:100020000000F8172128F813BA0C03188617031CD0
:100020000000F8172128F813B10C03188617031CD9
:100030008613781721287813F80B14281F2800003E
:1000400086173F308400840B23280000F81B1328F8
:10005000781B1B280800831603178C170C1400004C
:10006000000083120C087F3903196F280313A900BD
:1000700003170D080313AA0003170F080313AB009F
:100080002908BA0009202A0803178D0003132B083A
:100080002908B10009202A0803178D0003132B0843
:1000900003178F0083168C170C14000000008312C6
:1000A0000C0D0E0D7F3903196F280313A9000317D8
:1000B0000D080313AA0003170F080313AB00290848
:1000C000BA0009202A0803178D0003132B08031711
:1000C000B10009202A0803178D0003132B0803171A
:1000D0008F008D0A03198F0A03132B2803170313AC
:1000E0008A110A12162C2F3084008313000803197A
:1000E0008A110A12222B2F3084008313000803196F
:1000F00086280230F800F701F70B7C28F80B7B28E4
:100100009730F700F70B8228800B79280800281118
:10011000280883168700831207111308883093007C
35,110 → 35,76
:10022000031C0F2983121308B000130893018316CF
:10023000140C031C18298312281128088316870020
:1002400083120715B2012908B100B200B1012A08D2
:100250003107A0003208A1000318A10AB2012B083F
:10026000B100B200B1012C083107A2003208A3008E
:100270000318A30AB2012D08B100B200B1012E0883
:100280003107A4003208A5000318A50AB2012F08FF
:10029000B100B200B10130083107A6003208A70052
:1002A0000318A70A8A110A12362C1030B500F7017C
:1002B000FA01B20CB10C031C63293308F7070318C9
:1002C000FA0A3408FA07FA0CF70CF90CF80CB50B1B
:1002D000592908002811280883168700831207115E
:1002E0001308243093008316140C031C7429831202
:1002F000130893018316140C031C7B298312281105
:10030000280883168700831207150330AF00732077
:1003100028112808831687008312071113088030DC
:1003200093008316140C031C922983121308930163
:100330008316140C031C992983121308A9001308AF
:10034000823093008316140C031CA3298312130814
:1003500093018316140C031CAA2983121308AA0004
:10036000B0012A08AF00B000AF0129082F07AB0089
:100370003008AC000318AC0A1308843093008316CD
:10038000140C031CC0298312130893018316140C48
:10039000031CC72983121308A90013088630930091
:1003A0008316140C031CD12983121308930183169E
:1003B000140C031CD82983121308AA0013089301F4
:1003C0008316140C031CE1298312281128088316B4
:1003D000870083120715B0012A08AF00B000AF01F3
:1003E00029082F07AD003008AE000318AE0A270811
:1003F000B2002608B1002E08B4002D08B300552124
:100400007908FA0078082207AF002308B0007A08BC
:1004100003187A0FB0073008B2002F08B1002C087B
:10042000B4002B08B30055217908FA00780820079A
:10043000AF002108B0007A0803187A0FB00725082A
:10044000B2002408B1002E08B4002D08B3005521D5
:100450007908FA0078082F07F80030080318300FE1
:10046000FA077808AF007A08B0008E30F70030083D
:10047000F8002F08F900FA01F808031D492A790845
:10048000F800F9010830F702F808031D492AF701BE
:10049000512A0310F81B502AF90DF80DF703492AC9
:1004A000F8138A110A12372CF701F801F901FA0141
:1004B000C201C301C401C501410840043F043E0418
:1004C0000319922A2030C6000310BA0DBB0DBC0DD3
:1004D000BD0DC20DC30DC40DC50D41084502031D60
:1004E0007B2A40084402031D7B2A3F084302031D68
:1004F0007B2A3E084202031C8C2A3E08C2023F08A7
:10050000031C3F0FC3024008031C400FC4024108F4
:10051000031C410FC5020314F70DF80DF90DFA0D78
:10052000C60B642A42308400831308000408B2001A
:100530003108B4000319282B3008BD002F08BC0077
:100540002E08BB002D08BA00C101C0012030BF0039
:100550008230BE003A0803191A2BC2003E08031964
:100560001A2BC2070318BB2A7F30C202031C1A2BA6
:1005700003191A2BBF2A8130C20703181A2B42080D
:10058000F700F801F901FA013B08C600C6173C085C
:10059000C5003D08C4001830C200C301441CE82A4D
:1005A0004108FA07031CDA2AF90A031DDA2AF80AB5
:1005B0000319C3174008F907031CE12AF80A0319B5
:1005C000C3173F08BC00BC173C08F8070318C31743
:1005D000C30DF80CF90CFA0CC60CC50CC40C0310B6
:1005E000C20BCD2A0130F70703181A2BF81BFF2A7C
:1005F000C60DFA0DF90DF80DF70303191A2BC61FD6
:10060000102BFA0A031D102BF90A031D102BF80AF0
:10061000031D102BF80CF90CFA0CF70A03191A2B0E
:100620003B08C3003F08C306C31F182BF8171E2B37
:10063000F8131E2BF701F801F901FA017A08B0004E
:100640007908AF007808AE007708AD00B40B9C2A9B
:100650003008BD002F08BC002E08BB002D08BA00D2
:100660003A08B63CBA00FA013B08BE00BB170310BB
:10067000BB0CBC0CBD0CFA0CF90CF80CF70CBA0B4B
:10068000372BBE1F4E2BF709F809F909FA09F70AAB
:100690000319F80A0319F90A0319FA0A7A08B000CB
:1006A0007908AF007808AE007708AD00B01F652B61
:1006B000B203B216AD09AE09AF09B009AD0A03190C
:1006C000AE0A0319AF0A0319B00A3B30B9009A30D9
:1006D000B800CA30B700B6010A30B40031080319B7
:1006E000B20A3008BD002F08BC002E08BB002D0840
:1006F000BA003908C1003808C0003708BF00360802
:10070000BE0054220008AD00840A0008AE00840A2E
:100710000008AF00840A0008B000FD308407F70825
:10072000031DA52B310A34020319A52B3208031926
:10073000A72B0F39340203199F2B0318D72BB21B99
:10074000D72B321BA72B2030D32B2030B205B21E63
:10075000B52BB2123108031DB2037708B2002D3059
:10076000BA0009203208F700B20131083402031D33
:10077000C32B7708B2002E30BA0009203208F700E8
:100780002030B20500303030B21ED32BB212310807
:10079000031DB2037708B2002D30BA0009203208D9
:1007A000F700B2013030F7077708BA00092039089E
:1007B000BD003808BC003708BB003608BA00C101CC
:1007C000C001BF010A30BE0054227A08B90079087E
:1007D000B8007808B7007708B600B40B712B8A11FF
:1007E0000A124C2C840183131F3083057130831649
:1007F0008F000F08861383128617831603170908C4
:10080000C039890003131F129F120030031788009C
:100810008312870188018901FF300313A800043087
:1008200003178D0000308F0003132B289412A81299
:100830002808831687008312281628088316870045
:100840008312A8112808831687002230831294008F
:1008500040308316940083122811280883168700DD
:10086000831207156430AF00732087286A29770840
:10087000A9007808AA007908AB007A08AC00893092
:1008800084007A08B0007908AF007808AE007708D5
:10089000AD000230B100962A2030BA0009200D3098
:1008A000BA0009200A30BA0009206430AF00732072
:0408B000362C63007F
:100250003107F8003208FA000318FA0A7808A000FB
:100260007A08A100B2012B08B100B200B1012C083C
:100270003107F8003208FA000318FA0A7808A200D9
:100280007A08A300B2012D08B100B200B1012E0816
:100290003107F8003208FA000318FA0A7808A400B7
:1002A0007A08A500B2012F08B100B200B1013008F0
:1002B0003107F8003208FA000318FA0A7808A60095
:1002C0007A08A7008A110A12422BB01B77290F3037
:1002D000F7002F0EF7050A30770203187229303025
:1002E000F70774293008F7077708B10009200F30A5
:1002F000AF050A302F0203187F2930308129B0134F
:100300003008AF072F08B100092008003208340672
:100310008039B600B21F9129B109B209B10A031997
:10032000B20AB41F9829B309B409B30A0319B40A6D
:100330001030B500F701FA01B20CB10C031CA6296C
:100340003308F7070318FA0A3408FA07FA0CF70C0F
:10035000F90CF80CB50B9C29B61FB329F809F9095B
:10036000F80A0319F90A08002811280883168700DB
:10037000831207111308243093008316140C031CF6
:10038000BE298312130893018316140C031CC5297C
:1003900083122811280883168700831207150A3054
:1003A000AF007320281128088316870083120711D5
:1003B0001308803093008316140C031CDC2983126D
:1003C000130893018316140C031CE32983121308EA
:1003D000A9001308823093008316140C031CED2926
:1003E0008312130893018316140C031CF42983123F
:1003F0001308AA00281128088316870083120715FE
:100400002A08AF003730B00065212030B100092044
:100410002030B10009202908AF003730B000652135
:100420000D30B10009200A30B1000920B0012A08BE
:10043000AF00B000AF0129082F07AB003008AC00B7
:100440000318AC0A281128088316870083120711A5
:100450001308843093008316140C031C2C2A831277
:10046000130893018316140C031C332A83121308F8
:10047000A9001308863093008316140C031C3D2A30
:100480008312130893018316140C031C442A83124D
:100490001308AA00130893018316140C031C4D2A99
:1004A00083122811280883168700831207152A084B
:1004B000AF003730B00065212030B1000920203076
:1004C000B10009202908AF003730B00065210D3098
:1004D000B10009200A30B1000920B0012A08AF009C
:1004E000B000AF0129082F07AD003008AE00031897
:1004F000AE0A2C08AF003730B00065212B08AF00E2
:100500003730B00065212030B10009202030B10023
:1005100009202E08AF003730B00065212D08AF004C
:100520003730B00065210D30B10009200A30B1002C
:1005300009202708B2002608B1002E08B4002D08B3
:10054000B30086217908FA0078082207AF00230853
:10055000B0007A0803187A0FB0073008B2002F08ED
:10056000B1002C08B4002B08B30086217908FA00EA
:1005700078082007AF002108B0007A0803187A0F26
:10058000B0072508B2002408B1002E08B4002D08D9
:10059000B30086217908FA0078082F07F8003008A0
:1005A0000318300FFA077808AF007A08B0008E30D1
:1005B000F7003008F8002F08F900FA01B01FE52A0B
:1005C000F809F909F90A0319F80AF808031DF22ACB
:1005D0007908F800F9010830F702F808031DF22A3B
:1005E000F701FB2A0310F81BF92AF90DF80DF703A0
:1005F000F22AB01FF8138A110A12432B84018313C5
:100600001F308305713083168F000F088613831205
:100610008617831603170908C039890003131F12B0
:100620009F12003003178800831287018801890117
:10063000FF300313A800043003178D0000308F0033
:1006400003132B289412A8122808831687008312FC
:1006500028162808831687008312A81128088316F5
:100660008700223083129400403083169400831256
:100670002811280883168700831207156430AF00FD
:1006800073208728B4290230A900FA30AF00732004
:08069000A90B452B422B63006E
:04400E00F52CFF3F4F
:00000001FF
;PIC16F887
;CRC=EED4 CREATED="24-II-13 00:54"
;CRC=4B35 CREATED="24-II-13 17:31"