/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.c
1,17 → 1,24
#include "main.h"
 
#include <string.h>
 
#define LED PIN_E1
#define CE PIN_E2
 
int16 count;
#define SEL0 PIN_E0 // external counter division ratio
#define SEL1 PIN_E1 // external counter division ratio
#define MR PIN_E2 // external counter master reset
#define CLKI PIN_C0 // internal counter input
#define BEEP PIN_C3 // buzzer
 
int8 rcv_buf[0x10]; // I2C receive buffer
int8 snd_buf[0x10]; // I2C send buffer
unsigned int32 count;
 
 
int8 buffer[0x10]; // I2C buffer
int8 address;
 
unsigned int16 of=0; // count of overflow
 
const char cmd[40]={0xB5, 0x62, 0x06, 0x31, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x80, 0x84, 0x1E, 0x00, 0xE0, 0xC8, 0x10, 0x00, 0x40, 0x42, 0x0F, 0x00, 0xA0, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7, 0x00, 0x00, 0x00, 0x12, 0x03};
 
#INT_SSP
31,6 → 38,8
{
buffer[0]=make8(count,0);
buffer[1]=make8(count,1);
buffer[2]=make8(count,2);
buffer[3]=make8(count,3);
}
}
if(state == 2) //Second received byte is data
45,7 → 54,55
}
 
 
#int_TIMER2 // every 10 ms
#int_EXT // Interrupt from 1PPS
void EXT_isr(void)
{
unsigned int16 countH;
unsigned int8 countL;
char countS[10], a[4], b[4], c[4]; // strings for printing results
countL=0;
countH=get_timer1(); // read internal counter
output_low(SEL0);
output_low(SEL1);
countL=input(CLKI); // read bit 0 of external counter
output_high(SEL0);
output_low(SEL1);
countL|=input(CLKI)<<1; // read bit 1 of external counter
output_low(SEL0);
output_high(SEL1);
countL|=input(CLKI)<<2; // read bit 2 of external counter
output_high(SEL0);
output_high(SEL1);
countL|=input(CLKI)<<3; // read bit 3 of external counter
 
output_low(MR); // External counter Master Reset
output_high(MR);
set_timer1(0); // Internal counter reset
count=((unsigned int32)of<<20)+((unsigned int32)countH<<4)+(unsigned int32)countL; // concatenate
 
sprintf(countS,"%09Lu", count); // engeneering values conversion
strncpy(a, countS, 3); a[3]='\0';
strncpy(b, &countS[3], 3); b[3]='\0';
strncpy(c, &countS[6], 3); c[3]='\0';
printf("%s\r\n", countS); // output to RS232
 
output_toggle(BEEP); // cvak...
 
of=0; // reset overflow counter
}
 
#int_TIMER1 // Interrupf from overflow
void TIMER1_isr(void)
{
of++;
}
 
 
/*#int_TIMER2 // every 10 ms
void TIMER2_isr(void)
{
output_low(CE);
52,7 → 109,7
count=get_timer1();
set_timer1(0);
output_high(CE);
}
}*/
 
void main()
59,7 → 116,7
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
// setup_spi(SPI_SS_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
// setup_wdt(WDT_144MS);
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);
70,32 → 127,24
delay_ms(1000);
int n;
for (n=0;n<40;n++)
{
putc(cmd[n]);
}
for (n=0;n<40;n++) putc(cmd[n]); // setup GPS
 
printf("cvak...\r\n");
// snd_buf[2]=0x55;
// snd_buf[3]=0xAA;
set_timer1(0);
ext_int_edge( L_TO_H ); // set 1PPS active edge
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_EXT);
enable_interrupts(INT_SSP);
// enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
 
while(true)
{
output_high(LED);
output_low(LED);
set_timer1(0);
output_high(CE);
delay_ms(999);
delay_us(966);
output_low(CE);
count=get_timer1();
printf("count: %Lu %X %X %X %X\r\n",count, buffer[0],buffer[1],buffer[2],buffer[3]);
{
/* output_high(LED);
delay_ms(999);
output_low(LED);
delay_ms(999);
printf("%X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]);
*/
}
}
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.err
1,4 → 1,3
>>> Warning 202 "Z:\home\kaklik\svn\svnMLAB\Designs\Measuring_instruments\RMDS01C\SW\PIC887\main.h" Line 19(5,8): Variable never used: rs232_errors
>>> Warning 202 "main.c" Line 9(6,13): Variable never used: rcv_buf
Memory usage: ROM=10% RAM=18% - 22%
0 Errors, 2 Warnings.
>>> Warning 202 "Z:\home\kaklik\svn\svnMLAB\Designs\Measuring_instruments\RMDS01C\SW\PIC16F887\main.h" Line 19(5,8): Variable never used: rs232_errors
Memory usage: ROM=12% RAM=12% - 26%
0 Errors, 1 Warnings.
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.esym
1,7 → 1,8
D G "__PCM__" 0 0 ""4.106""
D G "__DEVICE__" 0 0 ""
D G "__DATE__" 0 0 ""01-II-14""
D G "__TIME__" 0 0 ""20:13:30"" "Standard Header file for the PIC16F887 device ////////////////"
C L "MAIN" 0 20 5 "FUNCTION"
D G "__PCM__" 0 152 ""4.106""
D G "__DEVICE__" 0 152 "887"
D G "__DATE__" 0 152 ""04-II-14""
D G "__TIME__" 0 152 ""11:45:16"" "Standard Header file for the PIC16F887 device ////////////////"
d G "PIN_A0" 2 20 "40"
d G "PIN_A1" 2 21 "41"
d G "PIN_A2" 2 22 "42"
273,27 → 274,182
d G "INT_RB5" 2 418 "0x0200B08"
d G "INT_RB6" 2 419 "0x0400B08"
d G "INT_RB7" 2 420 "0x0800B08"
D G "LED" 0 4 "PIN_E1"
D G "CE" 0 5 "PIN_E2"
V G "count" 0 7 "int16"
V G "rcv_buf" 0 9 "int8[16]" "I2C receive buffer"
V G "snd_buf" 0 10 "int8[16]" "I2C send buffer"
V G "buffer" 0 12 "int8[16]" "I2C buffer"
V G "address" 0 13 "int8"
V G "cmd" 0 15 "int8[40]"
F G "ssp_interupt" 0 18 "void()"
V L "incoming" 0 20 "int8"
V L "state" 0 20 "int8"
C L "ssp_interupt" 0 24 1 "FUNCTION"
C L "ssp_interupt" 0 24 1 "FUNCTION"
C L "ssp_interupt" 0 24 1 "FUNCTION"
C L "ssp_interupt" 0 24 1 "FUNCTION"
F G "TIMER2_isr" 0 49 "void()"
F G "MAIN" 0 58 "void()"
C L "MAIN" 0 24 1 "FUNCTION"
C L "MAIN" 0 24 1 "FUNCTION"
V L "n" 0 72 "int8"
C L "MAIN" 0 24 1 "FUNCTION"
D G "_STRING" 3 12 ""
D G "_STDDEF" 4 13 ""
D G "ptrdiff_t" 4 18 "unsigned int16"
D G "size_t" 4 21 "unsigned int8"
D G "wchar_t" 4 22 "char"
D G "NULL" 4 23 "0"
D G "offsetof" 4 25 "(s,f) (offsetofbit(s,f)/8)"
D G "_CTYPE" 5 12 ""
D G "islower" 5 14 "(x) isamong(x,"abcdefghijklmnopqrstuvwxyz")"
D G "isupper" 5 15 "(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZ")"
D G "isalnum" 5 16 "(x) isamong(x,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")"
D G "isalpha" 5 17 "(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")"
D G "isdigit" 5 18 "(x) isamong(x,"0123456789")"
D G "isspace" 5 19 "(x) ((x)==' ')"
D G "isxdigit" 5 20 "(x) isamong(x,"0123456789ABCDEFabcdef")"
D G "iscntrl" 5 21 "(x) ((x)<' ')"
D G "isprint" 5 22 "(x) ((x)>=' ')"
D G "isgraph" 5 23 "(x) ((x)>' ')"
D G "ispunct" 5 24 "(x) (((x)>' ')&&!isalnum(x))"
C L "memmove" 3 19 10 "FUNCTION"
F G "memmove" 3 34 "*int8(*int8 s1,*int8 s2,int8 n)"
V L "s1" 3 34 "*int8"
V L "s2" 3 34 "*int8"
V L "n" 3 34 "int8"
V L "sc1" 3 36 "*int8"
V L "sc2" 3 37 "*int8"
D G "strcopy" 3 54 "strcpy"
C L "strncpy" 3 19 4 "FUNCTION"
F G "strncpy" 3 61 "*int8(*int8 s1,*int8 s2,int8 n)"
V L "s1" 3 61 "*int8"
V L "s2" 3 61 "*int8"
V L "n" 3 61 "int8"
V L "s" 3 63 "*int8"
C L "strcat" 3 19 3 "FUNCTION"
F G "strcat" 3 78 "*int8(*int8 s1,*int8 s2)"
V L "s1" 3 78 "*int8"
V L "s2" 3 78 "*int8"
V L "s" 3 80 "*int8"
C L "strncat" 3 19 2 "FUNCTION"
F G "strncat" 3 96 "*int8(*int8 s1,*int8 s2,int8 n)"
V L "s1" 3 96 "*int8"
V L "s2" 3 96 "*int8"
V L "n" 3 96 "int8"
V L "s" 3 98 "*int8"
C L "memcmp" 3 19 3 "FUNCTION"
F G "memcmp" 3 120 "sint8(*int8 s1,*int8 s2,int8 n)"
V L "s1" 3 120 "*int8"
V L "s2" 3 120 "*int8"
V L "n" 3 120 "int8"
V L "su1" 3 122 "*int8"
V L "su2" 3 122 "*int8"
C L "strcmp" 3 19 2 "FUNCTION"
F G "strcmp" 3 134 "sint8(*int8 s1,*int8 s2)"
V L "s1" 3 134 "*int8"
V L "s2" 3 134 "*int8"
C L "strcoll" 3 19 2 "FUNCTION"
F G "strcoll" 3 144 "sint8(*int8 s1,*int8 s2)"
V L "s1" 3 144 "*int8"
V L "s2" 3 144 "*int8"
C L "strncmp" 3 19 4 "FUNCTION"
F G "strncmp" 3 157 "sint8(*int8 s1,*int8 s2,int8 n)"
V L "s1" 3 157 "*int8"
V L "s2" 3 157 "*int8"
V L "n" 3 157 "int8"
C L "strxfrm" 3 19 3 "FUNCTION"
F G "strxfrm" 3 169 "int8(*int8 s1,*int8 s2,int8 n)"
V L "s1" 3 169 "*int8"
V L "s2" 3 169 "*int8"
V L "n" 3 169 "int8"
V L "s" 3 171 "*int8"
V L "n1" 3 172 "int8"
C L "memchr" 3 19 3 "FUNCTION"
F G "memchr" 3 191 "*int8(*int8 s,int8 c,int8 n)"
V L "s" 3 191 "*int8"
V L "c" 3 191 "int8"
V L "n" 3 191 "int8"
V L "uc" 3 193 "int8"
V L "su" 3 194 "*int8"
C L "strchr" 3 19 2 "FUNCTION"
F G "strchr" 3 205 "*int8(*int8 s,int8 c)"
V L "s" 3 205 "*int8"
V L "c" 3 205 "int8"
C L "strcspn" 3 19 4 "FUNCTION"
F G "strcspn" 3 217 "int8(*int8 s1,*int8 s2)"
V L "s1" 3 217 "*int8"
V L "s2" 3 217 "*int8"
V L "sc1" 3 219 "*int8"
V L "sc2" 3 219 "*int8"
C L "strpbrk" 3 19 4 "FUNCTION"
F G "strpbrk" 3 232 "*int8(*int8 s1,*int8 s2)"
V L "s1" 3 232 "*int8"
V L "s2" 3 232 "*int8"
V L "sc1" 3 234 "*int8"
V L "sc2" 3 234 "*int8"
C L "strrchr" 3 19 2 "FUNCTION"
F G "strrchr" 3 247 "*int8(*int8 s,int8 c)"
V L "s" 3 247 "*int8"
V L "c" 3 247 "int8"
V L "p" 3 249 "*int8"
C L "strspn" 3 19 2 "FUNCTION"
F G "strspn" 3 262 "int8(*int8 s1,*int8 s2)"
V L "s1" 3 262 "*int8"
V L "s2" 3 262 "*int8"
V L "sc1" 3 264 "*int8"
V L "sc2" 3 264 "*int8"
C L "strstr" 3 19 6 "FUNCTION"
F G "strstr" 3 281 "*int8(*int8 s1,*int8 s2)"
V L "s1" 3 281 "*int8"
V L "s2" 3 281 "*int8"
V L "s" 3 283 "*int8"
V L "t" 3 283 "*int8"
C L "strtok" 3 19 13 "FUNCTION"
F G "strtok" 3 320 "*int8(*int8 s1,*int8 s2)"
V L "s1" 3 320 "*int8"
V L "s2" 3 320 "*int8"
V L "beg" 3 322 "*int8"
V L "end" 3 322 "*int8"
V L "save" 3 323 "*int8"
C L "strlen" 3 19 6 "FUNCTION"
F G "strlen" 3 369 "int8(*int8 s)"
V L "s" 3 369 "*int8"
V L "sc" 3 371 "*int8"
C L "stricmp" 3 19 2 "FUNCTION"
F G "stricmp" 3 380 "sint8(*int8 s1,*int8 s2)"
V L "s1" 3 380 "*int8"
V L "s2" 3 380 "*int8"
C L "strlwr" 3 19 3 "FUNCTION"
F G "strlwr" 3 394 "*int8(*int8 s)"
V L "s" 3 394 "*int8"
V L "p" 3 396 "*int8"
D G "LED" 0 5 "PIN_E1"
D G "CE" 0 6 "PIN_E2"
D G "SEL0" 0 8 "PIN_E0" "external counter division ratio"
D G "SEL1" 0 9 "PIN_E1" "external counter division ratio"
D G "MR" 0 10 "PIN_E2" "external counter master reset"
D G "CLKI" 0 11 "PIN_C0" "internal counter input"
D G "BEEP" 0 12 "PIN_C3" "buzzer"
V G "count" 0 14 "int32"
V G "buffer" 0 17 "int8[16]" "I2C buffer"
V G "address" 0 18 "int8"
V G "of" 0 20 "int16"
V G "cmd" 0 22 "int8[40]"
F G "ssp_interupt" 0 25 "void()"
V L "incoming" 0 27 "int8"
V L "state" 0 27 "int8"
C L "ssp_interupt" 0 20 1 "FUNCTION"
C L "ssp_interupt" 0 20 1 "FUNCTION"
C L "ssp_interupt" 0 20 1 "FUNCTION"
C L "ssp_interupt" 0 20 1 "FUNCTION"
F G "EXT_isr" 0 58 "void()"
V L "countH" 0 60 "int16"
V L "countL" 0 61 "int8"
V L "countS" 0 62 "int8[10]"
V L "a" 0 62 "int8[4]"
V L "b" 0 62 "int8[4]"
V L "c" 0 62 "int8[4]" "strings for printing results"
C L "EXT_isr" 0 20 1 "FUNCTION"
C L "EXT_isr" 0 20 1 "FUNCTION"
C L "EXT_isr" 0 20 1 "FUNCTION"
C L "EXT_isr" 0 20 1 "FUNCTION"
C L "EXT_isr" 0 20 1 "FUNCTION"
C L "EXT_isr" 0 20 1 "FUNCTION"
C L "EXT_isr" 0 20 1 "FUNCTION"
C L "EXT_isr" 0 20 1 "FUNCTION"
C L "EXT_isr" 0 20 1 "FUNCTION"
C L "EXT_isr" 0 20 1 "FUNCTION"
C L "EXT_isr" 0 20 1 "FUNCTION"
C L "EXT_isr" 0 20 1 "FUNCTION"
F G "TIMER1_isr" 0 99 "void()"
C L "MAIN" 0 20 7 "FUNCTION"
F G "MAIN" 0 115 "void()"
C L "MAIN" 0 20 1 "FUNCTION"
V L "n" 0 129 "int8"
C L "MAIN" 0 20 1 "FUNCTION"
C L "MAIN" 0 20 1 "FUNCTION"
C L "MAIN" 0 20 1 "FUNCTION"
F B "reset_cpu" 0 0
F B "abs" 1 0
F B "sleep_ulpwu" 1 0
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.hex
1,103 → 1,127
:1000000002308A001C2A0000FF00030E8301A100B9
:1000000003308A00322B0000FF00030E8301A100A1
:100010000A08A0008A010408A2007708A300780853
:10002000A4007908A5007A08A600831383128C30F7
:100030008400801C1D288C1834288C308400801D7E
:1000400023288C193728220884002308F700240865
:10005000F8002508F9002608FA0020088A00210E79
:100060008300FF0E7F0E09008A110A12B0288A1140
:100070000A1266280A108A100A118207B5346234FF
:100080000634313420340034003400340034003479
:100090003234003400340034803484341E3400346C
:1000A000E034C83410340034403442340F34003467
:1000B000A034863401340034003400340034003479
:1000C000F734003400340034123403348316941AA5
:1000D00071288312DC018316141D71288312DC172A
:1000E000831683125C08DC0AE80068087F3C031C66
:1000F000952814138C1D7A2813081416E700680B32
:100100008B286708DB006708023C031D8B28290841
:10011000CB002A08CC006808023C031D95284B3010
:100120005B0784008313670880006808803C031D18
:10013000AC284B305B07840083130008E900690892
:10014000EA006A08930014168C1183161418A62866
:10015000F8018312141AF80A8C118A110A12232842
:1001600083160911831209110F08FA000E08F7000F
:100170000F087A02031DB4287708A9007A08AA009C
:100180008F018E0183160911831209158C108A11B3
:100190000A122328633BE1352E17AE060A00E33727
:1001A0007537741DA012CC3AA0125810252CA0123D
:1001B0005810252C0D0500005F30840083130008C3
:1001C0000319EF280630F800F701F70BE528F80BC4
:1001D000E4287B30F700F70BEB28800BE2280800BF
:1001E000831603178C170C140000000083120C08F0
:1001F0007F39031936290313DE0003170D08031393
:10020000DF0003170F080313E0005E080C1E062929
:1002100099005F0803178D000313600803178F0010
:1002200083168C170C140000000083120C0D0E0DA9
:100230007F39031936290313DE0003170D08031352
:10024000DF0003170F080313E0005E080C1E2629C9
:1002500099005F0803178D000313600803178F00D0
:100260008D0A03198F0A0313F028031703138A1149
:100270000A129C2A0330DF02031C48295F308400E5
:10028000831300080319482946294629800B45296C
:100290008A110A12C12A831603178C170C14000046
:1002A000000003187B2983120C087F390313DF0039
:1002B00003170D080313E00003170F080313E100F1
:1002C0005F080C1E61299900600803178D00031355
:1002D000610803178F0083168C170C1400000000B0
:1002E00083120313DE0B75297829831603177B29E4
:1002F0009B298316031783120C0D0E0D7F390313F0
:10030000DF0003170D080313E00003170F080313A2
:10031000E1005F080C1E8A299900600803178D0010
:100320000313610803178F008D0A03198F0A031046
:100330000313DE0B4B298A110A12DD2AE601040899
:10034000E5006610831B66145F0EF038E100E107DC
:10035000E23EE200323EE4005F080F39E207E207C6
:10036000E407E93EE300E307E3075E0E0F39E30726
:10037000E407E30DE40DE409E40D5E080F39E4073A
:10038000E10D0730E0000A30E407E303031CC42951
:10039000E307E203031CC829E207E103031CCC299D
:1003A000E107E003031CD029603084008313073089
:1003B0006505651384076430040203196517000896
:1003C000F700031DEB29651BEB29651AF329E519D5
:1003D000EB292030EE29E51565123030F707770854
:1003E0000C1EF0299900840A651FDB298A110A1264
:1003F000E42ADF1B0C2A0F30F7005E0EF7050A30E7
:1004000077020318062A3030F707082A5F08F70733
:1004100077080C1E092A99000F30DE050A305E02AB
:100420000318142A3030162ADF135F08DE075E082F
:100430000C1E182A99000800840183131F308305BD
:1004400083160317871508300313990002309A00AA
:10045000A6309800903083129800A81528088316BB
:10046000870083122816280883168700A03093007F
:10047000363083129400831603170908C0398900A7
:1004800003131F129F120030031788008312870185
:10049000880189010313A701FF30A8000330DC00A5
:1004A000831603170908C039890003131F129F120E
:1004B000003003178800831203131F1083160108EE
:1004C000C739083881000730831290007830F8006F
:1004D00006389200C430831692008312281528082B
:1004E000831687008312970183169B019C010130BC
:1004F0009D00831203178701880189018316031366
:10050000970104308312DE00FA30DF00DC20DE0BBE
:10051000842ADD015D08273C031C952A5D083A20EA
:100520000C1E902A9900DD0A8A2ACA3003178D0012
:1005300000308F000313F0285530BD00AA30BE00F4
:100540008F018E0183168C15C03083128B048316A5
:1005500089108312891483168910831289108F01E0
:100560008E0183160911831209150930DE006F30E0
:10057000DF00DC20DE0BB72A0630DE00A030DF0013
:100580003A29DE0BBE2A83160911831209110F08BE
:10059000FA000E08F7000F087A02031DC72A770831
:1005A000A9007A08AA00CF3003178D0000308F0011
:1005B000031007300313DE004B29103084002A0893
:1005C000DF002908DE009E2920300C1EE52A990054
:1005D0004B08DE003730DF00F92120300C1EEE2AF8
:1005E00099004C08DE003730DF00F92120300C1E66
:1005F000F72A99004D08DE003730DF00F92120305E
:100600000C1E002B99004E08DE003730DF00F92168
:100610000D300C1E092B99000A300C1E0D2B990071
:04062000A72A6300A2
:10002000A4007908A5007A08A600831383120B1E8A
:100030001B288B1838288C308400001C21280C18B1
:100040003B288C308400801D27288C193E282208EC
:1000500084002308F7002408F8002508F900260882
:10006000FA0020088A00210E8300FF0E7F0E09008F
:100070008A110A1245298A110A12C62A8A110A12FD
:100080006D280A108A100A118207B53462340634CA
:10009000313420340034003400340034003432343D
:1000A000003400340034803484341E340034E034AE
:1000B000C83410340034403442340F340034A03497
:1000C0008634013400340034003400340034F73412
:1000D000003400340034123403348316941A782820
:1000E0008312C2018316141D78288312C217831647
:1000F00083124208C20ACA004A087F3C031CA02897
:1001000014138C1D812813081416C9004A0B962855
:100110004908BF004908023C031D96282B08AF0080
:100120002C08B0002D08B1002E08B2004A08023C8D
:10013000031DA0282F303F07840083134908800047
:100140004A08803C031DB7282F303F0784008313E3
:100150000008CB004B08CC004C08930014168C11FF
:1001600083161418B128F8018312141AF80A8C1196
:100170008A110A122728F701F801F901FA018316FA
:10018000A001A101A201A301750874047304720403
:100190000319FC282030A40003108312EE0DEF0D8C
:1001A000F00DF10D8316A00DA10DA20DA30D750884
:1001B0002302031DE52874082202031DE5287308A5
:1001C0002102031DE52872082002031CF62872088C
:1001D000A0027308031C730FA1027408031C740FA0
:1001E000A2027508031C750FA3020314F70DF80D86
:1001F000F90DFA0DA40BCC28A030840083138312D0
:1002000008006308E8006208E700E60803193029DF
:100210006508FA006408840083137A18831780083D
:10022000031930296808FA006708E70A0319E80A81
:10023000E9007A08EA006508FA006408E40A03198C
:10024000E50A840083137A1883170008EB00690815
:10025000840083136A1883176B088000E60305295E
:10026000E608031940296808FA006708E70A031935
:10027000E80A840083137A1883178001E603302983
:100280006208F8006308F9000800CB010F08FA00C3
:100290000E08F7000F087A02031D46297708C900E7
:1002A0007A08CA0083160910831209108316891070
:1002B0008312891028142808831687008312CB0123
:1002C0000718CB0A831609108312091483168910A4
:1002D000831289102814280883168700003083129F
:1002E00007180130F7000310F70D7708CB048316C9
:1002F0000910831209108316891083128914281497
:100300002808831687000030831207180130F70091
:10031000F70DF70DFC30F7057708CB0483160910AD
:10032000831209148316891083128914281428084B
:10033000831687000030831207180130F700F70D8D
:10034000F70DF70DF830F7057708CB048316091180
:100350008312091183160911831209158F018E0169
:10036000E501E4014108E3004008E2004108E5003E
:100370004008E400E201E301E40DE50DE40DE50DC4
:10038000E40DE50DE40DE50DF030E405EA01E901C9
:10039000490DF7004A0DF800690DF9006A0DFA00E1
:1003A000F70DF80DF90DFA0DF70DF80DF90DFA0D21
:1003B000F70DF80DF90DFA0DF030F7057708E207A3
:1003C00078080318780FE30779080318790FE40712
:1003D0007A0803187A0FE507F801F901FA014B08CA
:1003E0006207AB006308AC0078080318780FAC070D
:1003F0006408AD0079080318790FAD076508AE00F1
:100400007A0803187A0FAE07C4014C30C300493094
:1004100084002E08E5002D08E4002C08E3002B08DA
:10042000E2000408E6003B30ED009A30EC00CA30F0
:10043000EB00EA010A30E8006508F1006408F0000A
:100440006308EF006208EE006D08F5006C08F40028
:100450006B08F3006A08F200BB2078080008E2008D
:10046000840A0008E300840A0008E400840A000803
:10047000E500FD308407F708031D512A6808013A9A
:100480000319512A66080319522A0F396802031901
:100490004B2A0318622AE61B622A661B522A203066
:1004A000532AE6013030F7077708EE00430884004E
:1004B0008313441883176E088000840A8001C30ADE
:1004C0000319C40A6D08F1006C08F0006B08EF0016
:1004D0006A08EE00F501F401F3010A30F200BB20D6
:1004E0007A08ED007908EC007808EB007708EA005C
:1004F000E80B1C2AE3015630E200E5014C30E40031
:100500000330E6000121D901E3015A30E200E501A0
:100510004F30E4000330E6000121DD01E3015E30ED
:10052000E200E5015230E4000330E6000121E10180
:100530004C308400831380080319B12AE3010408B6
:10054000E2006310831B631400080C1EA52A9900A7
:1005500062088400831363188317840A0319850AC9
:100560009B2A0D300C1EB22A99000A300C1EB62AA6
:100570009900A8112808831687000830831287067F
:10058000C101C0018B108A110A122728C00A031961
:10059000C10A0C108A110A122728633BE1352E1775
:1005A000AE060A0047308400831300080319E52AC9
:1005B0000630F800F701F70BDB2AF80BDA2A7B305C
:1005C000F700F70BE12A800BD82A8A110A12B72B01
:1005D000831603178C170C140000000083120C08FC
:1005E0007F3903192E2B0313C60003170D080313BD
:1005F000C70003170F080313C80046080C1EFE2A85
:100600009900470803178D000313480803178F004C
:1006100083168C170C140000000083120C0D0E0DB5
:100620007F3903192E2B0313C60003170D0803137C
:10063000C70003170F080313C80046080C1E1E2B23
:100640009900470803178D000313480803178F000C
:100650008D0A03198F0A0313E82A031703138A115B
:100660000A12CC2B840183131F30830583160317D2
:10067000871508300313990002309A00A6309800BD
:10068000903083129800A8152808831687008312DB
:100690002816280883168700A0309300363083126E
:1006A0009400C101C001831603170908C0398900ED
:1006B00003131F129F120030031788008312870153
:1006C000880189010313A701FF30A800A901AA012D
:1006D0000330C200C301C401831603170908C039DF
:1006E000890003131F129F12003003178800831222
:1006F00003131F109412A812280883168700831270
:1007000028162808831687008312A8112808831644
:100710008700013083129400003083169400010892
:10072000C739083881000730831290007830F8000C
:1007300006389200C43083169200831228152808C8
:10074000831687008312970183169B019C01013059
:100750009D00831203178701880189018316031303
:10076000970104308312C600FA30C700D22AC60BA4
:10077000B42BC5014508273C031CC52B4508412067
:100780000C1EC02B9900C50ABA2BCD3003178D0063
:1007900002308F000313E82A831601170C1483120A
:1007A0000B1683168C15C03083128B04D62B630076
:04400E00F22CFF3F52
:00000001FF
;PIC16F887
;CRC=C1DB CREATED="01-II-14 20:13"
;CRC=9B3A CREATED="04-II-14 11:45"
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.lst
1,17 → 1,17
CCS PCM C Compiler, Version 4.106, 47914 01-II-14 20:13
CCS PCM C Compiler, Version 4.106, 47914 04-II-14 11:45
 
Filename: Z:\home\kaklik\svn\svnMLAB\Designs\Measuring_instruments\RMDS01C\SW\PIC887\main.lst
Filename: Z:\home\kaklik\svn\svnMLAB\Designs\Measuring_instruments\RMDS01C\SW\PIC16F887\main.lst
 
ROM used: 786 words (10%)
ROM used: 984 words (12%)
Largest free fragment is 2048
RAM used: 67 (18%) at main() level
80 (22%) worst case
Stack: 2 worst case (1 in main + 1 for interrupts)
RAM used: 43 (12%) at main() level
96 (26%) worst case
Stack: 3 worst case (1 in main + 2 for interrupts)
 
*
0000: MOVLW 02
0000: MOVLW 03
0001: MOVWF 0A
0002: GOTO 21C
0002: GOTO 332
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
32,41 → 32,48
0014: MOVWF 26
0015: BCF 03.7
0016: BCF 03.5
0017: MOVLW 8C
0018: MOVWF 04
0019: BTFSS 00.1
001A: GOTO 01D
001B: BTFSC 0C.1
001C: GOTO 034
001D: MOVLW 8C
001E: MOVWF 04
001F: BTFSS 00.3
0020: GOTO 023
0021: BTFSC 0C.3
0022: GOTO 037
0023: MOVF 22,W
0024: MOVWF 04
0025: MOVF 23,W
0026: MOVWF 77
0027: MOVF 24,W
0028: MOVWF 78
0029: MOVF 25,W
002A: MOVWF 79
002B: MOVF 26,W
002C: MOVWF 7A
002D: MOVF 20,W
002E: MOVWF 0A
002F: SWAPF 21,W
0030: MOVWF 03
0031: SWAPF 7F,F
0032: SWAPF 7F,W
0033: RETFIE
0034: BCF 0A.3
0035: BCF 0A.4
0036: GOTO 0B0
0037: BCF 0A.3
0038: BCF 0A.4
0039: GOTO 066
0017: BTFSS 0B.4
0018: GOTO 01B
0019: BTFSC 0B.1
001A: GOTO 038
001B: MOVLW 8C
001C: MOVWF 04
001D: BTFSS 00.0
001E: GOTO 021
001F: BTFSC 0C.0
0020: GOTO 03B
0021: MOVLW 8C
0022: MOVWF 04
0023: BTFSS 00.3
0024: GOTO 027
0025: BTFSC 0C.3
0026: GOTO 03E
0027: MOVF 22,W
0028: MOVWF 04
0029: MOVF 23,W
002A: MOVWF 77
002B: MOVF 24,W
002C: MOVWF 78
002D: MOVF 25,W
002E: MOVWF 79
002F: MOVF 26,W
0030: MOVWF 7A
0031: MOVF 20,W
0032: MOVWF 0A
0033: SWAPF 21,W
0034: MOVWF 03
0035: SWAPF 7F,F
0036: SWAPF 7F,W
0037: RETFIE
0038: BCF 0A.3
0039: BCF 0A.4
003A: GOTO 145
003B: BCF 0A.3
003C: BCF 0A.4
003D: GOTO 2C6
003E: BCF 0A.3
003F: BCF 0A.4
0040: GOTO 06D
.................... #include "main.h"
.................... #include <16F887.h>
.................... //////// Standard Header file for the PIC16F887 device ////////////////
91,44 → 98,28
....................
.................... #use delay(clock=20000000)
*
00DC: MOVLW 5F
00DD: MOVWF 04
00DE: BCF 03.7
00DF: MOVF 00,W
00E0: BTFSC 03.2
00E1: GOTO 0EF
00E2: MOVLW 06
00E3: MOVWF 78
00E4: CLRF 77
00E5: DECFSZ 77,F
00E6: GOTO 0E5
00E7: DECFSZ 78,F
00E8: GOTO 0E4
00E9: MOVLW 7B
00EA: MOVWF 77
00EB: DECFSZ 77,F
00EC: GOTO 0EB
00ED: DECFSZ 00,F
00EE: GOTO 0E2
00EF: RETURN
*
013A: MOVLW 03
013B: SUBWF 5F,F
013C: BTFSS 03.0
013D: GOTO 148
013E: MOVLW 5F
013F: MOVWF 04
0140: BCF 03.7
0141: MOVF 00,W
0142: BTFSC 03.2
0143: GOTO 148
0144: GOTO 146
0145: GOTO 146
0146: DECFSZ 00,F
0147: GOTO 145
0148: BCF 0A.3
0149: BCF 0A.4
014A: GOTO 2C1 (RETURN)
02D2: MOVLW 47
02D3: MOVWF 04
02D4: BCF 03.7
02D5: MOVF 00,W
02D6: BTFSC 03.2
02D7: GOTO 2E5
02D8: MOVLW 06
02D9: MOVWF 78
02DA: CLRF 77
02DB: DECFSZ 77,F
02DC: GOTO 2DB
02DD: DECFSZ 78,F
02DE: GOTO 2DA
02DF: MOVLW 7B
02E0: MOVWF 77
02E1: DECFSZ 77,F
02E2: GOTO 2E1
02E3: DECFSZ 00,F
02E4: GOTO 2D8
02E5: BCF 0A.3
02E6: BCF 0A.4
02E7: GOTO 3B7 (RETURN)
.................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,errors)
....................
.................... //NOTE: Must declare MASTER before SLAVE, i2c_isr_state() returns 0
136,32 → 127,576
.................... //#use i2c(MASTER, sda=PIN_C1, scl=PIN_C0, stream=I2CM)
.................... #use i2c(SLAVE, Fast, sda=PIN_C4, scl=PIN_C3, force_hw, address=0xA0)
*
00A1: MOVF 6A,W
00A2: MOVWF 13
00A3: BSF 14.4
00A4: BCF 0C.3
00A5: BSF 03.5
00A6: BTFSC 14.0
00A7: GOTO 0A6
00A8: CLRF 78
00A9: BCF 03.5
00AA: BTFSC 14.4
00AB: INCF 78,F
00AC: MOVF 4C,W
00AD: MOVWF 13
00AE: BSF 14.4
00AF: BCF 0C.3
00B0: BSF 03.5
00B1: BTFSC 14.0
00B2: GOTO 0B1
00B3: CLRF 78
00B4: BCF 03.5
00B5: BTFSC 14.4
00B6: INCF 78,F
....................
....................
....................
.................... #include <string.h>
.................... ////////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996,2008 Custom Computer Services ////
.................... //// This source code may only be used by licensed users of the CCS C ////
.................... //// compiler. This source code may only be distributed to other ////
.................... //// licensed users of the CCS C compiler. No other use, reproduction ////
.................... //// or distribution is permitted without written permission. ////
.................... //// Derivative programs created using this software in object code ////
.................... //// form are not restricted in any way. ////
.................... ////////////////////////////////////////////////////////////////////////////
....................
.................... #ifndef _STRING
.................... #define _STRING
.................... #include <stddef.h>
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996,2003 Custom Computer Services ////
.................... //// This source code may only be used by licensed users of the CCS C ////
.................... //// compiler. This source code may only be distributed to other ////
.................... //// licensed users of the CCS C compiler. No other use, reproduction ////
.................... //// or distribution is permitted without written permission. ////
.................... //// Derivative programs created using this software in object code ////
.................... //// form are not restricted in any way. ////
.................... ///////////////////////////////////////////////////////////////////////////
....................
.................... #ifndef _STDDEF
....................
.................... #define _STDDEF
....................
.................... #if sizeof(unsigned int8 *)==1
.................... #define ptrdiff_t unsigned int8
.................... #else
.................... #define ptrdiff_t unsigned int16
.................... #endif
....................
.................... #define size_t unsigned int8
.................... #define wchar_t char
.................... #define NULL 0
....................
.................... #define offsetof(s,f) (offsetofbit(s,f)/8)
....................
.................... #endif
....................
.................... #include <ctype.h>
.................... ////////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996,2003 Custom Computer Services ////
.................... //// This source code may only be used by licensed users of the CCS C ////
.................... //// compiler. This source code may only be distributed to other ////
.................... //// licensed users of the CCS C compiler. No other use, reproduction ////
.................... //// or distribution is permitted without written permission. ////
.................... //// Derivative programs created using this software in object code ////
.................... //// form are not restricted in any way. ////
.................... ////////////////////////////////////////////////////////////////////////////
....................
.................... #ifndef _CTYPE
.................... #define _CTYPE
....................
.................... #define islower(x) isamong(x,"abcdefghijklmnopqrstuvwxyz")
.................... #define isupper(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZ")
.................... #define isalnum(x) isamong(x,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
.................... #define isalpha(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
.................... #define isdigit(x) isamong(x,"0123456789")
.................... #define isspace(x) ((x)==' ')
.................... #define isxdigit(x) isamong(x,"0123456789ABCDEFabcdef")
.................... #define iscntrl(x) ((x)<' ')
.................... #define isprint(x) ((x)>=' ')
.................... #define isgraph(x) ((x)>' ')
.................... #define ispunct(x) (((x)>' ')&&!isalnum(x))
....................
.................... #endif
....................
....................
....................
....................
....................
.................... //////////////////////////////////////////////
.................... //// Uncomment the following define to ////
.................... //// allow some functions to use a ////
.................... //// quicker algorithm, but use more ROM ////
.................... //// ////
.................... //// #define FASTER_BUT_MORE_ROM ////
.................... //////////////////////////////////////////////
....................
....................
....................
.................... /*Copying functions*/
.................... /* standard template:
.................... void *memmove(void *s1, void *s2, size_t n).
.................... Copies max of n characters safely (not following ending '\0')
.................... from s2 in s1; if s2 has less than n characters, appends 0 */
....................
.................... char *memmove(void *s1,char *s2,size_t n)
.................... {
.................... char *sc1;
.................... char *sc2;
.................... sc1=s1;
.................... sc2=s2;
.................... if(sc2<sc1 && sc1 <sc2 +n)
.................... for(sc1+=n,sc2+=n;0<n;--n)
.................... *--sc1=*--sc2;
.................... else
.................... for(;0<n;--n)
.................... *sc1++=*sc2++;
.................... return s1;
.................... }
....................
.................... /* Standard template: char *strcpy(char *s1, const char *s2)
.................... copies the string s2 including the null character to s1.
.................... This is a compiler built in to handle the different address
.................... spaces */
....................
.................... #define strcopy strcpy
....................
.................... /* standard template:
.................... char *strncpy(char *s1, const char *s2, size_t n).
.................... Copies max of n characters (not following ending '\0')
.................... from s2 in s1; if s2 has less than n characters, appends 0 */
....................
.................... char *strncpy(char *s1, char *s2, size_t n)
.................... {
.................... char *s;
....................
.................... for (s = s1; n > 0 && *s2 != '\0'; n--)
*
0101: MOVF 63,W
0102: MOVWF 68
0103: MOVF 62,W
0104: MOVWF 67
0105: MOVF 66,F
0106: BTFSC 03.2
0107: GOTO 130
0108: MOVF 65,W
0109: MOVWF 7A
010A: MOVF 64,W
010B: MOVWF 04
010C: BCF 03.7
010D: BTFSC 7A.0
010E: BSF 03.7
010F: MOVF 00,F
0110: BTFSC 03.2
0111: GOTO 130
.................... *s++ = *s2++;
0112: MOVF 68,W
0113: MOVWF 7A
0114: MOVF 67,W
0115: INCF 67,F
0116: BTFSC 03.2
0117: INCF 68,F
0118: MOVWF 69
0119: MOVF 7A,W
011A: MOVWF 6A
011B: MOVF 65,W
011C: MOVWF 7A
011D: MOVF 64,W
011E: INCF 64,F
011F: BTFSC 03.2
0120: INCF 65,F
0121: MOVWF 04
0122: BCF 03.7
0123: BTFSC 7A.0
0124: BSF 03.7
0125: MOVF 00,W
0126: MOVWF 6B
0127: MOVF 69,W
0128: MOVWF 04
0129: BCF 03.7
012A: BTFSC 6A.0
012B: BSF 03.7
012C: MOVF 6B,W
012D: MOVWF 00
012E: DECF 66,F
012F: GOTO 105
.................... for (; n > 0; n--)
0130: MOVF 66,F
0131: BTFSC 03.2
0132: GOTO 140
.................... *s++ = '\0';
0133: MOVF 68,W
0134: MOVWF 7A
0135: MOVF 67,W
0136: INCF 67,F
0137: BTFSC 03.2
0138: INCF 68,F
0139: MOVWF 04
013A: BCF 03.7
013B: BTFSC 7A.0
013C: BSF 03.7
013D: CLRF 00
013E: DECF 66,F
013F: GOTO 130
....................
.................... return(s1);
0140: MOVF 62,W
0141: MOVWF 78
0142: MOVF 63,W
0143: MOVWF 79
.................... }
0144: RETURN
.................... /***********************************************************/
....................
.................... /*concatenation functions*/
.................... /* standard template: char *strcat(char *s1, const char *s2)
.................... appends s2 to s1*/
....................
.................... char *strcat(char *s1, char *s2)
.................... {
.................... char *s;
....................
.................... for (s = s1; *s != '\0'; ++s);
.................... while(*s2 != '\0')
.................... {
.................... *s = *s2;
.................... ++s;
.................... ++s2;
.................... }
....................
.................... *s = '\0';
.................... return(s1);
.................... }
.................... /* standard template: char *strncat(char *s1, char *s2,size_t n)
.................... appends not more than n characters from s2 to s1*/
....................
.................... char *strncat(char *s1, char *s2, size_t n)
.................... {
.................... char *s;
....................
.................... for (s = s1; *s != '\0'; ++s);
.................... while(*s2 != '\0' && 0<n)
.................... {
.................... *s = *s2;
.................... ++s;
.................... ++s2;
.................... --n;
.................... }
....................
.................... *s = '\0';
.................... return(s1);
.................... }
....................
.................... /***********************************************************/
....................
....................
.................... /*comparison functions*/
.................... /* standard template: signed int memcmp(void *s1, void *s2).
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
....................
.................... signed int8 memcmp(void * s1,char *s2,size_t n)
.................... {
.................... char *su1, *su2;
.................... for(su1=s1, su2=s2; 0<n; ++su1, ++su2, --n)
.................... {
.................... if(*su1!=*su2)
.................... return ((*su1<*su2)?-1:+1);
.................... }
.................... return 0;
.................... }
....................
.................... /* standard template: int strcmp(const char *s1, const char *s2).
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
....................
.................... signed int8 strcmp(char *s1, char *s2)
.................... {
.................... for (; *s1 == *s2; s1++, s2++)
.................... if (*s1 == '\0')
.................... return(0);
.................... return((*s1 < *s2) ? -1: 1);
.................... }
.................... /* standard template: int strcoll(const char *s1, const char *s2).
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
....................
.................... signed int8 strcoll(char *s1, char *s2)
.................... {
.................... for (; *s1 == *s2; s1++, s2++)
.................... if (*s1 == '\0')
.................... return(0);
.................... return((*s1 < *s2) ? -1: 1);
.................... }
....................
.................... /* standard template:
.................... int strncmp(const char *s1, const char *s2, size_t n).
.................... Compares max of n characters (not following 0) from s1 to s2;
.................... returns same as strcmp */
....................
.................... signed int8 strncmp(char *s1, char *s2, size_t n)
.................... {
.................... for (; n > 0; s1++, s2++, n--)
.................... if (*s1 != *s2)
.................... return((*s1 <*s2) ? -1: 1);
.................... else if (*s1 == '\0')
.................... return(0);
.................... return(0);
.................... }
.................... /* standard template:
.................... int strxfrm(const char *s1, const char *s2, size_t n).
.................... transforms maximum of n characters from s2 and places them into s1*/
.................... size_t strxfrm(char *s1, char *s2, size_t n)
.................... {
.................... char *s;
.................... unsigned int8 n1;
.................... n1=n;
.................... for (s = s1; n > 0 && *s2 != '\0'; n--)
.................... *s++ = *s2++;
.................... for (; n > 0; n--)
.................... *s++ = '\0';
....................
.................... return(n1);
.................... }
....................
....................
....................
....................
....................
.................... /***********************************************************/
.................... /*Search functions*/
.................... /* standard template: void *memchr(const char *s, int c).
.................... Finds first occurrence of c in n characters of s */
....................
.................... char *memchr(void *s,unsigned int8 c,size_t n)
.................... {
.................... char uc;
.................... char *su;
.................... uc=c;
.................... for(su=s;0<n;++su,--n)
.................... if(*su==uc)
.................... return su;
.................... return NULL;
.................... }
....................
.................... /* standard template: char *strchr(const char *s, int c).
.................... Finds first occurrence of c in s */
....................
.................... char *strchr(char *s, unsigned int8 c)
.................... {
.................... for (; *s != c; s++)
.................... if (*s == '\0')
.................... return(0);
.................... return(s);
.................... }
.................... /* standard template:
.................... size_t strcspn(const char *s1, const char *s2).
.................... Computes length of max initial segment of s1 that
.................... consists entirely of characters NOT from s2*/
....................
.................... unsigned int8 strcspn(char *s1, char *s2)
.................... {
.................... char *sc1, *sc2;
....................
.................... for (sc1 = s1; *sc1 != 0; sc1++)
.................... for (sc2 = s2; *sc2 != 0; sc2++)
.................... if (*sc1 == *sc2)
.................... return(sc1 - s1);
.................... return(sc1 - s1);
.................... }
.................... /* standard template:
.................... char *strpbrk(const char *s1, const char *s2).
.................... Locates first occurence of any character from s2 in s1;
.................... returns s1 if s2 is empty string */
....................
.................... char *strpbrk(char *s1, char *s2)
.................... {
.................... char *sc1, *sc2;
....................
.................... for (sc1 = s1; *sc1 != 0; sc1++)
.................... for (sc2 = s2; *sc2 != 0; sc2++)
.................... if (*sc1 == *sc2)
.................... return(sc1);
.................... return(0);
.................... }
....................
....................
.................... /* standard template: char *strrchr(const char *s, int c).
.................... Finds last occurrence of c in s */
....................
.................... char *strrchr(char *s, unsigned int8 c)
.................... {
.................... char *p;
....................
.................... for (p = 0; ; s++)
.................... {
.................... if (*s == c)
.................... p = s;
.................... if (*s == '\0')
.................... return(p);
.................... }
.................... }
.................... /* computes length of max initial segment of s1 consisting
.................... entirely of characters from s2 */
....................
.................... unsigned int8 strspn(char *s1, char *s2)
.................... {
.................... char *sc1, *sc2;
....................
.................... for (sc1 = s1; *sc1 != 0; sc1++)
.................... for (sc2 = s2; ; sc2++)
.................... if (*sc2 == '\0')
.................... return(sc1 - s1);
.................... else if (*sc1 == *sc2)
.................... break;
.................... return(sc1 - s1);
.................... }
.................... /* standard template:
.................... char *strstr(const char *s1, const char *s2);
.................... Locates first occurence of character sequence s2 in s1;
.................... returns 0 if s2 is empty string
....................
.................... Uncomment #define FASTER_BUT_MORE_ROM at the top of the
.................... file to use the faster algorithm */
.................... char *strstr(char *s1, char *s2)
.................... {
.................... char *s, *t;
....................
.................... #ifdef FASTER_BUT_MORE_ROM
.................... if (*s2 == '\0')
.................... return(s1);
.................... #endif
....................
.................... while (*s1)
.................... {
.................... for(s = s1, t = s2; *t && (*s == *t); ++s, ++t);
....................
.................... if (*t == '\0')
.................... return s1;
.................... ++s1;
.................... #ifdef FASTER_BUT_MORE_ROM
.................... while(*s1 != '\0' && *s1 != *s2)
.................... ++s1;
.................... #endif
.................... }
.................... return 0;
.................... }
....................
.................... /* standard template: char *strtok(char *s1, const char *s2).
....................
.................... Finds next token in s1 delimited by a character from separator
.................... string s2 (which can be different from call to call). First call
.................... starts at beginning of s1 searching for first character NOT
.................... contained in s2; returns 0 if none is found.
.................... If one is found, it is the start of first token (return value).
.................... Function then searches from there for a character contained in s2.
.................... If none is found, current token extends to end of s1, and subsequent
.................... searches for a token will return 0. If one is found, it is
.................... overwritten by '\0', which terminates current token. Function saves
.................... pointer to following character from which next search will start.
.................... Each subsequent call, with 0 as first argument, starts searching
.................... from saved pointer */
....................
.................... char *strtok(char *s1, char *s2)
.................... {
.................... char *beg, *end;
.................... static char *save;
*
0366: CLRF 29
0367: CLRF 2A
....................
.................... beg = (s1)? s1: save;
.................... beg += strspn(beg, s2);
.................... if (*beg == '\0')
.................... {
.................... *save = ' ';
.................... return(0);
.................... }
.................... end = strpbrk(beg, s2);
.................... if (*end != '\0')
.................... {
.................... *end = '\0';
.................... end++;
.................... }
.................... save = end;
.................... return(beg);
.................... }
....................
.................... /*****************************************************************/
.................... /*Miscellaneous functions*/
.................... /* standard template
.................... maps error number in errnum to an error message string
.................... Returns: Pointer to string
.................... */
.................... #ifdef _ERRNO
.................... char * strerror(unsigned int8 errnum)
.................... {
.................... char s[15];
.................... switch( errnum)
.................... {
.................... case 0:
.................... strcpy(s,"no errors");
.................... return s;
.................... case EDOM :
.................... strcpy(s,"domain error");
.................... return s;
.................... case ERANGE:
.................... strcpy(s,"range error");
.................... return s;
.................... }
.................... }
.................... #ENDIF
.................... /* standard template: size_t strlen(const char *s).
.................... Computes length of s1 (preceding terminating 0) */
....................
.................... unsigned int8 strlen(char *s)
.................... {
.................... char *sc;
....................
.................... for (sc = s; *sc != 0; sc++);
.................... return(sc - s);
.................... }
....................
.................... /* standard template: size_t stricmp(const char *s1, const char *s2).
.................... Compares s1 to s2 ignoring case (upper vs. lower) */
....................
.................... signed int8 stricmp(char *s1, char *s2)
.................... {
.................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32));
.................... s1++, s2++)
.................... if (*s1 == '\0')
.................... return(0);
.................... return((*s1 < *s2) ? -1: 1);
.................... }
....................
....................
.................... /* standard template: char *strlwr(char *s).
.................... Replaces uppercase letters by lowercase;
.................... returns pointer to new string s */
....................
.................... char *strlwr(char *s)
.................... {
.................... char *p;
....................
.................... for (p = s; *p != '\0'; p++)
.................... if (*p >= 'A' && *p <='Z')
.................... *p += 'a' - 'A';
.................... return(s);
.................... }
....................
....................
.................... /************************************************************/
....................
....................
.................... #endif
....................
....................
.................... #define LED PIN_E1
.................... #define CE PIN_E2
....................
.................... int16 count;
.................... #define SEL0 PIN_E0 // external counter division ratio
.................... #define SEL1 PIN_E1 // external counter division ratio
.................... #define MR PIN_E2 // external counter master reset
.................... #define CLKI PIN_C0 // internal counter input
.................... #define BEEP PIN_C3 // buzzer
....................
.................... int8 rcv_buf[0x10]; // I2C receive buffer
.................... int8 snd_buf[0x10]; // I2C send buffer
.................... unsigned int32 count;
....................
....................
.................... int8 buffer[0x10]; // I2C buffer
.................... int8 address;
....................
.................... unsigned int16 of=0; // count of overflow
....................
.................... const char cmd[40]={0xB5, 0x62, 0x06, 0x31, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x80, 0x84, 0x1E, 0x00, 0xE0, 0xC8, 0x10, 0x00, 0x40, 0x42, 0x0F, 0x00, 0xA0, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7, 0x00, 0x00, 0x00, 0x12, 0x03};
....................
.................... #INT_SSP
171,417 → 706,621
....................
.................... state = i2c_isr_state();
*
0066: BSF 03.5
0067: BTFSC 14.5
0068: GOTO 071
0069: BCF 03.5
006A: CLRF 5C
006B: BSF 03.5
006C: BTFSS 14.2
006D: GOTO 071
006E: BCF 03.5
006F: BSF 5C.7
0070: BSF 03.5
0071: BCF 03.5
0072: MOVF 5C,W
0073: INCF 5C,F
0074: MOVWF 68
006D: BSF 03.5
006E: BTFSC 14.5
006F: GOTO 078
0070: BCF 03.5
0071: CLRF 42
0072: BSF 03.5
0073: BTFSS 14.2
0074: GOTO 078
0075: BCF 03.5
0076: BSF 42.7
0077: BSF 03.5
0078: BCF 03.5
0079: MOVF 42,W
007A: INCF 42,F
007B: MOVWF 4A
....................
.................... if(state < 0x80) //Master is sending data
0075: MOVF 68,W
0076: SUBLW 7F
0077: BTFSS 03.0
0078: GOTO 095
007C: MOVF 4A,W
007D: SUBLW 7F
007E: BTFSS 03.0
007F: GOTO 0A0
.................... {
.................... incoming = i2c_read();
0079: BCF 14.6
007A: BTFSS 0C.3
007B: GOTO 07A
007C: MOVF 13,W
007D: BSF 14.4
007E: MOVWF 67
0080: BCF 14.6
0081: BTFSS 0C.3
0082: GOTO 081
0083: MOVF 13,W
0084: BSF 14.4
0085: MOVWF 49
.................... if(state == 1) //First received byte is address
007F: DECFSZ 68,W
0080: GOTO 08B
0086: DECFSZ 4A,W
0087: GOTO 096
.................... {
.................... address = incoming;
0081: MOVF 67,W
0082: MOVWF 5B
0088: MOVF 49,W
0089: MOVWF 3F
.................... if (incoming == 2)
0083: MOVF 67,W
0084: SUBLW 02
0085: BTFSS 03.2
0086: GOTO 08B
008A: MOVF 49,W
008B: SUBLW 02
008C: BTFSS 03.2
008D: GOTO 096
.................... {
.................... buffer[0]=make8(count,0);
0087: MOVF 29,W
0088: MOVWF 4B
008E: MOVF 2B,W
008F: MOVWF 2F
.................... buffer[1]=make8(count,1);
0089: MOVF 2A,W
008A: MOVWF 4C
0090: MOVF 2C,W
0091: MOVWF 30
.................... buffer[2]=make8(count,2);
0092: MOVF 2D,W
0093: MOVWF 31
.................... buffer[3]=make8(count,3);
0094: MOVF 2E,W
0095: MOVWF 32
.................... }
.................... }
.................... if(state == 2) //Second received byte is data
008B: MOVF 68,W
008C: SUBLW 02
008D: BTFSS 03.2
008E: GOTO 095
0096: MOVF 4A,W
0097: SUBLW 02
0098: BTFSS 03.2
0099: GOTO 0A0
.................... buffer[address] = incoming;
008F: MOVLW 4B
0090: ADDWF 5B,W
0091: MOVWF 04
0092: BCF 03.7
0093: MOVF 67,W
0094: MOVWF 00
009A: MOVLW 2F
009B: ADDWF 3F,W
009C: MOVWF 04
009D: BCF 03.7
009E: MOVF 49,W
009F: MOVWF 00
....................
....................
.................... }
.................... if(state == 0x80) //Master is requesting data
0095: MOVF 68,W
0096: SUBLW 80
0097: BTFSS 03.2
0098: GOTO 0AC
00A0: MOVF 4A,W
00A1: SUBLW 80
00A2: BTFSS 03.2
00A3: GOTO 0B7
.................... {
.................... i2c_write(buffer[address]);
0099: MOVLW 4B
009A: ADDWF 5B,W
009B: MOVWF 04
009C: BCF 03.7
009D: MOVF 00,W
009E: MOVWF 69
009F: MOVF 69,W
00A0: MOVWF 6A
00A4: MOVLW 2F
00A5: ADDWF 3F,W
00A6: MOVWF 04
00A7: BCF 03.7
00A8: MOVF 00,W
00A9: MOVWF 4B
00AA: MOVF 4B,W
00AB: MOVWF 4C
.................... }
.................... }
....................
....................
*
00AC: BCF 0C.3
00AD: BCF 0A.3
00AE: BCF 0A.4
00AF: GOTO 023
.................... #int_TIMER2 // every 10 ms
00B7: BCF 0C.3
00B8: BCF 0A.3
00B9: BCF 0A.4
00BA: GOTO 027
.................... #int_EXT // Interrupt from 1PPS
.................... void EXT_isr(void)
.................... {
.................... unsigned int16 countH;
.................... unsigned int8 countL;
.................... char countS[10], a[4], b[4], c[4]; // strings for printing results
....................
.................... countL=0;
*
0145: CLRF 4B
.................... countH=get_timer1(); // read internal counter
0146: MOVF 0F,W
0147: MOVWF 7A
0148: MOVF 0E,W
0149: MOVWF 77
014A: MOVF 0F,W
014B: SUBWF 7A,W
014C: BTFSS 03.2
014D: GOTO 146
014E: MOVF 77,W
014F: MOVWF 49
0150: MOVF 7A,W
0151: MOVWF 4A
.................... output_low(SEL0);
0152: BSF 03.5
0153: BCF 09.0
0154: BCF 03.5
0155: BCF 09.0
.................... output_low(SEL1);
0156: BSF 03.5
0157: BCF 09.1
0158: BCF 03.5
0159: BCF 09.1
.................... countL=input(CLKI); // read bit 0 of external counter
015A: BSF 28.0
015B: MOVF 28,W
015C: BSF 03.5
015D: MOVWF 07
015E: BCF 03.5
015F: CLRF 4B
0160: BTFSC 07.0
0161: INCF 4B,F
.................... output_high(SEL0);
0162: BSF 03.5
0163: BCF 09.0
0164: BCF 03.5
0165: BSF 09.0
.................... output_low(SEL1);
0166: BSF 03.5
0167: BCF 09.1
0168: BCF 03.5
0169: BCF 09.1
.................... countL|=input(CLKI)<<1; // read bit 1 of external counter
016A: BSF 28.0
016B: MOVF 28,W
016C: BSF 03.5
016D: MOVWF 07
016E: MOVLW 00
016F: BCF 03.5
0170: BTFSC 07.0
0171: MOVLW 01
0172: MOVWF 77
0173: BCF 03.0
0174: RLF 77,F
0175: MOVF 77,W
0176: IORWF 4B,F
.................... output_low(SEL0);
0177: BSF 03.5
0178: BCF 09.0
0179: BCF 03.5
017A: BCF 09.0
.................... output_high(SEL1);
017B: BSF 03.5
017C: BCF 09.1
017D: BCF 03.5
017E: BSF 09.1
.................... countL|=input(CLKI)<<2; // read bit 2 of external counter
017F: BSF 28.0
0180: MOVF 28,W
0181: BSF 03.5
0182: MOVWF 07
0183: MOVLW 00
0184: BCF 03.5
0185: BTFSC 07.0
0186: MOVLW 01
0187: MOVWF 77
0188: RLF 77,F
0189: RLF 77,F
018A: MOVLW FC
018B: ANDWF 77,F
018C: MOVF 77,W
018D: IORWF 4B,F
.................... output_high(SEL0);
018E: BSF 03.5
018F: BCF 09.0
0190: BCF 03.5
0191: BSF 09.0
.................... output_high(SEL1);
0192: BSF 03.5
0193: BCF 09.1
0194: BCF 03.5
0195: BSF 09.1
.................... countL|=input(CLKI)<<3; // read bit 3 of external counter
0196: BSF 28.0
0197: MOVF 28,W
0198: BSF 03.5
0199: MOVWF 07
019A: MOVLW 00
019B: BCF 03.5
019C: BTFSC 07.0
019D: MOVLW 01
019E: MOVWF 77
019F: RLF 77,F
01A0: RLF 77,F
01A1: RLF 77,F
01A2: MOVLW F8
01A3: ANDWF 77,F
01A4: MOVF 77,W
01A5: IORWF 4B,F
....................
.................... output_low(MR); // External counter Master Reset
01A6: BSF 03.5
01A7: BCF 09.2
01A8: BCF 03.5
01A9: BCF 09.2
.................... output_high(MR);
01AA: BSF 03.5
01AB: BCF 09.2
01AC: BCF 03.5
01AD: BSF 09.2
....................
.................... set_timer1(0); // Internal counter reset
01AE: CLRF 0F
01AF: CLRF 0E
....................
.................... count=((unsigned int32)of<<20)+((unsigned int32)countH<<4)+(unsigned int32)countL; // concatenate
01B0: CLRF 65
01B1: CLRF 64
01B2: MOVF 41,W
01B3: MOVWF 63
01B4: MOVF 40,W
01B5: MOVWF 62
01B6: MOVF 41,W
01B7: MOVWF 65
01B8: MOVF 40,W
01B9: MOVWF 64
01BA: CLRF 62
01BB: CLRF 63
01BC: RLF 64,F
01BD: RLF 65,F
01BE: RLF 64,F
01BF: RLF 65,F
01C0: RLF 64,F
01C1: RLF 65,F
01C2: RLF 64,F
01C3: RLF 65,F
01C4: MOVLW F0
01C5: ANDWF 64,F
01C6: CLRF 6A
01C7: CLRF 69
01C8: RLF 49,W
01C9: MOVWF 77
01CA: RLF 4A,W
01CB: MOVWF 78
01CC: RLF 69,W
01CD: MOVWF 79
01CE: RLF 6A,W
01CF: MOVWF 7A
01D0: RLF 77,F
01D1: RLF 78,F
01D2: RLF 79,F
01D3: RLF 7A,F
01D4: RLF 77,F
01D5: RLF 78,F
01D6: RLF 79,F
01D7: RLF 7A,F
01D8: RLF 77,F
01D9: RLF 78,F
01DA: RLF 79,F
01DB: RLF 7A,F
01DC: MOVLW F0
01DD: ANDWF 77,F
01DE: MOVF 77,W
01DF: ADDWF 62,F
01E0: MOVF 78,W
01E1: BTFSC 03.0
01E2: INCFSZ 78,W
01E3: ADDWF 63,F
01E4: MOVF 79,W
01E5: BTFSC 03.0
01E6: INCFSZ 79,W
01E7: ADDWF 64,F
01E8: MOVF 7A,W
01E9: BTFSC 03.0
01EA: INCFSZ 7A,W
01EB: ADDWF 65,F
01EC: CLRF 78
01ED: CLRF 79
01EE: CLRF 7A
01EF: MOVF 4B,W
01F0: ADDWF 62,W
01F1: MOVWF 2B
01F2: MOVF 63,W
01F3: MOVWF 2C
01F4: MOVF 78,W
01F5: BTFSC 03.0
01F6: INCFSZ 78,W
01F7: ADDWF 2C,F
01F8: MOVF 64,W
01F9: MOVWF 2D
01FA: MOVF 79,W
01FB: BTFSC 03.0
01FC: INCFSZ 79,W
01FD: ADDWF 2D,F
01FE: MOVF 65,W
01FF: MOVWF 2E
0200: MOVF 7A,W
0201: BTFSC 03.0
0202: INCFSZ 7A,W
0203: ADDWF 2E,F
....................
.................... sprintf(countS,"%09Lu", count); // engeneering values conversion
0204: CLRF 44
0205: MOVLW 4C
0206: MOVWF 43
0207: MOVLW 49
0208: MOVWF 04
0209: MOVF 2E,W
020A: MOVWF 65
020B: MOVF 2D,W
020C: MOVWF 64
020D: MOVF 2C,W
020E: MOVWF 63
020F: MOVF 2B,W
0210: MOVWF 62
.................... strncpy(a, countS, 3); a[3]='\0';
*
027A: CLRF 63
027B: MOVLW 56
027C: MOVWF 62
027D: CLRF 65
027E: MOVLW 4C
027F: MOVWF 64
0280: MOVLW 03
0281: MOVWF 66
0282: CALL 101
0283: CLRF 59
.................... strncpy(b, &countS[3], 3); b[3]='\0';
0284: CLRF 63
0285: MOVLW 5A
0286: MOVWF 62
0287: CLRF 65
0288: MOVLW 4F
0289: MOVWF 64
028A: MOVLW 03
028B: MOVWF 66
028C: CALL 101
028D: CLRF 5D
.................... strncpy(c, &countS[6], 3); c[3]='\0';
028E: CLRF 63
028F: MOVLW 5E
0290: MOVWF 62
0291: CLRF 65
0292: MOVLW 52
0293: MOVWF 64
0294: MOVLW 03
0295: MOVWF 66
0296: CALL 101
0297: CLRF 61
....................
.................... printf("%s\r\n", countS); // output to RS232
0298: MOVLW 4C
0299: MOVWF 04
029A: BCF 03.7
*
02B1: MOVLW 0D
02B2: BTFSS 0C.4
02B3: GOTO 2B2
02B4: MOVWF 19
02B5: MOVLW 0A
02B6: BTFSS 0C.4
02B7: GOTO 2B6
02B8: MOVWF 19
....................
.................... output_toggle(BEEP); // cvak...
02B9: BCF 28.3
02BA: MOVF 28,W
02BB: BSF 03.5
02BC: MOVWF 07
02BD: MOVLW 08
02BE: BCF 03.5
02BF: XORWF 07,F
....................
.................... of=0; // reset overflow counter
02C0: CLRF 41
02C1: CLRF 40
.................... }
....................
02C2: BCF 0B.1
02C3: BCF 0A.3
02C4: BCF 0A.4
02C5: GOTO 027
.................... #int_TIMER1 // Interrupf from overflow
.................... void TIMER1_isr(void)
.................... {
.................... of++;
02C6: INCF 40,F
02C7: BTFSC 03.2
02C8: INCF 41,F
.................... }
....................
....................
.................... /*#int_TIMER2 // every 10 ms
.................... void TIMER2_isr(void)
.................... {
.................... output_low(CE);
00B0: BSF 03.5
00B1: BCF 09.2
00B2: BCF 03.5
00B3: BCF 09.2
.................... count=get_timer1();
00B4: MOVF 0F,W
00B5: MOVWF 7A
00B6: MOVF 0E,W
00B7: MOVWF 77
00B8: MOVF 0F,W
00B9: SUBWF 7A,W
00BA: BTFSS 03.2
00BB: GOTO 0B4
00BC: MOVF 77,W
00BD: MOVWF 29
00BE: MOVF 7A,W
00BF: MOVWF 2A
.................... set_timer1(0);
00C0: CLRF 0F
00C1: CLRF 0E
.................... output_high(CE);
00C2: BSF 03.5
00C3: BCF 09.2
00C4: BCF 03.5
00C5: BSF 09.2
.................... }
.................... }*/
....................
....................
00C6: BCF 0C.1
00C7: BCF 0A.3
00C8: BCF 0A.4
00C9: GOTO 023
02C9: BCF 0C.0
02CA: BCF 0A.3
02CB: BCF 0A.4
02CC: GOTO 027
.................... void main()
.................... {
*
021C: CLRF 04
021D: BCF 03.7
021E: MOVLW 1F
021F: ANDWF 03,F
0220: BSF 03.5
0221: BSF 03.6
0222: BSF 07.3
0223: MOVLW 08
0224: BCF 03.6
0225: MOVWF 19
0226: MOVLW 02
0227: MOVWF 1A
0228: MOVLW A6
0229: MOVWF 18
022A: MOVLW 90
022B: BCF 03.5
022C: MOVWF 18
022D: BSF 28.3
022E: MOVF 28,W
022F: BSF 03.5
0230: MOVWF 07
0231: BCF 03.5
0232: BSF 28.4
0233: MOVF 28,W
0234: BSF 03.5
0235: MOVWF 07
0236: MOVLW A0
0237: MOVWF 13
0238: MOVLW 36
0239: BCF 03.5
023A: MOVWF 14
023B: BSF 03.5
023C: BSF 03.6
023D: MOVF 09,W
023E: ANDLW C0
023F: MOVWF 09
0240: BCF 03.6
0241: BCF 1F.4
0242: BCF 1F.5
0243: MOVLW 00
0244: BSF 03.6
0245: MOVWF 08
0246: BCF 03.5
0247: CLRF 07
0248: CLRF 08
0249: CLRF 09
0332: CLRF 04
0333: BCF 03.7
0334: MOVLW 1F
0335: ANDWF 03,F
0336: BSF 03.5
0337: BSF 03.6
0338: BSF 07.3
0339: MOVLW 08
033A: BCF 03.6
033B: MOVWF 19
033C: MOVLW 02
033D: MOVWF 1A
033E: MOVLW A6
033F: MOVWF 18
0340: MOVLW 90
0341: BCF 03.5
0342: MOVWF 18
0343: BSF 28.3
0344: MOVF 28,W
0345: BSF 03.5
0346: MOVWF 07
0347: BCF 03.5
0348: BSF 28.4
0349: MOVF 28,W
034A: BSF 03.5
034B: MOVWF 07
034C: MOVLW A0
034D: MOVWF 13
034E: MOVLW 36
034F: BCF 03.5
0350: MOVWF 14
0351: CLRF 41
0352: CLRF 40
0353: BSF 03.5
0354: BSF 03.6
0355: MOVF 09,W
0356: ANDLW C0
0357: MOVWF 09
0358: BCF 03.6
0359: BCF 1F.4
035A: BCF 1F.5
035B: MOVLW 00
035C: BSF 03.6
035D: MOVWF 08
035E: BCF 03.5
035F: CLRF 07
0360: CLRF 08
0361: CLRF 09
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
*
0250: BSF 03.5
0251: BSF 03.6
0252: MOVF 09,W
0253: ANDLW C0
0254: MOVWF 09
0255: BCF 03.6
0256: BCF 1F.4
0257: BCF 1F.5
0258: MOVLW 00
0259: BSF 03.6
025A: MOVWF 08
036C: BSF 03.5
036D: BSF 03.6
036E: MOVF 09,W
036F: ANDLW C0
0370: MOVWF 09
0371: BCF 03.6
0372: BCF 1F.4
0373: BCF 1F.5
0374: MOVLW 00
0375: BSF 03.6
0376: MOVWF 08
.................... setup_adc(ADC_OFF);
025B: BCF 03.5
025C: BCF 03.6
025D: BCF 1F.0
.................... // setup_spi(SPI_SS_DISABLED);
0377: BCF 03.5
0378: BCF 03.6
0379: BCF 1F.0
.................... setup_spi(SPI_SS_DISABLED);
037A: BCF 14.5
037B: BCF 28.5
037C: MOVF 28,W
037D: BSF 03.5
037E: MOVWF 07
037F: BCF 03.5
0380: BSF 28.4
0381: MOVF 28,W
0382: BSF 03.5
0383: MOVWF 07
0384: BCF 03.5
0385: BCF 28.3
0386: MOVF 28,W
0387: BSF 03.5
0388: MOVWF 07
0389: MOVLW 01
038A: BCF 03.5
038B: MOVWF 14
038C: MOVLW 00
038D: BSF 03.5
038E: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
025E: BSF 03.5
025F: MOVF 01,W
0260: ANDLW C7
0261: IORLW 08
0262: MOVWF 01
038F: MOVF 01,W
0390: ANDLW C7
0391: IORLW 08
0392: MOVWF 01
.................... // setup_wdt(WDT_144MS);
.................... setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);
0263: MOVLW 07
0264: BCF 03.5
0265: MOVWF 10
0393: MOVLW 07
0394: BCF 03.5
0395: MOVWF 10
.................... setup_timer_2(T2_DIV_BY_16,196,16);
0266: MOVLW 78
0267: MOVWF 78
0268: IORLW 06
0269: MOVWF 12
026A: MOVLW C4
026B: BSF 03.5
026C: MOVWF 12
0396: MOVLW 78
0397: MOVWF 78
0398: IORLW 06
0399: MOVWF 12
039A: MOVLW C4
039B: BSF 03.5
039C: MOVWF 12
.................... setup_ccp1(CCP_OFF);
026D: BCF 03.5
026E: BSF 28.2
026F: MOVF 28,W
0270: BSF 03.5
0271: MOVWF 07
0272: BCF 03.5
0273: CLRF 17
0274: BSF 03.5
0275: CLRF 1B
0276: CLRF 1C
0277: MOVLW 01
0278: MOVWF 1D
039D: BCF 03.5
039E: BSF 28.2
039F: MOVF 28,W
03A0: BSF 03.5
03A1: MOVWF 07
03A2: BCF 03.5
03A3: CLRF 17
03A4: BSF 03.5
03A5: CLRF 1B
03A6: CLRF 1C
03A7: MOVLW 01
03A8: MOVWF 1D
.................... setup_comparator(NC_NC_NC_NC);
0279: BCF 03.5
027A: BSF 03.6
027B: CLRF 07
027C: CLRF 08
027D: CLRF 09
03A9: BCF 03.5
03AA: BSF 03.6
03AB: CLRF 07
03AC: CLRF 08
03AD: CLRF 09
.................... setup_vref(FALSE);
027E: BSF 03.5
027F: BCF 03.6
0280: CLRF 17
03AE: BSF 03.5
03AF: BCF 03.6
03B0: CLRF 17
....................
.................... delay_ms(1000);
0281: MOVLW 04
0282: BCF 03.5
0283: MOVWF 5E
0284: MOVLW FA
0285: MOVWF 5F
0286: CALL 0DC
0287: DECFSZ 5E,F
0288: GOTO 284
03B1: MOVLW 04
03B2: BCF 03.5
03B3: MOVWF 46
03B4: MOVLW FA
03B5: MOVWF 47
03B6: GOTO 2D2
03B7: DECFSZ 46,F
03B8: GOTO 3B4
.................... int n;
.................... for (n=0;n<40;n++)
0289: CLRF 5D
028A: MOVF 5D,W
028B: SUBLW 27
028C: BTFSS 03.0
028D: GOTO 295
.................... {
.................... putc(cmd[n]);
028E: MOVF 5D,W
028F: CALL 03A
0290: BTFSS 0C.4
0291: GOTO 290
0292: MOVWF 19
.................... }
0293: INCF 5D,F
0294: GOTO 28A
.................... for (n=0;n<40;n++) putc(cmd[n]); // setup GPS
03B9: CLRF 45
03BA: MOVF 45,W
03BB: SUBLW 27
03BC: BTFSS 03.0
03BD: GOTO 3C5
03BE: MOVF 45,W
03BF: CALL 041
03C0: BTFSS 0C.4
03C1: GOTO 3C0
03C2: MOVWF 19
03C3: INCF 45,F
03C4: GOTO 3BA
....................
.................... printf("cvak...\r\n");
0295: MOVLW CA
0296: BSF 03.6
0297: MOVWF 0D
0298: MOVLW 00
0299: MOVWF 0F
029A: BCF 03.6
029B: GOTO 0F0
.................... snd_buf[2]=0x55;
029C: MOVLW 55
029D: MOVWF 3D
.................... snd_buf[3]=0xAA;
029E: MOVLW AA
029F: MOVWF 3E
03C5: MOVLW CD
03C6: BSF 03.6
03C7: MOVWF 0D
03C8: MOVLW 02
03C9: MOVWF 0F
03CA: BCF 03.6
03CB: GOTO 2E8
....................
.................... set_timer1(0);
02A0: CLRF 0F
02A1: CLRF 0E
.................... ext_int_edge( L_TO_H ); // set 1PPS active edge
03CC: BSF 03.5
03CD: BSF 01.6
.................... enable_interrupts(INT_TIMER1);
03CE: BSF 0C.0
.................... enable_interrupts(INT_EXT);
03CF: BCF 03.5
03D0: BSF 0B.4
.................... enable_interrupts(INT_SSP);
02A2: BSF 03.5
02A3: BSF 0C.3
03D1: BSF 03.5
03D2: BSF 0C.3
.................... // enable_interrupts(INT_TIMER2);
.................... enable_interrupts(GLOBAL);
02A4: MOVLW C0
02A5: BCF 03.5
02A6: IORWF 0B,F
03D3: MOVLW C0
03D4: BCF 03.5
03D5: IORWF 0B,F
....................
.................... while(true)
.................... {
....................
.................... output_high(LED);
02A7: BSF 03.5
02A8: BCF 09.1
02A9: BCF 03.5
02AA: BSF 09.1
.................... output_low(LED);
02AB: BSF 03.5
02AC: BCF 09.1
02AD: BCF 03.5
02AE: BCF 09.1
.................... set_timer1(0);
02AF: CLRF 0F
02B0: CLRF 0E
.................... output_high(CE);
02B1: BSF 03.5
02B2: BCF 09.2
02B3: BCF 03.5
02B4: BSF 09.2
.................... delay_ms(999);
02B5: MOVLW 09
02B6: MOVWF 5E
02B7: MOVLW 6F
02B8: MOVWF 5F
02B9: CALL 0DC
02BA: DECFSZ 5E,F
02BB: GOTO 2B7
.................... delay_us(966);
02BC: MOVLW 06
02BD: MOVWF 5E
02BE: MOVLW A0
02BF: MOVWF 5F
02C0: GOTO 13A
02C1: DECFSZ 5E,F
02C2: GOTO 2BE
.................... output_low(CE);
02C3: BSF 03.5
02C4: BCF 09.2
02C5: BCF 03.5
02C6: BCF 09.2
.................... count=get_timer1();
02C7: MOVF 0F,W
02C8: MOVWF 7A
02C9: MOVF 0E,W
02CA: MOVWF 77
02CB: MOVF 0F,W
02CC: SUBWF 7A,W
02CD: BTFSS 03.2
02CE: GOTO 2C7
02CF: MOVF 77,W
02D0: MOVWF 29
02D1: MOVF 7A,W
02D2: MOVWF 2A
....................
.................... printf("count: %Lu %X %X %X %X\r\n",count, buffer[0],buffer[1],buffer[2],buffer[3]);
02D3: MOVLW CF
02D4: BSF 03.6
02D5: MOVWF 0D
02D6: MOVLW 00
02D7: MOVWF 0F
02D8: BCF 03.0
02D9: MOVLW 07
02DA: BCF 03.6
02DB: MOVWF 5E
02DC: GOTO 14B
02DD: MOVLW 10
02DE: MOVWF 04
02DF: MOVF 2A,W
02E0: MOVWF 5F
02E1: MOVF 29,W
02E2: MOVWF 5E
02E3: GOTO 19E
02E4: MOVLW 20
02E5: BTFSS 0C.4
02E6: GOTO 2E5
02E7: MOVWF 19
02E8: MOVF 4B,W
02E9: MOVWF 5E
02EA: MOVLW 37
02EB: MOVWF 5F
02EC: CALL 1F9
02ED: MOVLW 20
02EE: BTFSS 0C.4
02EF: GOTO 2EE
02F0: MOVWF 19
02F1: MOVF 4C,W
02F2: MOVWF 5E
02F3: MOVLW 37
02F4: MOVWF 5F
02F5: CALL 1F9
02F6: MOVLW 20
02F7: BTFSS 0C.4
02F8: GOTO 2F7
02F9: MOVWF 19
02FA: MOVF 4D,W
02FB: MOVWF 5E
02FC: MOVLW 37
02FD: MOVWF 5F
02FE: CALL 1F9
02FF: MOVLW 20
0300: BTFSS 0C.4
0301: GOTO 300
0302: MOVWF 19
0303: MOVF 4E,W
0304: MOVWF 5E
0305: MOVLW 37
0306: MOVWF 5F
0307: CALL 1F9
0308: MOVLW 0D
0309: BTFSS 0C.4
030A: GOTO 309
030B: MOVWF 19
030C: MOVLW 0A
030D: BTFSS 0C.4
030E: GOTO 30D
030F: MOVWF 19
.................... {
.................... /* output_high(LED);
.................... delay_ms(999);
.................... output_low(LED);
.................... delay_ms(999);
.................... printf("%X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]);
.................... */
.................... }
0310: GOTO 2A7
03D6: GOTO 3D6
.................... }
0311: SLEEP
03D7: SLEEP
 
Configuration Fuses:
Word 1: 2CF2 HS NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.sta
1,56 → 1,60
 
ROM used: 786 (10%)
786 (10%) including unused fragments
ROM used: 984 (12%)
984 (12%) including unused fragments
 
1 Average locations per line
16 Average locations per statement
5 Average locations per statement
 
RAM used: 67 (18%) at main() level
80 (22%) worst case
RAM used: 43 (12%) at main() level
96 (26%) worst case
 
Stack used: 2 worst case (out of 8 total available)
Stack used: 3 worst case (out of 8 total available)
 
Lines Stmts % Files
----- ----- --- -----
102 50 100 main.c
151 68 36 main.c
26 0 0 main.h
423 0 0 C:\Program Files\PICC\devices\16F887.h
423 0 0 C:\Program Files (x86)\PICC\Devices\16F887.h
409 121 64 C:\Program Files (x86)\PICC\Drivers\string.h
28 0 0 C:\Program Files (x86)\PICC\Drivers\stddef.h
28 0 0 C:\Program Files (x86)\PICC\Drivers\ctype.h
----- -----
551 50 Total
1065 189 Total
 
Page ROM % RAM Vol Diff Functions:
---- --- --- --- --- ---- ----------
0 20 3 1 @delay_ms1
0 17 2 1 @delay_us1
0 22 2 1 @delay_ms1
Inline 1 @I2C_WRITE_1
0 44 6 0 @const78
0 74 9 4 453 4.3 ssp_interupt
0 26 3 0 78 1.6 TIMER2_isr
0 246 31 1 1017 5.3 MAIN
0 5 1 0 @const88
0 74 9 3 @PSTRINGC7_9600_62_63
0 13 2 0 @const90
0 83 11 4 @PSTRINGCN7_9600_62_63
0 91 12 9 @PRINTF_LU_9600_62_63
0 35 4 2 @PRINTF_X_9600_62_63
0 68 7 10 318 6.5 strncpy
0 44 4 0 @const169
0 78 8 4 592 4.3 ssp_interupt
0 385 39 35 1383 5.2 EXT_isr
Inline 1 @SPRINTF
0 70 7 13 @DIV3232
Inline 12 @PRINTF_L32U_184
Inline 2 @PSTRINGR_9600_62_63
0 7 1 0 17 1.3 TIMER1_isr
0 166 17 1 601 5.2 MAIN
0 5 1 0 851 5.3 @const197
0 74 8 3 @PSTRINGC7_9600_62_63
 
Program metrics:
Functions 3
Statements 50
Comments 96
Volume (V) 1896
Difficilty (D) 10.5
Effort to implement (E) 19912
Time to implement (T) 18 minutes
Est Delivered Bugs (B) 0
Cyclomatic Complexity 6
Maintainability (MI) 122
Functions 6
Statements 189
Comments 262
Volume (V) 5169
Difficilty (D) 27.7
Effort to implement (E) 142931
Time to implement (T) 2 hours, 12 minutes
Est Delivered Bugs (B) 1
Cyclomatic Complexity 9
Maintainability (MI) 43
 
Segment Used Free
----------- ---- ----
00000-00003 4 0
00004-00039 54 0
0003A-007FF 728 1262
00004-00040 61 0
00041-007FF 919 1064
00800-00FFF 0 2048
01000-017FF 0 2048
01800-01FFF 0 2048
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.sym
1,10 → 1,10
004 @WRITE_PROGRAM_MEMORY8.P1
004-005 @READ_PROGRAM_MEMORY8.P2
015 CCP_1_LOW
015 CCP_1
015 CCP_1_LOW
016 CCP_1_HIGH
01B CCP_2
01B CCP_2_LOW
01B CCP_2
01C CCP_2_HIGH
020 @INTERRUPT_AREA
021 @INTERRUPT_AREA
15,38 → 15,61
026 @INTERRUPT_AREA
027 rs232_errors
028 @TRIS_C
029-02A count
02B-03A rcv_buf
03B-04A snd_buf
04B-05A buffer
05B address
05C @I2C_STATE
05D MAIN.n
05E-05F @PRINTF_LU_9600_62_63.P1
05E @PRINTF_X_9600_62_63.P2
05E @PSTRINGCN7_9600_62_63.P3
05E MAIN.@SCRATCH1
05E @PSTRINGC7_9600_62_63.@SCRATCH1
05F @PRINTF_X_9600_62_63.P1
05F @delay_ms1.P2
05F @delay_us1.P3
05F @PSTRINGC7_9600_62_63.@SCRATCH2
05F @PSTRINGCN7_9600_62_63.@SCRATCH1
060 @PSTRINGC7_9600_62_63.@SCRATCH3
060 @PSTRINGCN7_9600_62_63.@SCRATCH2
060 @PRINTF_LU_9600_62_63.@SCRATCH1
061 @PSTRINGCN7_9600_62_63.@SCRATCH3
061 @PRINTF_LU_9600_62_63.@SCRATCH2
062 @PRINTF_LU_9600_62_63.@SCRATCH3
063 @PRINTF_LU_9600_62_63.@SCRATCH4
064 @PRINTF_LU_9600_62_63.@SCRATCH5
065 @PRINTF_LU_9600_62_63.@SCRATCH6
066 @PRINTF_LU_9600_62_63.@SCRATCH7
067 ssp_interupt.incoming
068 ssp_interupt.state
069 ssp_interupt.@SCRATCH1
06A @I2C_WRITE_1.P1
06A ssp_interupt.@SCRATCH2
029-02A strtok.save
02B-02E count
02F-03E buffer
03F address
040-041 of
042 @I2C_STATE
043-044 @sprintf_string
045 MAIN.n
046 MAIN.@SCRATCH1
046 @PSTRINGC7_9600_62_63.@SCRATCH1
047 @delay_ms1.P1
047 @PSTRINGC7_9600_62_63.@SCRATCH2
048 @PSTRINGC7_9600_62_63.@SCRATCH3
049 ssp_interupt.incoming
049-04A EXT_isr.countH
04A ssp_interupt.state
04B EXT_isr.countL
04B ssp_interupt.@SCRATCH1
04C-055 EXT_isr.countS
04C @I2C_WRITE_1.P1
04C ssp_interupt.@SCRATCH2
056-059 EXT_isr.a
05A-05D EXT_isr.b
05E-061 EXT_isr.c
062-065 @PRINTF_L32U_184.P1
062-063 strncpy.s1
062 EXT_isr.@SCRATCH1
062 @PSTRINGR_9600_62_63.@SCRATCH1
063 EXT_isr.@SCRATCH2
063 @PSTRINGR_9600_62_63.@SCRATCH2
064-065 strncpy.s2
064 EXT_isr.@SCRATCH3
065 EXT_isr.@SCRATCH4
066 strncpy.n
066 EXT_isr.@SCRATCH5
066 @PRINTF_L32U_184.@SCRATCH1
067-068 strncpy.s
067 EXT_isr.@SCRATCH6
067 @PRINTF_L32U_184.@SCRATCH2
068 EXT_isr.@SCRATCH7
068 @PRINTF_L32U_184.@SCRATCH3
069 strncpy.@SCRATCH1
069 EXT_isr.@SCRATCH8
069 @PRINTF_L32U_184.@SCRATCH4
06A strncpy.@SCRATCH2
06A EXT_isr.@SCRATCH9
06A @PRINTF_L32U_184.@SCRATCH5
06B strncpy.@SCRATCH3
06B EXT_isr.@SCRATCH10
06B @PRINTF_L32U_184.@SCRATCH6
06C @PRINTF_L32U_184.@SCRATCH7
06D @PRINTF_L32U_184.@SCRATCH8
06E @SPRINTF.P1
06E-071 @DIV3232.P2
072-075 @DIV3232.P1
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
53,11 → 76,16
079 @SCRATCH
07A @SCRATCH
07F @INTERRUPT_AREA
0A0 @DIV3232.@SCRATCH1
0A1 @DIV3232.@SCRATCH2
0A2 @DIV3232.@SCRATCH3
0A3 @DIV3232.@SCRATCH4
0A4 @DIV3232.@SCRATCH5
0FF @INTERRUPT_AREA
107.6 C1OUT
108.6 C2OUT
10D-10E @READ_PROGRAM_MEMORY8.P1
10D-10E @WRITE_PROGRAM_MEMORY8.P2
10D-10E @WRITE_PROGRAM_MEMORY8.P1
10D-10E @READ_PROGRAM_MEMORY8.P2
17F @INTERRUPT_AREA
1FF @INTERRUPT_AREA
27F @INTERRUPT_AREA
90,20 → 118,21
FFF @INTERRUPT_AREA
 
ROM Allocation:
00DC @delay_ms1
013A @delay_us1
00A1 @I2C_WRITE_1
003A cmd
0066 ssp_interupt
00B0 TIMER2_isr
021C MAIN
00CA @const88
00F0 @PSTRINGC7_9600_62_63
00CF @const90
014B @PSTRINGCN7_9600_62_63
019E @PRINTF_LU_9600_62_63
01F9 @PRINTF_X_9600_62_63
021C @cinit
02D2 @delay_ms1
00AC @I2C_WRITE_1
0101 strncpy
0041 cmd
006D ssp_interupt
0145 EXT_isr
0256 @SPRINTF
00BB @DIV3232
0211 @PRINTF_L32U_184
029B @PSTRINGR_9600_62_63
02C6 TIMER1_isr
0332 MAIN
02CD @const197
02E8 @PSTRINGC7_9600_62_63
0332 @cinit
 
 
User Memory space:
111,15 → 140,18
User Memory space:
 
Project Directory:
Z:\home\kaklik\svn\svnMLAB\Designs\Measuring_instruments\RMDS01C\SW\PIC887\
Z:\home\kaklik\svn\svnMLAB\Designs\Measuring_instruments\RMDS01C\SW\PIC16F887\
 
Project Files:
main.c
main.h
C:\Program Files\PICC\devices\16F887.h
C:\Program Files (x86)\PICC\Devices\16F887.h
C:\Program Files (x86)\PICC\Drivers\string.h
C:\Program Files (x86)\PICC\Drivers\stddef.h
C:\Program Files (x86)\PICC\Drivers\ctype.h
 
Units:
Z:\home\kaklik\svn\svnMLAB\Designs\Measuring_instruments\RMDS01C\SW\PIC887\main (main)
Z:\home\kaklik\svn\svnMLAB\Designs\Measuring_instruments\RMDS01C\SW\PIC16F887\main (main)
 
Compiler Settings:
Processor: PIC16F887
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.tre
1,17 → 1,18
ÀÄmain
ÃÄMAIN 0/246 Ram=1
ÃÄMAIN 0/166 Ram=1
³ ÃÄ??0??
³ ÃÄ@delay_ms1 0/20 Ram=1
³ ÃÄ@const78 0/44 Ram=0
³ ÃÄ@PSTRINGC7_9600_62_63 0/74 Ram=3
³ ÃÄ@delay_ms1 0/20 Ram=1
³ ÃÄ@delay_us1 0/17 Ram=1
³ ÃÄ@PSTRINGCN7_9600_62_63 0/83 Ram=4
³ ÃÄ@PRINTF_LU_9600_62_63 0/91 Ram=9
³ ÃÄ@PRINTF_X_9600_62_63 0/35 Ram=2
³ ÃÄ@PRINTF_X_9600_62_63 0/35 Ram=2
³ ÃÄ@PRINTF_X_9600_62_63 0/35 Ram=2
³ ÀÄ@PRINTF_X_9600_62_63 0/35 Ram=2
ÃÄssp_interupt 0/74 Ram=4
³ ÃÄ@delay_ms1 0/22 Ram=1
³ ÃÄ@const169 0/44 Ram=0
³ ÀÄ@PSTRINGC7_9600_62_63 0/74 Ram=3
ÃÄssp_interupt 0/78 Ram=4
³ ÀÄ@I2C_WRITE_1 (Inline) Ram=1
ÀÄTIMER2_isr 0/26 Ram=0
ÃÄEXT_isr 0/385 Ram=35
³ ÃÄ@PRINTF_L32U_184 (Inline) Ram=12
³ ³ ÃÄ@DIV3232 0/70 Ram=13
³ ³ ÃÄ@SPRINTF (Inline) Ram=1
³ ³ ÀÄ@DIV3232 0/70 Ram=13
³ ÃÄstrncpy 0/68 Ram=10
³ ÃÄstrncpy 0/68 Ram=10
³ ÃÄstrncpy 0/68 Ram=10
³ ÀÄ@PSTRINGR_9600_62_63 (Inline) Ram=2
ÀÄTIMER1_isr 0/7 Ram=0