/Designs/Measuring_instruments/RMDS02C/SW/PIC16F887/main.c
22,19 → 22,24
 
unsigned int32 count; // count per second
 
int1 fire_setup; // flag for sending setup to GPS
 
#define BUF_LEN 4
int8 buffer[BUF_LEN]; // I2C buffer
int8 address=0;
 
unsigned int16 of=0; // count of overflow
 
// 1x 100 us per 10 s UTC synchronised; 40 configuration bytes
char cmd[50]={40, 0xB5, 0x62, 0x06, 0x31, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x80, 0x96, 0x98, 0x00, 0xE0, 0xC8, 0x10, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0xC6, 0x51};
 
// configure GPS
void setup_GPS()
{
// 1x 100 us per 10 s UTC synchronised
const char cmd[40]={0xB5, 0x62, 0x06, 0x31, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x80, 0x96, 0x98, 0x00, 0xE0, 0xC8, 0x10, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0xC6, 0x51};
int n;
for (n=0;n<40;n++) putc(cmd[n]);
int len;
len=cmd[0];
for (n=1;n<=len;n++) putc(cmd[n]);
}
 
#INT_SSP
52,6 → 57,18
{
address = incoming;
}
 
if(state == 2) //Thid received byte are configuration data
{
if ((address==0)&&(incoming==0))
{
fire_setup = 1; // Write configuration to the GPS if configuration data length is 0
}
else
{
cmd[address] = incoming; // Store byte to configuration sentence
}
}
}
if(state == 0x80) //Master is requesting data
{
64,9 → 81,12
buffer[2]=make8(count,2);
buffer[3]=make8(count,3);
}
if(address <= BUF_LEN) i2c_write(buffer[address]); // Prepare one byte to SSP buffer
else
if(address <= BUF_LEN)
{
i2c_write(buffer[address]); // Prepare one byte to SSP buffer
}
else
{
i2c_write(0x00); // There is nothing to prepare, so zero
}
}
81,9 → 101,7
}
if(state == 0x83) //Master is requesting data
{
i2c_write(buffer[3]); // Prepare next byte to SSP buffer
setup_GPS();
i2c_write(buffer[3]); // Prepare next byte to SSP buffer
}
 
if(state > 0x83) //Master is requesting data
163,13 → 181,20
buffer[2]=0x0;
buffer[3]=0x0;
 
printf("\r\ncvak...\r\n");
//printf("\r\ncvak...\r\n");
fire_setup = 0;
 
while(true)
{
restart_wdt();
delay_ms(1500);
// printf("%X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]);
printf("%010Lu\r\n", count);
delay_ms(1000);
if (fire_setup)
{
setup_GPS(); // Write configuration to the GPS
fire_setup = 0;
}
//printf("%X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]);
//printf("%010Lu\r\n", count);
}
}
/Designs/Measuring_instruments/RMDS02C/SW/PIC16F887/main.hex
1,4 → 1,4
:1000000002308A00AF2A0000FF00030E8301A10026
:1000000001308A00BD290000FF00030E8301A1001A
:100010000A08A0008A010408A2007708A300780853
:10002000A4007908A5007A08A600831383120B1E8A
:100030001B288B1838288C308400001C21280C18B1
5,109 → 5,84
:100040003B288C308400801D27288C193E282208EC
:1000500084002308F7002408F8002508F900260882
:10006000FA0020088A00210E8300FF0E7F0E09008F
:100070008A110A12E2288A110A12A3298A110A1285
:1000800087280A108A100A118207B53462340634B0
:10009000313420340034003400340034003432343D
:1000A0000034003400348034963498340034E03422
:1000B000C834103400346434003400340034003464
:1000C000003400340034003400340034003473341D
:1000D000003400340034C6345134130854089300FB
:1000E00014168C11831614187328F8018312141A2D
:1000F000F80A0800D3015308273C031C862853083C
:1001000041200C1E81289900D30A7B280800831601
:10011000941A92288312B7018316141D9228831211
:10012000B717831683123708B70AD20052087F3CEC
:10013000031CA42814138C1D9B2813081416D1002B
:10014000520BA4285108B4005208803C031DC22859
:10015000B408031DB3282C08B0002D08B1002E08E8
:10016000B2002F08B3003408043C031CC028303010
:100170003407840083130008D300D4006D20C22804
:10018000D4016D205208813C031DC9283108D400D8
:100190006D205208823C031DD0283208D4006D2007
:1001A0005208833C031DD8283308D4006D207A20E0
:1001B0005208833C0318DE28D4016D208C118A116B
:1001C0000A1227283608D5003508D4000F08FA008F
:1001D0000E08F7000F087A02031DE6287708D10001
:1001E0007A08D200D30183160910831209108316EE
:1001F0008910831289102914290883168700831215
:10020000D3010718D30A831609108312091429147D
:100210002908831687000030831207180130F70081
:100220000310F70D7708D304831609108312091001
:1002300083168910831289142914290883168700CC
:100240000030831207180130F700F70DF70DFC306E
:10025000F7057708D30483160910831209142914AB
:100260002908831687000030831207180130F70031
:10027000F70DF70DF70DF830F7057708D30483165F
:1002800009118312091183160911831209158F01AF
:100290008E01B601B501D901D8015508D70054081F
:1002A000D6005508D9005408D800D601D701D80D7A
:1002B000D90DD80DD90DD80DD90DD80DD90DF030D7
:1002C000D805DE01DD01510DF700520DF8005D0D7E
:1002D000F9005E0DFA00F70DF80DF90DFA0DF70DA6
:1002E000F80DF90DFA0DF70DF80DF90DFA0DF030C6
:1002F000F7057708D60778080318780FD707790825
:100300000318790FD8077A0803187A0FD907F8016C
:10031000F901FA0153085607AC005708AD007808F8
:100320000318780FAD075808AE0079080318790F45
:10033000AE075908AF007A0803187A0FAF078B1081
:100340008A110A122728B50A0319B60A0C108A1155
:100350000A1227280D05633BE1352E17AE060A0069
:1003600039308400831300080319C3290630F800CC
:10037000F701F70BB929F80BB8297B30F700F70B19
:10038000BF29800BB6290800831603178C170C149D
:100390000000000083120C087F3903190A2A031396
:1003A000B80003170D080313B90003170F08031350
:1003B000BA0038080C1EDA299900390803178D0095
:1003C00003133A0803178F0083168C170C140000D0
:1003D000000083120C0D0E0D7F3903190A2A031336
:1003E000B80003170D080313B90003170F08031310
:1003F000BA0038080C1EFA299900390803178D0035
:1004000003133A0803178F008D0A03198F0A031389
:10041000C429031703138A110A12472BF701F801A5
:10042000F901FA01CC01CD01CE01CF014B084A04FC
:100430004904480403194C2A2030D0000310C40D8D
:10044000C50DC60DC70DCC0DCD0DCE0DCF0D4B0876
:100450004F02031D352A4A084E02031D352A49085A
:100460004D02031D352A48084C02031C462A480841
:10047000CC024908031C490FCD024A08031C4A0F4D
:10048000CE024B08031C4B0FCF020314F70DF80DDF
:10049000F90DFA0DD00B1E2A4C308400831308008E
:1004A0000408BC003B30C3009A30C200CA30C1000F
:1004B000C0010A30BE003B08C7003A08C600390830
:1004C000C5003808C4004308CB004208CA004108F0
:1004D000C9004008C8000E220008B800840A0008BD
:1004E000B900840A0008BA00840A0008BB00F708B3
:1004F000031D8D2A3E08013A03198D2A3C08031971
:100500008E2A0F393E020319872A0318942ABC1B2E
:10051000942A3C1B8E2A20308F2ABC013030F707EA
:1005200077080C1E912A99004308C7004208C600AC
:100530004108C5004008C400CB01CA01C9010A3006
:10054000C8000E227A08C3007908C2007808C100EA
:100550007708C000BE0B5B2A8A110A125A2B84014D
:1005600083131F3083058316031787150830031381
:10057000990002309A00A6309800903083129800BB
:10058000A9152908831687008312291629088316BE
:100590008700A2309300363083129400B401B60174
:1005A000B501831603170908C039890003131F1208
:1005B0009F12003003178800831287018801890188
:1005C0000313A801FF30A900AA01AB010330B70053
:1005D000831603170908C039890003131F129F12DD
:1005E000003003178800831203131F1083160108BD
:1005F000C7390838810009308312031785000F308E
:10060000F700031381018130840083130008F0395F
:100610000738800064000008F739F719F0397704CB
:100620008000073090000030F80092000030831600
:10063000920083120317870188018901831603132F
:100640009701640004308312B800FA30B900B02179
:10065000B80B252B6400A7018B1BA7178B137A20DF
:10066000A71B8B17831601170C1483120B16831606
:100670008C15C03083128B04B001B101B201B301FB
:10068000AA3003178D0001308F000313C4296400C2
:100690000630B800FA30B900B021B80B4A2B4A3006
:1006A00084002F08BB002E08BA002D08B9002C08C2
:1006B000B800502A0D300C1E5B2B99000A300C1E1E
:0806C0005F2B9900472B63003A
:100070008A110A12BA288A110A128D298A110A12C3
:100080004E2813087008930014168C118316141848
:100090004728F8018312141AF80A08008316941AE4
:1000A00059288312E9018316141D59288312E91770
:1000B000831683126908E90AEE006E087F3C031C70
:1000C0007D2814138C1D622813081416ED006E0B86
:1000D0006B286D08B4006E08023C031D7D28B4082F
:1000E000031D7728ED08031D77282F147D2837304E
:1000F0003407840083136D0880006E08803C031D64
:100100009B28B408031D8C282B08B0002C08B100D4
:100110002D08B2002E08B3003408043C031C9928B3
:1001200030303407840083130008EF00F0004120D2
:100130009B28F00141206E08813C031DA228310854
:10014000F00041206E08823C031DA9283208F0000F
:1001500041206E08833C031DB0283308F000412085
:100160006E08833C0318B628F00141208C118A11D7
:100170000A1227283608F1003508F0000F08FA00A7
:100180000E08F7000F087A02031DBE287708ED005D
:100190007A08EE00EF018316091083120910831606
:1001A0008910831289102814280883168700831267
:1001B000EF010718EF0A8316091083120914281497
:1001C0002808831687000030831207180130F700D3
:1001D0000310F70D7708EF04831609108312091036
:1001E000831689108312891428142808831687001F
:1001F0000030831207180130F700F70DF70DFC30BF
:10020000F7057708EF0483160910831209142814E0
:100210002808831687000030831207180130F70082
:10022000F70DF70DF70DF830F7057708EF04831693
:1002300009118312091183160911831209158F01FF
:100240008E01B601B5018316A301A2017108A100B8
:100250007008A0002108A3002008A200A001A101AD
:10026000A20DA30DA20DA30DA20DA30DA20DA30D12
:10027000F030A205A801A70183126E088316A6001C
:1002800083126D088316A500250DF700260DF800D2
:10029000270DF900280DFA00F70DF80DF90DFA0DEC
:1002A000F70DF80DF90DFA0DF70DF80DF90DFA0D22
:1002B000F030F7057708A00778080318780FA10732
:1002C00079080318790FA2077A0803187A0FA30791
:1002D0008312F801F901FA016F08831620078312CF
:1002E000AB00831621088312AC0078080318780F3E
:1002F000AC07831622088312AD0079080318790F22
:10030000AD07831623088312AE007A0803187A0F0C
:10031000AE078B108A110A122728B50A0319B60AEC
:100320000C108A110A1227286B30840083130008EE
:100330000319A7290630F800F701F70B9D29F80BE0
:100340009C297B30F700F70BA329800B9A29080022
:100350003708EB000130EA006A086B02031CBC2975
:1003600037306A07840083130008EC006C080C1E09
:10037000B7299900EA0AAC290800840183131F30C9
:10038000830583160317871508300313990002307D
:100390009A00A6309800903083129800A81528087B
:1003A0008316870083122816280883168700A23038
:1003B0009300363083129400B401B601B501831660
:1003C00003170908C039890003131F129F12003058
:1003D0000317880083128701880189010313A7018D
:1003E000FF30A800A901AA012830B700B530B80035
:1003F0006230B9000630BA003130BB002030BC009A
:10040000BD01BE01BF01C001C1013230C200C30144
:10041000C401C5018030C6009630C7009830C800BE
:10042000C901E030CA00C830CB001030CC00CD018B
:100430006430CE00CF01D001D101D201D301D4016B
:10044000D501D601D701D801D9017330DA00DB011B
:10045000DC01DD01C630DE005130DF00E001E101EA
:10046000E201E301E401E501E601E701E80103300F
:10047000E900831603170908C039890003131F1206
:100480009F12003003178800831203131F10831676
:100490000108C73908388100093083120317850025
:1004A0000F30F700031381018130840083130008AB
:1004B000F0390738800064000008F739F719F0397F
:1004C00077048000073090000030F8009200003080
:1004D000831692008312031787018801890183160E
:1004E00003139701640004308312EA00FA30EB0032
:1004F0009421EA0B762A6400A821831601170C14B4
:1005000083120B1683168C15C03083128B04B00136
:10051000B101B201B3012F1064000430EA00FA30D7
:10052000EB009421EA0B8F2A2F1C982AA8212F1068
:040530008C2A6300AE
:04400E00EA2CFF3F5A
:00000001FF
;PIC16F887
;CRC=E464 CREATED="16-Oct-14 22:09"
;CRC=EE34 CREATED="17-Oct-14 14:31"