/Designs/Measuring_instruments/AWS01B/SW/PIC16F887/i2c_wind_sensor/main.c
10,8 → 10,6
//#include <stdlib.h>
//#include <input.c> //needed for the rs232 input routines
 
 
int16 count=0xA5A5;
const int8 buf_len=8;
 
int8 buffer[buf_len]; // I2C buffer
21,8 → 19,8
#include "..\common\dbloader.h"
 
unsigned int16 timer0_overflow_count;
float anemo=0;
unsigned int8 rain;
unsigned int16 anemo=0;
unsigned int16 rain=0;
 
//we are using the rtctimer.c library, in which a counter is incremented
//every time the timer2 interrupt occurs (timer2 overflow). the time math
44,8 → 42,10
address = incoming;
if (incoming == 2)
{
buffer[0]=make8(count,0);
buffer[1]=make8(count,1);
buffer[0]=make8(anemo,0);
buffer[1]=make8(anemo,1);
buffer[2]=make8(rain,0);
buffer[3]=make8(rain,1);
}
}
if(state == 2) //Second received byte is data
62,7 → 62,7
void TIMER1_isr(void)
{
// 32.768 kHz krystal pro timer1 oscilátor
anemo = ((timer0_overflow_count * 0xFF) + get_timer0())/(0xFFFF/32768.0); // pocet pulzu za 1s
anemo = ((timer0_overflow_count * 0xFF) + get_timer0()); // pocet pulzu za 1s
 
timer0_overflow_count=0; //nulovani
set_timer0(0);
173,7 → 173,6
set_timer0(0);
set_timer1(0);
timer0_overflow_count=0;
rain=0;
 
buffer[2]=0;
buffer[3]=0;
180,15 → 179,12
buffer[4]=0;
buffer[5]=0;
 
 
welcome();
 
set_timer1(0);
 
while(true)
{
printf("count: %X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]);
printf("%6.1f %u \n\r", anemo, rain);
printf("%Lu %Lu \n\r", anemo, rain);
delay_ms(1000);
 
/Designs/Measuring_instruments/AWS01B/SW/PIC16F887/i2c_wind_sensor/main.h
1,8 → 1,6
#include <16F887.h>
#device adc=8
 
 
 
//#FUSES WDT // Watch Dog Timer
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //external crystal oscillator
20,8 → 18,5
 
#use delay(clock=20000000)
 
//set I2C
//#use i2c(Master,Slow,sda=PIN_C4,scl=PIN_C3)
 
//set RS232
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.c
1,6 → 1,8
#define ID "$Id: main.c 2916 2013-04-14 17:42:03Z kaklik $"
#include "main.h"
#use i2c(SLAVE, Fast, sda=PIN_C4, scl=PIN_C3, force_hw, address=0xA2)
 
#include <string.h>
//#include <string.h>
 
#define LED PIN_E1
#define CE PIN_E2
13,21 → 15,21
 
unsigned int32 count;
 
const int8 buf_len=8;
int8 buffer[buf_len]; // I2C buffer
int8 address=0;
 
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
void ssp_interupt ()
{
BYTE incoming, state;
BYTE incoming, state;
 
state = i2c_isr_state();
if(state < 0x80) //Master is sending data
{
incoming = i2c_read();
36,25 → 38,25
address = incoming;
if (incoming == 2)
{
buffer[0]=make8(count,0);
buffer[1]=make8(count,1);
buffer[2]=make8(count,2);
buffer[3]=make8(count,3);
}
/* buffer[0]=make8(anemo,0);
buffer[1]=make8(anemo,1);
buffer[2]=make8(rain,0);
buffer[3]=make8(rain,1);
*/ }
}
if(state == 2) //Second received byte is data
buffer[address] = incoming;
}
if(state == 0x80) //Master is requesting data
{
i2c_write(buffer[address]);
if(address <= buf_len) i2c_write(buffer[address]);
else i2c_write(ID[address - buf_len]);
}
}
 
 
#int_EXT // Interrupt from 1PPS
 
/*#int_EXT // Interrupt from 1PPS
void EXT_isr(void)
{
unsigned int16 countH;
114,9 → 116,9
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
/* 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);
124,27 → 126,50
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
delay_ms(1000);
 
*/
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
// setup_adc(ADC_CLOCK_DIV_2);
setup_adc(ADC_OFF);
// setup_spi(SPI_SS_DISABLED); //must not be set if I2C are in use!
setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
// setup_timer_0(RTCC_INTERNAL);setup_wdt(WDT_144MS);
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1|T1_CLK_OUT);
// setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
// setup_oscillator(OSC_8MHZ|OSC_INTRC);
 
// 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);
 
 
/* delay_ms(1000);
int n;
for (n=0;n<40;n++) putc(cmd[n]); // setup GPS
 
*/
 
printf("cvak...\r\n");
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);
 
buffer[2]=0;
buffer[3]=0;
buffer[4]=0;
buffer[5]=0;
 
while(true)
{
/* output_high(LED);
delay_ms(999);
output_low(LED);
delay_ms(999);
// output_high(LED);
delay_ms(1000);
// 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,3 → 1,6
>>> 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.
>>> Warning 202 "main.c" Line 16(16,21): Variable never used: count
>>> Warning 202 "main.c" Line 22(16,18): Variable never used: of
>>> Warning 202 "main.c" Line 24(12,15): Variable never used: cmd
Memory usage: ROM=5% RAM=8% - 10%
0 Errors, 4 Warnings.
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.esym
1,8 → 1,8
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 "__PCM__" 0 177 ""4.106""
D G "__DEVICE__" 0 177 "887"
D G "__DATE__" 0 177 ""04-II-14""
D G "__TIME__" 0 177 ""15:49:01""
D G "ID" 0 1 ""$Id: main.c 2916 2013-04-14 17:42:03Z kaklik $""
d G "PIN_A0" 2 20 "40"
d G "PIN_A1" 2 21 "41"
d G "PIN_A2" 2 22 "42"
274,182 → 274,39
d G "INT_RB5" 2 418 "0x0200B08"
d G "INT_RB6" 2 419 "0x0400B08"
d G "INT_RB7" 2 420 "0x0800B08"
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"
D G "LED" 0 7 "PIN_E1"
D G "CE" 0 8 "PIN_E2"
D G "SEL0" 0 10 "PIN_E0" "external counter division ratio"
D G "SEL1" 0 11 "PIN_E1" "external counter division ratio"
D G "MR" 0 12 "PIN_E2" "external counter master reset"
D G "CLKI" 0 13 "PIN_C0" "internal counter input"
D G "BEEP" 0 14 "PIN_C3" "buzzer"
V G "count" 0 16 "int32"
V G "buf_len" 0 18 "int8"
V G "buffer" 0 19 "int8[8]" "I2C buffer"
V G "address" 0 20 "int8"
V G "of" 0 22 "int16"
V G "cmd" 0 24 "int8[40]"
F G "ssp_interupt" 0 28 "void()"
V L "incoming" 0 30 "int8"
V L "state" 0 30 "int8"
C L "ssp_interupt" 0 5 1 "FUNCTION"
C L "ssp_interupt" 0 5 1 "FUNCTION"
C L "ssp_interupt" 0 5 4 "FUNCTION"
C L "ssp_interupt" 0 5 1 "FUNCTION"
C L "ssp_interupt" 0 5 1 "FUNCTION"
C L "MAIN" 0 5 40 "FUNCTION"
F G "MAIN" 0 117 "void()" "setup_adc_ports(NO_ANALOGS|VSS_VDD);"
C L "MAIN" 0 5 9 "FUNCTION"
C L "MAIN" 0 5 1 "FUNCTION"
C L "MAIN" 0 5 1 "FUNCTION"
C L "MAIN" 0 5 1 "FUNCTION"
C L "MAIN" 0 5 1 "FUNCTION"
C L "MAIN" 0 5 4 "FUNCTION"
C L "MAIN" 0 5 1 "FUNCTION"
C L "MAIN" 0 5 3 "FUNCTION"
C L "MAIN" 0 5 1 "FUNCTION"
C L "MAIN" 0 5 2 "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.h
18,8 → 18,4
#use delay(clock=20000000)
#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
// when MASTER is the most recent #use i2c
//#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)
 
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.hex
1,127 → 1,57
:1000000003308A00322B0000FF00030E8301A100A1
:1000000001308A0011290000FF00030E8301A100C6
:100010000A08A0008A010408A2007708A300780853
: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
:10002000A4007908A5007A08A600831383128C30F7
:100030008400801D1D288C192E2822088400230886
:10004000F7002408F8002508F9002608FA0020081F
:100050008A00210E8300FF0E7F0E09008A110A120A
:100060003E2813083F08930014168C1183161418A9
:100070003728F8018312141AF80A08008316941A14
:1000800049288312B8018316141D49288312B81712
:10009000831683123808B80ABD003D087F3C031C54
:1000A000692814138C1D522813081416BC003D0B2C
:1000B0005F283C08B5003C08023C031D5F283D0852
:1000C000023C031D69282D303507840083133C084A
:1000D00080003D08803C031D85283508083C031C32
:1000E0007A282D303507840083130008BE00BF0036
:1000F0003120852808303502000784008313561804
:1001000083170008BE00BF0031208C118A110A122B
:100110001D28633BE1352E17AE060A008316031730
:100120008C170C140000000083120C087F3903198F
:10013000D4280313B90003170D080313BA000317DB
:100140000F080313BB0039080C1EA42899003A08B5
:1001500003178D0003133B0803178F0083168C17BA
:100160000C140000000083120C0D0E0D7F390319D2
:10017000D4280313B90003170D080313BA0003179B
:100180000F080313BB0039080C1EC42899003A0855
:1001900003178D0003133B0803178F008D0A031903
:1001A0008F0A03138E28031703138A110A1270296A
:1001B0003A308400831300080319EB280630F80056
:1001C000F701F70BE128F80BE0287B30F700F70B7D
:1001D000E728800BDE288A110A127929BA1B012927
:1001E0000F30F700390EF7050A3077020318FB28A5
:1001F0003030F707FD283A08F70777080C1EFE286D
:1002000099000F30B9050A30390203180929303036
:100210000B29BA133A08B90739080C1E0D299900A1
:100220000800840183131F30830583160317871585
:1002300008300313990002309A00A63098009030DD
:1002400083129800A81528088316870083122816A1
:10025000280883168700A23093003630831294005A
:10026000B501B701B601831603170908C039890023
:1002700003131F129F120030031788008312870197
:10028000880189010313A701FF30A8000330B800DB
:10029000831603170908C039890003131F129F1220
:1002A000003003178800831203131F108316010800
:1002B000C739283881000F30831290000317870157
:1002C000880189018316031397018C15C0308312AE
:1002D0008B04893003178D0000308F0003138E28A4
:1002E000AF01B001B101B2010430B900FA30BA0077
:1002F000D828B90B76292D08B9003730BA00EE207E
:1003000020300C1E812999002E08B9003730BA0020
:10031000EE2020300C1E8A2999002F08B9003730B2
:10032000BA00EE2020300C1E932999003008B90045
:100330003730BA00EE200D300C1E9C2999000A308F
:0A0340000C1EA02999007429630027
:04400E00F22CFF3F52
:00000001FF
;PIC16F887
;CRC=9B3A CREATED="04-II-14 11:45"
;CRC=6DDF CREATED="04-II-14 15:49"
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.lst
1,17 → 1,17
CCS PCM C Compiler, Version 4.106, 47914 04-II-14 11:45
CCS PCM C Compiler, Version 4.106, 47914 04-II-14 15:49
 
Filename: Z:\home\kaklik\svn\svnMLAB\Designs\Measuring_instruments\RMDS01C\SW\PIC16F887\main.lst
 
ROM used: 984 words (12%)
ROM used: 421 words (5%)
Largest free fragment is 2048
RAM used: 43 (12%) at main() level
96 (26%) worst case
RAM used: 31 (8%) at main() level
37 (10%) worst case
Stack: 3 worst case (1 in main + 2 for interrupts)
 
*
0000: MOVLW 03
0000: MOVLW 01
0001: MOVWF 0A
0002: GOTO 332
0002: GOTO 111
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
32,48 → 32,33
0014: MOVWF 26
0015: BCF 03.7
0016: BCF 03.5
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
0017: MOVLW 8C
0018: MOVWF 04
0019: BTFSS 00.3
001A: GOTO 01D
001B: BTFSC 0C.3
001C: GOTO 02E
001D: MOVF 22,W
001E: MOVWF 04
001F: MOVF 23,W
0020: MOVWF 77
0021: MOVF 24,W
0022: MOVWF 78
0023: MOVF 25,W
0024: MOVWF 79
0025: MOVF 26,W
0026: MOVWF 7A
0027: MOVF 20,W
0028: MOVWF 0A
0029: SWAPF 21,W
002A: MOVWF 03
002B: SWAPF 7F,F
002C: SWAPF 7F,W
002D: RETFIE
002E: BCF 0A.3
002F: BCF 0A.4
0030: GOTO 03E
.................... #define ID "$Id: main.c 2916 2013-04-14 17:42:03Z kaklik $"
.................... #include "main.h"
.................... #include <16F887.h>
.................... //////// Standard Header file for the PIC16F887 device ////////////////
98,588 → 83,50
....................
.................... #use delay(clock=20000000)
*
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)
00D8: MOVLW 3A
00D9: MOVWF 04
00DA: BCF 03.7
00DB: MOVF 00,W
00DC: BTFSC 03.2
00DD: GOTO 0EB
00DE: MOVLW 06
00DF: MOVWF 78
00E0: CLRF 77
00E1: DECFSZ 77,F
00E2: GOTO 0E1
00E3: DECFSZ 78,F
00E4: GOTO 0E0
00E5: MOVLW 7B
00E6: MOVWF 77
00E7: DECFSZ 77,F
00E8: GOTO 0E7
00E9: DECFSZ 00,F
00EA: GOTO 0DE
00EB: BCF 0A.3
00EC: BCF 0A.4
00ED: GOTO 179 (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
.................... // when MASTER is the most recent #use i2c
.................... //#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)
*
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--)
.................... #use i2c(SLAVE, Fast, sda=PIN_C4, scl=PIN_C3, force_hw, address=0xA2)
*
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
0031: MOVF 13,W
0032: MOVF 3F,W
0033: MOVWF 13
0034: BSF 14.4
0035: BCF 0C.3
0036: BSF 03.5
0037: BTFSC 14.0
0038: GOTO 037
0039: CLRF 78
003A: BCF 03.5
003B: BTFSC 14.4
003C: INCF 78,F
003D: RETURN
....................
.................... return(s1);
0140: MOVF 62,W
0141: MOVWF 78
0142: MOVF 63,W
0143: MOVWF 79
.................... }
0144: RETURN
.................... /***********************************************************/
.................... //#include <string.h>
....................
.................... /*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
....................
691,117 → 138,119
....................
.................... unsigned int32 count;
....................
.................... const int8 buf_len=8;
.................... int8 buffer[buf_len]; // I2C buffer
.................... int8 address=0;
....................
.................... 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
.................... void ssp_interupt ()
.................... {
.................... BYTE incoming, state;
.................... BYTE incoming, state;
....................
.................... state = i2c_isr_state();
*
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
....................
003E: BSF 03.5
003F: BTFSC 14.5
0040: GOTO 049
0041: BCF 03.5
0042: CLRF 38
0043: BSF 03.5
0044: BTFSS 14.2
0045: GOTO 049
0046: BCF 03.5
0047: BSF 38.7
0048: BSF 03.5
0049: BCF 03.5
004A: MOVF 38,W
004B: INCF 38,F
004C: MOVWF 3D
.................... if(state < 0x80) //Master is sending data
007C: MOVF 4A,W
007D: SUBLW 7F
007E: BTFSS 03.0
007F: GOTO 0A0
004D: MOVF 3D,W
004E: SUBLW 7F
004F: BTFSS 03.0
0050: GOTO 069
.................... {
.................... incoming = i2c_read();
0080: BCF 14.6
0081: BTFSS 0C.3
0082: GOTO 081
0083: MOVF 13,W
0084: BSF 14.4
0085: MOVWF 49
0051: BCF 14.6
0052: BTFSS 0C.3
0053: GOTO 052
0054: MOVF 13,W
0055: BSF 14.4
0056: MOVWF 3C
.................... if(state == 1) //First received byte is address
0086: DECFSZ 4A,W
0087: GOTO 096
0057: DECFSZ 3D,W
0058: GOTO 05F
.................... {
.................... address = incoming;
0088: MOVF 49,W
0089: MOVWF 3F
0059: MOVF 3C,W
005A: MOVWF 35
.................... if (incoming == 2)
008A: MOVF 49,W
008B: SUBLW 02
008C: BTFSS 03.2
008D: GOTO 096
005B: MOVF 3C,W
005C: SUBLW 02
005D: BTFSS 03.2
005E: GOTO 05F
.................... {
.................... buffer[0]=make8(count,0);
008E: MOVF 2B,W
008F: MOVWF 2F
.................... buffer[1]=make8(count,1);
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
.................... }
.................... /* buffer[0]=make8(anemo,0);
.................... buffer[1]=make8(anemo,1);
.................... buffer[2]=make8(rain,0);
.................... buffer[3]=make8(rain,1);
.................... */ }
.................... }
.................... if(state == 2) //Second received byte is data
0096: MOVF 4A,W
0097: SUBLW 02
0098: BTFSS 03.2
0099: GOTO 0A0
005F: MOVF 3D,W
0060: SUBLW 02
0061: BTFSS 03.2
0062: GOTO 069
.................... buffer[address] = incoming;
009A: MOVLW 2F
009B: ADDWF 3F,W
009C: MOVWF 04
009D: BCF 03.7
009E: MOVF 49,W
009F: MOVWF 00
....................
....................
0063: MOVLW 2D
0064: ADDWF 35,W
0065: MOVWF 04
0066: BCF 03.7
0067: MOVF 3C,W
0068: MOVWF 00
.................... }
.................... if(state == 0x80) //Master is requesting data
00A0: MOVF 4A,W
00A1: SUBLW 80
00A2: BTFSS 03.2
00A3: GOTO 0B7
0069: MOVF 3D,W
006A: SUBLW 80
006B: BTFSS 03.2
006C: GOTO 085
.................... {
.................... i2c_write(buffer[address]);
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
.................... if(address <= buf_len) i2c_write(buffer[address]);
006D: MOVF 35,W
006E: SUBLW 08
006F: BTFSS 03.0
0070: GOTO 07A
0071: MOVLW 2D
0072: ADDWF 35,W
0073: MOVWF 04
0074: BCF 03.7
0075: MOVF 00,W
0076: MOVWF 3E
0077: MOVWF 3F
0078: CALL 031
.................... else i2c_write(ID[address - buf_len]);
0079: GOTO 085
007A: MOVLW 08
007B: SUBWF 35,W
007C: ADDWF 00,W
007D: MOVWF 04
007E: BCF 03.7
007F: BTFSC 56.0
0080: BSF 03.7
0081: MOVF 00,W
0082: MOVWF 3E
0083: MOVWF 3F
0084: CALL 031
.................... }
.................... }
....................
....................
*
00B7: BCF 0C.3
00B8: BCF 0A.3
00B9: BCF 0A.4
00BA: GOTO 027
.................... #int_EXT // Interrupt from 1PPS
....................
.................... /*#int_EXT // Interrupt from 1PPS
.................... void EXT_isr(void)
.................... {
.................... unsigned int16 countH;
809,307 → 258,43
.................... 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
.................... }
....................
....................
1123,204 → 308,213
.................... }*/
....................
....................
02C9: BCF 0C.0
02CA: BCF 0A.3
02CB: BCF 0A.4
02CC: GOTO 027
0085: BCF 0C.3
0086: BCF 0A.3
0087: BCF 0A.4
0088: GOTO 01D
.................... void main()
.................... {
*
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);
*
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
0111: CLRF 04
0112: BCF 03.7
0113: MOVLW 1F
0114: ANDWF 03,F
0115: BSF 03.5
0116: BSF 03.6
0117: BSF 07.3
0118: MOVLW 08
0119: BCF 03.6
011A: MOVWF 19
011B: MOVLW 02
011C: MOVWF 1A
011D: MOVLW A6
011E: MOVWF 18
011F: MOVLW 90
0120: BCF 03.5
0121: MOVWF 18
0122: BSF 28.3
0123: MOVF 28,W
0124: BSF 03.5
0125: MOVWF 07
0126: BCF 03.5
0127: BSF 28.4
0128: MOVF 28,W
0129: BSF 03.5
012A: MOVWF 07
012B: MOVLW A2
012C: MOVWF 13
012D: MOVLW 36
012E: BCF 03.5
012F: MOVWF 14
0130: CLRF 35
0131: CLRF 37
0132: CLRF 36
0133: BSF 03.5
0134: BSF 03.6
0135: MOVF 09,W
0136: ANDLW C0
0137: MOVWF 09
0138: BCF 03.6
0139: BCF 1F.4
013A: BCF 1F.5
013B: MOVLW 00
013C: BSF 03.6
013D: MOVWF 08
013E: BCF 03.5
013F: CLRF 07
0140: CLRF 08
0141: CLRF 09
.................... /* setup_adc_ports(NO_ANALOGS|VSS_VDD);
.................... setup_adc(ADC_OFF);
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_spi(SPI_SS_DISABLED);
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
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);
0393: MOVLW 07
0394: BCF 03.5
0395: MOVWF 10
.................... setup_timer_2(T2_DIV_BY_16,196,16);
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);
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);
03A9: BCF 03.5
03AA: BSF 03.6
03AB: CLRF 07
03AC: CLRF 08
03AD: CLRF 09
.................... setup_vref(FALSE);
03AE: BSF 03.5
03AF: BCF 03.6
03B0: CLRF 17
....................
.................... delay_ms(1000);
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
....................
.................... */
....................
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
*
0148: BSF 03.5
0149: BSF 03.6
014A: MOVF 09,W
014B: ANDLW C0
014C: MOVWF 09
014D: BCF 03.6
014E: BCF 1F.4
014F: BCF 1F.5
0150: MOVLW 00
0151: BSF 03.6
0152: MOVWF 08
.................... // setup_adc(ADC_CLOCK_DIV_2);
.................... setup_adc(ADC_OFF);
0153: BCF 03.5
0154: BCF 03.6
0155: BCF 1F.0
.................... // setup_spi(SPI_SS_DISABLED); //must not be set if I2C are in use!
.................... setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
0156: BSF 03.5
0157: MOVF 01,W
0158: ANDLW C7
0159: IORLW 28
015A: MOVWF 01
.................... // setup_timer_0(RTCC_INTERNAL);setup_wdt(WDT_144MS);
.................... setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1|T1_CLK_OUT);
015B: MOVLW 0F
015C: BCF 03.5
015D: MOVWF 10
.................... // setup_timer_2(T2_DISABLED,0,1);
.................... setup_comparator(NC_NC_NC_NC);
015E: BSF 03.6
015F: CLRF 07
0160: CLRF 08
0161: CLRF 09
.................... setup_vref(FALSE);
0162: BSF 03.5
0163: BCF 03.6
0164: CLRF 17
.................... // setup_oscillator(OSC_8MHZ|OSC_INTRC);
....................
.................... // ext_int_edge( L_TO_H ); // set 1PPS active edge
.................... // enable_interrupts(INT_TIMER1);
.................... // enable_interrupts(INT_EXT);
.................... enable_interrupts(INT_SSP);
0165: BSF 0C.3
.................... // enable_interrupts(INT_TIMER2);
.................... enable_interrupts(GLOBAL);
0166: MOVLW C0
0167: BCF 03.5
0168: IORWF 0B,F
....................
....................
.................... /* delay_ms(1000);
.................... int n;
.................... 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");
03C5: MOVLW CD
03C6: BSF 03.6
03C7: MOVWF 0D
03C8: MOVLW 02
03C9: MOVWF 0F
03CA: BCF 03.6
03CB: GOTO 2E8
0169: MOVLW 89
016A: BSF 03.6
016B: MOVWF 0D
016C: MOVLW 00
016D: MOVWF 0F
016E: BCF 03.6
016F: GOTO 08E
....................
.................... 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);
03D1: BSF 03.5
03D2: BSF 0C.3
.................... // enable_interrupts(INT_TIMER2);
.................... enable_interrupts(GLOBAL);
03D3: MOVLW C0
03D4: BCF 03.5
03D5: IORWF 0B,F
....................
.................... buffer[2]=0;
0170: CLRF 2F
.................... buffer[3]=0;
0171: CLRF 30
.................... buffer[4]=0;
0172: CLRF 31
.................... buffer[5]=0;
0173: CLRF 32
....................
.................... while(true)
.................... {
.................... /* output_high(LED);
.................... delay_ms(999);
.................... output_low(LED);
.................... delay_ms(999);
.................... // output_high(LED);
.................... delay_ms(1000);
0174: MOVLW 04
0175: MOVWF 39
0176: MOVLW FA
0177: MOVWF 3A
0178: GOTO 0D8
0179: DECFSZ 39,F
017A: GOTO 176
.................... // output_low(LED);
.................... // delay_ms(999);
.................... printf("%X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]);
.................... */
017B: MOVF 2D,W
017C: MOVWF 39
017D: MOVLW 37
017E: MOVWF 3A
017F: CALL 0EE
0180: MOVLW 20
0181: BTFSS 0C.4
0182: GOTO 181
0183: MOVWF 19
0184: MOVF 2E,W
0185: MOVWF 39
0186: MOVLW 37
0187: MOVWF 3A
0188: CALL 0EE
0189: MOVLW 20
018A: BTFSS 0C.4
018B: GOTO 18A
018C: MOVWF 19
018D: MOVF 2F,W
018E: MOVWF 39
018F: MOVLW 37
0190: MOVWF 3A
0191: CALL 0EE
0192: MOVLW 20
0193: BTFSS 0C.4
0194: GOTO 193
0195: MOVWF 19
0196: MOVF 30,W
0197: MOVWF 39
0198: MOVLW 37
0199: MOVWF 3A
019A: CALL 0EE
019B: MOVLW 0D
019C: BTFSS 0C.4
019D: GOTO 19C
019E: MOVWF 19
019F: MOVLW 0A
01A0: BTFSS 0C.4
01A1: GOTO 1A0
01A2: MOVWF 19
....................
.................... }
03D6: GOTO 3D6
01A3: GOTO 174
.................... }
03D7: SLEEP
01A4: 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,60 → 1,50
 
ROM used: 984 (12%)
984 (12%) including unused fragments
ROM used: 421 (5%)
421 (5%) including unused fragments
 
1 Average locations per line
5 Average locations per statement
13 Average locations per statement
 
RAM used: 43 (12%) at main() level
96 (26%) worst case
RAM used: 31 (8%) at main() level
37 (10%) worst case
 
Stack used: 3 worst case (out of 8 total available)
 
Lines Stmts % Files
----- ----- --- -----
151 68 36 main.c
26 0 0 main.h
176 33 100 main.c
22 0 0 main.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
----- -----
1065 189 Total
621 33 Total
 
Page ROM % RAM Vol Diff Functions:
---- --- --- --- --- ---- ----------
0 22 2 1 @delay_ms1
Inline 1 @I2C_WRITE_1
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
0 22 5 1 @delay_ms1
0 13 3 1 @I2C_WRITE_1
0 75 18 4 420 5.5 ssp_interupt
0 148 35 1 574 3.8 MAIN
0 5 1 0 231 6.6 @const88
0 74 18 3 231 6.6 @PSTRINGC7_9600_62_63
0 35 8 2 367 7.0 @PRINTF_X_9600_62_63
 
Program metrics:
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
Functions 5
Statements 33
Comments 180
Volume (V) 2590
Difficilty (D) 28.8
Effort to implement (E) 74647
Time to implement (T) 1 hours, 9 minutes
Est Delivered Bugs (B) 1
Cyclomatic Complexity 9
Maintainability (MI) 43
Cyclomatic Complexity 12
Maintainability (MI) 114
 
Segment Used Free
----------- ---- ----
00000-00003 4 0
00004-00040 61 0
00041-007FF 919 1064
00004-00030 45 0
00031-007FF 372 1627
00800-00FFF 0 2048
01000-017FF 0 2048
01800-01FFF 0 2048
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.sym
1,7 → 1,7
004 @WRITE_PROGRAM_MEMORY8.P1
004-005 @READ_PROGRAM_MEMORY8.P2
004-005 @READ_PROGRAM_MEMORY8.P1
004 @WRITE_PROGRAM_MEMORY8.P2
015 CCP_1
015 CCP_1_LOW
015 CCP_1
016 CCP_1_HIGH
01B CCP_2
01B CCP_2_LOW
15,61 → 15,23
026 @INTERRUPT_AREA
027 rs232_errors
028 @TRIS_C
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
029-02C count
02D-034 buffer
035 address
036-037 of
038 @I2C_STATE
039 @PRINTF_X_9600_62_63.P1
039 MAIN.@SCRATCH1
039 @PSTRINGC7_9600_62_63.@SCRATCH1
03A @PRINTF_X_9600_62_63.P1
03A @delay_ms1.P2
03A @PSTRINGC7_9600_62_63.@SCRATCH2
03B @PSTRINGC7_9600_62_63.@SCRATCH3
03C ssp_interupt.incoming
03D ssp_interupt.state
03E ssp_interupt.@SCRATCH1
03F @I2C_WRITE_1.P1
03F ssp_interupt.@SCRATCH2
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
76,16 → 38,11
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 @WRITE_PROGRAM_MEMORY8.P1
10D-10E @READ_PROGRAM_MEMORY8.P2
10D-10E @READ_PROGRAM_MEMORY8.P1
10D-10E @WRITE_PROGRAM_MEMORY8.P2
17F @INTERRUPT_AREA
1FF @INTERRUPT_AREA
27F @INTERRUPT_AREA
118,21 → 75,14
FFF @INTERRUPT_AREA
 
ROM Allocation:
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
00D8 @delay_ms1
0031 @I2C_WRITE_1
003E ssp_interupt
0111 MAIN
0089 @const88
008E @PSTRINGC7_9600_62_63
00EE @PRINTF_X_9600_62_63
0111 @cinit
 
 
User Memory space:
146,9 → 96,6
main.c
main.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\PIC16F887\main (main)
/Designs/Measuring_instruments/RMDS01C/SW/PIC16F887/main.tre
1,18 → 1,12
ÀÄmain
ÃÄMAIN 0/166 Ram=1
ÃÄMAIN 0/148 Ram=1
³ ÃÄ??0??
³ ÃÄ@PSTRINGC7_9600_62_63 0/74 Ram=3
³ ÃÄ@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
ÃÄ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
³ ÃÄ@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/75 Ram=4
ÃÄ@I2C_WRITE_1 0/13 Ram=1
ÀÄ@I2C_WRITE_1 0/13 Ram=1