Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Ignore whitespace Rev 6 → Rev 410

/programy/C/PIC_C/mereni/geiger/bez_GPS/geiger.BAK
0,0 → 1,19
#include <16F88.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPUT //No Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOIESO //Internal External Switch Over mode enabled
 
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B5,bits=8)
 
/programy/C/PIC_C/mereni/geiger/bez_GPS/geiger.PJT
0,0 → 1,40
[PROJECT]
Target=geiger.HEX
Development_Mode=2
Processor=0x688F
ToolSuite=CCS
 
[Directories]
Include=
Library=
LinkerScript=
 
[Target Data]
FileList=D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[geiger.c]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c
 
[Windows]
0=0000 D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c 0 0 796 451 3 0
 
[Opened Files]
1=D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c
2=D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.h
3=C:\Program Files\PICC\devices\16F88.h
4=
[Units]
Count=1
1=D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c (main)
/programy/C/PIC_C/mereni/geiger/bez_GPS/geiger.c
0,0 → 1,27
#include "D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.h"
 
 
void main()
{
unsigned int16 n;
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_EXT_H_TO_L|RTCC_DIV_1);
setup_timer_1(T1_DISABLED|T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(A0_A2_A1_A2_OUT_ON_A3_A4);
setup_vref(VREF_LOW|1|VREF_A2);
setup_oscillator(False);
n=0;
set_timer0(0);
While(true)
{
printf("%Lu0, %u\n\r", n++, get_timer0());
set_timer0(0);
Delay_ms(10000);
}
}
/programy/C/PIC_C/mereni/geiger/bez_GPS/geiger.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/PIC_C/mereni/geiger/bez_GPS/geiger.err
0,0 → 1,2
No Errors
0 Errors, 0 Warnings.
/programy/C/PIC_C/mereni/geiger/bez_GPS/geiger.h
0,0 → 1,19
#include <16F88.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPUT //No Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOIESO //Internal External Switch Over mode disabled
 
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B5,bits=8)
 
/programy/C/PIC_C/mereni/geiger/bez_GPS/geiger.hex
0,0 → 1,47
:1000000000308A00E12800008316861183128611D1
:100010000830F800000000000000F8171E28F81350
:10002000AE0C03188615031C861178171E2878134A
:10003000F80B10280000000000008615A73084008F
:10004000840B202800000000F81B0F28781B1728BD
:1000500000340408AD00270EF038A900A907E23EDD
:10006000AA00323EAC0027080F39AA07AA07AC073E
:10007000E93EAB00AB07AB07260E0F39AB07AC0769
:10008000AB0DAC0DAC09AC0D26080F39AC07A90DB2
:100090000730A8000A30AC07AB03031C4B28AB07A2
:1000A000AA03031C4F28AA07A903031C5328A90766
:1000B000A803031C57282830840007302D052D1372
:1000C00084072C30040203192D170008F700031DC4
:1000D00071282D1B71282D1A7D28AD19712820300B
:1000E0007428AD152D123030F707A7010408A600BB
:1000F0007708AE00042026088400840A2D1F61289A
:100100008A113C292908F801280203188A2828089E
:10011000F7009628F7010830AA00A80DF70D290866
:1001200077020318F700F80DAA0B8D280034780821
:100130002608A8006430A90082207708A600780865
:100140003030031DAA28A71CB128A719B128271AE7
:100150002030AD28A71127122714F8077808AE0021
:1001600004202608A8000A30A90082207708A600EB
:1001700078083030031DC228A719C628271CC628B6
:10018000271A2030F8077808AE0004203030A60780
:100190002608AE0004208A114A2924308400000871
:1001A0000319DF280630F800F701F70BD528F80B04
:1001B000D4287B30F700F70BDB28800BD2288A117C
:1001C000562984011F3083058316861183128615F4
:1001D00083161F129F121B0880399B0007309C005A
:1001E0001F129F121B0880399B0083121F1094124C
:1001F00083160611861406120030831294008316AB
:1002000094000108C739383881008312900100300A
:10021000F8009200003083169200061483129701B2
:100220009701063083169C0005080738E7398500DA
:100230001030F700F70B1A2900001C0883120D1369
:10024000E13083169D0005158F010F088312A2016E
:10025000A10181012208FA002108A10A0319A20ABA
:10026000A3007A08A4000108A50010308400240827
:10027000A7002308A60029283030AE0004202C3027
:10028000AE0004202030AE0004202508A6001B305C
:10029000A70097280A30AE0004200D30AE000420DD
:1002A00081012830A300FA30A400CD28A30B5329E4
:0402B0002A29630094
:04400E002A3FFC3F0A
:00000001FF
;PIC16F88
/programy/C/PIC_C/mereni/geiger/bez_GPS/geiger.lst
0,0 → 1,250
CCS PCM C Compiler, Version 3.245, 27853 10-VI-06 10:23
 
Filename: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.lst
 
ROM used: 346 words (8%)
Largest free fragment is 2048
RAM used: 10 (6%) at main() level
19 (11%) worst case
Stack: 2 locations
 
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 0E1
0003: NOP
.................... #include "D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.h"
.................... #include <16F88.h>
.................... //////// Standard Header file for the PIC16F88 device ////////////////
.................... #device PIC16F88
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES HS //High speed Osc (> 4mhz)
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NOFCMEN //Fail-safe clock monitor disabled
.................... #FUSES NOIESO //Internal External Switch Over mode disabled
....................
.................... #use delay(clock=20000000)
00CD: MOVLW 24
00CE: MOVWF 04
00CF: MOVF 00,W
00D0: BTFSC 03.2
00D1: GOTO 0DF
00D2: MOVLW 06
00D3: MOVWF 78
00D4: CLRF 77
00D5: DECFSZ 77,F
00D6: GOTO 0D5
00D7: DECFSZ 78,F
00D8: GOTO 0D4
00D9: MOVLW 7B
00DA: MOVWF 77
00DB: DECFSZ 77,F
00DC: GOTO 0DB
00DD: DECFSZ 00,F
00DE: GOTO 0D2
00DF: BCF 0A.3
00E0: GOTO 156 (RETURN)
.................... #use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B5,bits=8)
*
0004: BSF 03.5
0005: BCF 06.3
0006: BCF 03.5
0007: BCF 06.3
0008: MOVLW 08
0009: MOVWF 78
000A: NOP
000B: NOP
000C: NOP
000D: BSF 78.7
000E: GOTO 01E
000F: BCF 78.7
0010: RRF 2E,F
0011: BTFSC 03.0
0012: BSF 06.3
0013: BTFSS 03.0
0014: BCF 06.3
0015: BSF 78.6
0016: GOTO 01E
0017: BCF 78.6
0018: DECFSZ 78,F
0019: GOTO 010
001A: NOP
001B: NOP
001C: NOP
001D: BSF 06.3
001E: MOVLW A7
001F: MOVWF 04
0020: DECFSZ 04,F
0021: GOTO 020
0022: NOP
0023: NOP
0024: BTFSC 78.7
0025: GOTO 00F
0026: BTFSC 78.6
0027: GOTO 017
0028: RETLW 00
....................
....................
....................
....................
.................... void main()
.................... {
*
00E1: CLRF 04
00E2: MOVLW 1F
00E3: ANDWF 03,F
00E4: BSF 03.5
00E5: BCF 06.3
00E6: BCF 03.5
00E7: BSF 06.3
00E8: BSF 03.5
00E9: BCF 1F.4
00EA: BCF 1F.5
00EB: MOVF 1B,W
00EC: ANDLW 80
00ED: MOVWF 1B
00EE: MOVLW 07
00EF: MOVWF 1C
.................... unsigned int16 n;
....................
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
00F0: BCF 1F.4
00F1: BCF 1F.5
00F2: MOVF 1B,W
00F3: ANDLW 80
00F4: MOVWF 1B
.................... setup_adc(ADC_OFF);
00F5: BCF 03.5
00F6: BCF 1F.0
.................... setup_spi(FALSE);
00F7: BCF 14.5
00F8: BSF 03.5
00F9: BCF 06.2
00FA: BSF 06.1
00FB: BCF 06.4
00FC: MOVLW 00
00FD: BCF 03.5
00FE: MOVWF 14
00FF: BSF 03.5
0100: MOVWF 14
.................... setup_timer_0(RTCC_EXT_H_TO_L|RTCC_DIV_1);
0101: MOVF 01,W
0102: ANDLW C7
0103: IORLW 38
0104: MOVWF 01
.................... setup_timer_1(T1_DISABLED|T1_DIV_BY_1);
0105: BCF 03.5
0106: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
0107: MOVLW 00
0108: MOVWF 78
0109: MOVWF 12
010A: MOVLW 00
010B: BSF 03.5
010C: MOVWF 12
.................... setup_ccp1(CCP_OFF);
010D: BSF 06.0
010E: BCF 03.5
010F: CLRF 17
0110: CLRF 17
.................... setup_comparator(A0_A2_A1_A2_OUT_ON_A3_A4);
0111: MOVLW 06
0112: BSF 03.5
0113: MOVWF 1C
0114: MOVF 05,W
0115: IORLW 07
0116: ANDLW E7
0117: MOVWF 05
0118: MOVLW 10
0119: MOVWF 77
011A: DECFSZ 77,F
011B: GOTO 11A
011C: NOP
011D: MOVF 1C,W
011E: BCF 03.5
011F: BCF 0D.6
.................... setup_vref(VREF_LOW|1|VREF_A2);
0120: MOVLW E1
0121: BSF 03.5
0122: MOVWF 1D
0123: BSF 05.2
.................... setup_oscillator(False);
0124: CLRF 0F
0125: MOVF 0F,W
....................
.................... n=0;
0126: BCF 03.5
0127: CLRF 22
0128: CLRF 21
.................... set_timer0(0);
0129: CLRF 01
.................... While(true)
.................... {
.................... printf("%Lu0, %u\n\r", n++, get_timer0());
012A: MOVF 22,W
012B: MOVWF 7A
012C: MOVF 21,W
012D: INCF 21,F
012E: BTFSC 03.2
012F: INCF 22,F
0130: MOVWF 23
0131: MOVF 7A,W
0132: MOVWF 24
0133: MOVF 01,W
0134: MOVWF 25
0135: MOVLW 10
0136: MOVWF 04
0137: MOVF 24,W
0138: MOVWF 27
0139: MOVF 23,W
013A: MOVWF 26
013B: GOTO 029
013C: MOVLW 30
013D: MOVWF 2E
013E: CALL 004
013F: MOVLW 2C
0140: MOVWF 2E
0141: CALL 004
0142: MOVLW 20
0143: MOVWF 2E
0144: CALL 004
0145: MOVF 25,W
0146: MOVWF 26
0147: MOVLW 1B
0148: MOVWF 27
0149: GOTO 097
014A: MOVLW 0A
014B: MOVWF 2E
014C: CALL 004
014D: MOVLW 0D
014E: MOVWF 2E
014F: CALL 004
.................... set_timer0(0);
0150: CLRF 01
.................... Delay_ms(10000);
0151: MOVLW 28
0152: MOVWF 23
0153: MOVLW FA
0154: MOVWF 24
0155: GOTO 0CD
0156: DECFSZ 23,F
0157: GOTO 153
.................... }
0158: GOTO 12A
.................... }
0159: SLEEP
 
Configuration Fuses:
Word 1: 3F2A HS NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT
Word 2: 3FFC NOFCMEN NOIESO
/programy/C/PIC_C/mereni/geiger/bez_GPS/geiger.sta
0,0 → 1,33
 
ROM used: 346 (8%)
346 (8%) including unused fragments
 
1 Average locations per line
20 Average locations per statement
 
RAM used: 10 (6%) at main() level
19 (11%) worst case
 
Lines Stmts % Files
----- ----- --- -----
28 17 100 D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c
20 0 0 D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.h
279 0 0 C:\Program Files\PICC\devices\16F88.h
----- -----
654 34 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 20 6 1 @delay_ms1
0 37 11 1 @PUTCHAR_1_
0 121 35 5 main
0 89 26 8 @PRINTF_LU_9600_51_53
0 21 6 3 @DIV88
0 54 16 2 @PRINTF_U_9600_51_53
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-007FF 342 1702
00800-00FFF 0 2048
 
/programy/C/PIC_C/mereni/geiger/bez_GPS/geiger.sym
0,0 → 1,61
015-016 CCP_1
015 CCP_1_LOW
016 CCP_1_HIGH
021-022 main.n
023 main.@SCRATCH
024 @delay_ms1.P1
024 main.@SCRATCH
025 main.@SCRATCH
026-027 @PRINTF_LU_9600_51_53.P1
026 @PRINTF_U_9600_51_53.P2
027 @PRINTF_U_9600_51_53.P1
028 @DIV88.P1
028 @PRINTF_LU_9600_51_53.@SCRATCH
029 @DIV88.P1
029 @PRINTF_LU_9600_51_53.@SCRATCH
02A @PRINTF_LU_9600_51_53.@SCRATCH
02A @DIV88.@SCRATCH
02B @PRINTF_LU_9600_51_53.@SCRATCH
02C @PRINTF_LU_9600_51_53.@SCRATCH
02D @PRINTF_LU_9600_51_53.@SCRATCH
02E @PUTCHAR_1_.P1
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
079 @SCRATCH
07A @SCRATCH
07B @SCRATCH
09C.6 C1OUT
09C.7 C2OUT
 
00CD @delay_ms1
0004 @PUTCHAR_1_
00E1 main
0029 @PRINTF_LU_9600_51_53
0082 @DIV88
0097 @PRINTF_U_9600_51_53
00E1 @cinit
 
Project Files:
D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c
D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.h
C:\Program Files\PICC\devices\16F88.h
 
Units:
D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c (main)
 
Compiler Settings:
Processor: PIC16F88
Pointer Size: 8
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: 1,8,16
 
Output Files:
Errors: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.err
INHX8: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.hex
Symbols: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.sym
List: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.lst
Debug/COFF: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.cof
Call Tree: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.tre
Statistics: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.sta
/programy/C/PIC_C/mereni/geiger/bez_GPS/geiger.tre
0,0 → 1,17
ÀÄgeiger
ÀÄmain 0/121 Ram=5
ÃÄ??0??
ÃÄ@PRINTF_LU_9600_51_53 0/89 Ram=8
³ ÀÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PRINTF_U_9600_51_53 0/54 Ram=2
³ ÃÄ@DIV88 0/21 Ram=3
³ ÃÄ@PUTCHAR_1_ 0/37 Ram=1
³ ÃÄ@DIV88 0/21 Ram=3
³ ÃÄ@PUTCHAR_1_ 0/37 Ram=1
³ ÀÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PUTCHAR_1_ 0/37 Ram=1
ÀÄ@delay_ms1 0/20 Ram=1
/programy/C/PIC_C/mereni/geiger/geiger.BAK
0,0 → 1,19
#include <16F88.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPUT //No Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOIESO //Internal External Switch Over mode enabled
 
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B5,bits=8)
 
/programy/C/PIC_C/mereni/geiger/geiger.PJT
0,0 → 1,40
[PROJECT]
Target=geiger.HEX
Development_Mode=2
Processor=0x688F
ToolSuite=CCS
 
[Directories]
Include=
Library=
LinkerScript=
 
[Target Data]
FileList=D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[geiger.c]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c
 
[Windows]
0=0000 D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c 0 0 796 451 3 0
 
[Opened Files]
1=D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c
2=D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.h
3=C:\Program Files\PICC\devices\16F88.h
4=
[Units]
Count=1
1=D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c (main)
/programy/C/PIC_C/mereni/geiger/geiger.c
0,0 → 1,27
#include "D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.h"
 
 
void main()
{
unsigned int16 n;
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_EXT_H_TO_L|RTCC_DIV_1);
setup_timer_1(T1_DISABLED|T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(A0_A2_A1_A2_OUT_ON_A3_A4);
setup_vref(VREF_LOW|1|VREF_A2);
setup_oscillator(False);
n=0;
set_timer0(0);
While(true)
{
printf("%Lu0, %u\n\r", n++, get_timer0());
set_timer0(0);
Delay_ms(10000);
}
}
/programy/C/PIC_C/mereni/geiger/geiger.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/PIC_C/mereni/geiger/geiger.err
0,0 → 1,2
No Errors
0 Errors, 0 Warnings.
/programy/C/PIC_C/mereni/geiger/geiger.h
0,0 → 1,19
#include <16F88.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPUT //No Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOIESO //Internal External Switch Over mode disabled
 
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B5,bits=8)
 
/programy/C/PIC_C/mereni/geiger/geiger.hex
0,0 → 1,47
:1000000000308A00E12800008316861183128611D1
:100010000830F800000000000000F8171E28F81350
:10002000AE0C03188615031C861178171E2878134A
:10003000F80B10280000000000008615A73084008F
:10004000840B202800000000F81B0F28781B1728BD
:1000500000340408AD00270EF038A900A907E23EDD
:10006000AA00323EAC0027080F39AA07AA07AC073E
:10007000E93EAB00AB07AB07260E0F39AB07AC0769
:10008000AB0DAC0DAC09AC0D26080F39AC07A90DB2
:100090000730A8000A30AC07AB03031C4B28AB07A2
:1000A000AA03031C4F28AA07A903031C5328A90766
:1000B000A803031C57282830840007302D052D1372
:1000C00084072C30040203192D170008F700031DC4
:1000D00071282D1B71282D1A7D28AD19712820300B
:1000E0007428AD152D123030F707A7010408A600BB
:1000F0007708AE00042026088400840A2D1F61289A
:100100008A113C292908F801280203188A2828089E
:10011000F7009628F7010830AA00A80DF70D290866
:1001200077020318F700F80DAA0B8D280034780821
:100130002608A8006430A90082207708A600780865
:100140003030031DAA28A71CB128A719B128271AE7
:100150002030AD28A71127122714F8077808AE0021
:1001600004202608A8000A30A90082207708A600EB
:1001700078083030031DC228A719C628271CC628B6
:10018000271A2030F8077808AE0004203030A60780
:100190002608AE0004208A114A2924308400000871
:1001A0000319DF280630F800F701F70BD528F80B04
:1001B000D4287B30F700F70BDB28800BD2288A117C
:1001C000562984011F3083058316861183128615F4
:1001D00083161F129F121B0880399B0007309C005A
:1001E0001F129F121B0880399B0083121F1094124C
:1001F00083160611861406120030831294008316AB
:1002000094000108C739383881008312900100300A
:10021000F8009200003083169200061483129701B2
:100220009701063083169C0005080738E7398500DA
:100230001030F700F70B1A2900001C0883120D1369
:10024000E13083169D0005158F010F088312A2016E
:10025000A10181012208FA002108A10A0319A20ABA
:10026000A3007A08A4000108A50010308400240827
:10027000A7002308A60029283030AE0004202C3027
:10028000AE0004202030AE0004202508A6001B305C
:10029000A70097280A30AE0004200D30AE000420DD
:1002A00081012830A300FA30A400CD28A30B5329E4
:0402B0002A29630094
:04400E002A3FFC3F0A
:00000001FF
;PIC16F88
/programy/C/PIC_C/mereni/geiger/geiger.lst
0,0 → 1,250
CCS PCM C Compiler, Version 3.245, 27853 10-VI-06 10:23
 
Filename: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.lst
 
ROM used: 346 words (8%)
Largest free fragment is 2048
RAM used: 10 (6%) at main() level
19 (11%) worst case
Stack: 2 locations
 
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 0E1
0003: NOP
.................... #include "D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.h"
.................... #include <16F88.h>
.................... //////// Standard Header file for the PIC16F88 device ////////////////
.................... #device PIC16F88
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES HS //High speed Osc (> 4mhz)
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NOFCMEN //Fail-safe clock monitor disabled
.................... #FUSES NOIESO //Internal External Switch Over mode disabled
....................
.................... #use delay(clock=20000000)
00CD: MOVLW 24
00CE: MOVWF 04
00CF: MOVF 00,W
00D0: BTFSC 03.2
00D1: GOTO 0DF
00D2: MOVLW 06
00D3: MOVWF 78
00D4: CLRF 77
00D5: DECFSZ 77,F
00D6: GOTO 0D5
00D7: DECFSZ 78,F
00D8: GOTO 0D4
00D9: MOVLW 7B
00DA: MOVWF 77
00DB: DECFSZ 77,F
00DC: GOTO 0DB
00DD: DECFSZ 00,F
00DE: GOTO 0D2
00DF: BCF 0A.3
00E0: GOTO 156 (RETURN)
.................... #use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B5,bits=8)
*
0004: BSF 03.5
0005: BCF 06.3
0006: BCF 03.5
0007: BCF 06.3
0008: MOVLW 08
0009: MOVWF 78
000A: NOP
000B: NOP
000C: NOP
000D: BSF 78.7
000E: GOTO 01E
000F: BCF 78.7
0010: RRF 2E,F
0011: BTFSC 03.0
0012: BSF 06.3
0013: BTFSS 03.0
0014: BCF 06.3
0015: BSF 78.6
0016: GOTO 01E
0017: BCF 78.6
0018: DECFSZ 78,F
0019: GOTO 010
001A: NOP
001B: NOP
001C: NOP
001D: BSF 06.3
001E: MOVLW A7
001F: MOVWF 04
0020: DECFSZ 04,F
0021: GOTO 020
0022: NOP
0023: NOP
0024: BTFSC 78.7
0025: GOTO 00F
0026: BTFSC 78.6
0027: GOTO 017
0028: RETLW 00
....................
....................
....................
....................
.................... void main()
.................... {
*
00E1: CLRF 04
00E2: MOVLW 1F
00E3: ANDWF 03,F
00E4: BSF 03.5
00E5: BCF 06.3
00E6: BCF 03.5
00E7: BSF 06.3
00E8: BSF 03.5
00E9: BCF 1F.4
00EA: BCF 1F.5
00EB: MOVF 1B,W
00EC: ANDLW 80
00ED: MOVWF 1B
00EE: MOVLW 07
00EF: MOVWF 1C
.................... unsigned int16 n;
....................
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
00F0: BCF 1F.4
00F1: BCF 1F.5
00F2: MOVF 1B,W
00F3: ANDLW 80
00F4: MOVWF 1B
.................... setup_adc(ADC_OFF);
00F5: BCF 03.5
00F6: BCF 1F.0
.................... setup_spi(FALSE);
00F7: BCF 14.5
00F8: BSF 03.5
00F9: BCF 06.2
00FA: BSF 06.1
00FB: BCF 06.4
00FC: MOVLW 00
00FD: BCF 03.5
00FE: MOVWF 14
00FF: BSF 03.5
0100: MOVWF 14
.................... setup_timer_0(RTCC_EXT_H_TO_L|RTCC_DIV_1);
0101: MOVF 01,W
0102: ANDLW C7
0103: IORLW 38
0104: MOVWF 01
.................... setup_timer_1(T1_DISABLED|T1_DIV_BY_1);
0105: BCF 03.5
0106: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
0107: MOVLW 00
0108: MOVWF 78
0109: MOVWF 12
010A: MOVLW 00
010B: BSF 03.5
010C: MOVWF 12
.................... setup_ccp1(CCP_OFF);
010D: BSF 06.0
010E: BCF 03.5
010F: CLRF 17
0110: CLRF 17
.................... setup_comparator(A0_A2_A1_A2_OUT_ON_A3_A4);
0111: MOVLW 06
0112: BSF 03.5
0113: MOVWF 1C
0114: MOVF 05,W
0115: IORLW 07
0116: ANDLW E7
0117: MOVWF 05
0118: MOVLW 10
0119: MOVWF 77
011A: DECFSZ 77,F
011B: GOTO 11A
011C: NOP
011D: MOVF 1C,W
011E: BCF 03.5
011F: BCF 0D.6
.................... setup_vref(VREF_LOW|1|VREF_A2);
0120: MOVLW E1
0121: BSF 03.5
0122: MOVWF 1D
0123: BSF 05.2
.................... setup_oscillator(False);
0124: CLRF 0F
0125: MOVF 0F,W
....................
.................... n=0;
0126: BCF 03.5
0127: CLRF 22
0128: CLRF 21
.................... set_timer0(0);
0129: CLRF 01
.................... While(true)
.................... {
.................... printf("%Lu0, %u\n\r", n++, get_timer0());
012A: MOVF 22,W
012B: MOVWF 7A
012C: MOVF 21,W
012D: INCF 21,F
012E: BTFSC 03.2
012F: INCF 22,F
0130: MOVWF 23
0131: MOVF 7A,W
0132: MOVWF 24
0133: MOVF 01,W
0134: MOVWF 25
0135: MOVLW 10
0136: MOVWF 04
0137: MOVF 24,W
0138: MOVWF 27
0139: MOVF 23,W
013A: MOVWF 26
013B: GOTO 029
013C: MOVLW 30
013D: MOVWF 2E
013E: CALL 004
013F: MOVLW 2C
0140: MOVWF 2E
0141: CALL 004
0142: MOVLW 20
0143: MOVWF 2E
0144: CALL 004
0145: MOVF 25,W
0146: MOVWF 26
0147: MOVLW 1B
0148: MOVWF 27
0149: GOTO 097
014A: MOVLW 0A
014B: MOVWF 2E
014C: CALL 004
014D: MOVLW 0D
014E: MOVWF 2E
014F: CALL 004
.................... set_timer0(0);
0150: CLRF 01
.................... Delay_ms(10000);
0151: MOVLW 28
0152: MOVWF 23
0153: MOVLW FA
0154: MOVWF 24
0155: GOTO 0CD
0156: DECFSZ 23,F
0157: GOTO 153
.................... }
0158: GOTO 12A
.................... }
0159: SLEEP
 
Configuration Fuses:
Word 1: 3F2A HS NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT
Word 2: 3FFC NOFCMEN NOIESO
/programy/C/PIC_C/mereni/geiger/geiger.sta
0,0 → 1,33
 
ROM used: 346 (8%)
346 (8%) including unused fragments
 
1 Average locations per line
20 Average locations per statement
 
RAM used: 10 (6%) at main() level
19 (11%) worst case
 
Lines Stmts % Files
----- ----- --- -----
28 17 100 D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c
20 0 0 D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.h
279 0 0 C:\Program Files\PICC\devices\16F88.h
----- -----
654 34 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 20 6 1 @delay_ms1
0 37 11 1 @PUTCHAR_1_
0 121 35 5 main
0 89 26 8 @PRINTF_LU_9600_51_53
0 21 6 3 @DIV88
0 54 16 2 @PRINTF_U_9600_51_53
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-007FF 342 1702
00800-00FFF 0 2048
 
/programy/C/PIC_C/mereni/geiger/geiger.sym
0,0 → 1,61
015-016 CCP_1
015 CCP_1_LOW
016 CCP_1_HIGH
021-022 main.n
023 main.@SCRATCH
024 @delay_ms1.P1
024 main.@SCRATCH
025 main.@SCRATCH
026-027 @PRINTF_LU_9600_51_53.P1
026 @PRINTF_U_9600_51_53.P2
027 @PRINTF_U_9600_51_53.P1
028 @DIV88.P1
028 @PRINTF_LU_9600_51_53.@SCRATCH
029 @DIV88.P1
029 @PRINTF_LU_9600_51_53.@SCRATCH
02A @PRINTF_LU_9600_51_53.@SCRATCH
02A @DIV88.@SCRATCH
02B @PRINTF_LU_9600_51_53.@SCRATCH
02C @PRINTF_LU_9600_51_53.@SCRATCH
02D @PRINTF_LU_9600_51_53.@SCRATCH
02E @PUTCHAR_1_.P1
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
079 @SCRATCH
07A @SCRATCH
07B @SCRATCH
09C.6 C1OUT
09C.7 C2OUT
 
00CD @delay_ms1
0004 @PUTCHAR_1_
00E1 main
0029 @PRINTF_LU_9600_51_53
0082 @DIV88
0097 @PRINTF_U_9600_51_53
00E1 @cinit
 
Project Files:
D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c
D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.h
C:\Program Files\PICC\devices\16F88.h
 
Units:
D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.c (main)
 
Compiler Settings:
Processor: PIC16F88
Pointer Size: 8
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: 1,8,16
 
Output Files:
Errors: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.err
INHX8: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.hex
Symbols: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.sym
List: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.lst
Debug/COFF: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.cof
Call Tree: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.tre
Statistics: D:\KAKLIK\programy\PIC_C\mereni\geiger\geiger.sta
/programy/C/PIC_C/mereni/geiger/geiger.tre
0,0 → 1,17
ÀÄgeiger
ÀÄmain 0/121 Ram=5
ÃÄ??0??
ÃÄ@PRINTF_LU_9600_51_53 0/89 Ram=8
³ ÀÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PRINTF_U_9600_51_53 0/54 Ram=2
³ ÃÄ@DIV88 0/21 Ram=3
³ ÃÄ@PUTCHAR_1_ 0/37 Ram=1
³ ÃÄ@DIV88 0/21 Ram=3
³ ÃÄ@PUTCHAR_1_ 0/37 Ram=1
³ ÀÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PUTCHAR_1_ 0/37 Ram=1
ÃÄ@PUTCHAR_1_ 0/37 Ram=1
ÀÄ@delay_ms1 0/20 Ram=1
/programy/C/PIC_C/mereni/geiger/nmea.c
0,0 → 1,1434
// Change the following to change the clock frequency
#define CRYSTAL_FREQ 16000000
// Change the following to change between 16 or 20 column display
#define DISPLAY_COLS 20
// Speed units are "1" (nautical knots), "2" (metric kph), or "3" (statute mph)
#define SPEED_UNITS 1
 
/****************************************************************************
GPS18.c
 
This program receives NMEA-0183 data from a GPS and displays it.
Meant for large display version still in 16F876.
Three buttons
Automicaly resets if main loop stops (not the best solution, still don't know why it's stopping)
 
Next: don't display GPS screens unless GPS is active
detect display needing reset
preset data eeprom for first-time operation
don't display init stuff if reseting from main loop
 
 
 
+5 +5+5
| | |
20 15 2
---------- ----------
~SerIn -----18-| |-24-----11-|DB4 A Vdd |
| |-25-----12-|DB5 |
ADC0 ------2-| |-26-----13-|DB6 |
ADC1 ------3-| 16F876 |-27-----14-|DB7 Vo| 3--
ADC2 ------5-| | | LCD | |
| |-14------6-|EN | |
XTAL--9-| |-15------4-|R/S | |
XTAL-10-| |-28-FET-16-|K | |
| | | RW Vss | |
BUTTON 1---21-| | ---------- |
BUTTON 2---22-| | 1 5 |
BUTTON 3---23-| | | | |
| | Gnd Gnd |
| | |
| |-11----------R/C-----------
| |
| |
----------
8 19
| |
Gnd Gnd
 
***************************************************************************/
#case
#include <16F876.h>
#include <jonsinc.h>
#device = *=16 ADC=10 /* allow RAM addresses over 255 */
 
#if ( ( CRYSTAL_FREQ < 4000000) || ( CRYSTAL_FREQ > 20000000 ) )
#error "CRYSTAL FREQ" not defined to between 8000000 and 20000000
#endif
#if ( ( DISPLAY_COLS != 16 ) && ( DISPLAY_COLS != 20 ) )
#error "DISPLAY COLS" not defined to 16 or 20
#endif
 
// RMC_TIME = 1 per clock megahertz, rounded
#define RMC_TIME CRYSTAL_FREQ/1000000
 
#define LCD_D0 PIN_B3
#define LCD_D1 PIN_B4
#define LCD_D2 PIN_B5
#define LCD_D3 PIN_B6
#define LCD_EN PIN_C3
#define LCD_RS PIN_C4
#define RX_IN PIN_C7
#define BUTTON_1 PIN_B0
#define BUTTON_2 PIN_B1
#define BUTTON_3 PIN_B2
#define LCD_BACKLITE PIN_B7
#define LINE_1 0x00
#define LINE_2 0x40
#if DISPLAY_COLS == 20
#define LINE_3 0x14
#define LINE_4 0x54
#endif
#if DISPLAY_COLS == 16
#define LINE_3 0x10
#define LINE_4 0x50
#endif
#define CLEAR_DISP 0x01
#define EOF 0x00
#define COMMA ','
#define CR 13
#define SPACE ' '
#define PERIOD '.'
#define DEGREE 0xdf
#define DOLLAR '$'
#define NULL 0
#define GPRMC_CODE 75
#define GPRMB_CODE 74
#define RX_BUFFER_SIZE 70
#define POSITION_SCREEN 1
#define WAYPOINT_SCREEN 2
#define BATTERY_SCREEN 3
#define HIDDEN_RMC 5
#define WARNING_MSG 0
#define NODATA_MSG 1
#define ACTIVITY_SYMBOL 0xFF
#define MAX_VOLTS 15
#define EEPROM_CONTRAST 0
#define EEPROM_INITIAL 1
 
/* Set the following define to "YES" to display XOR'ed GPS sentence code */
/* such as GPRMC and the display will read out the value of 74. */
#define GET_GPS_CODE NO
 
#separate void Display ( void );
#separate void LCD_Init ( void );
#separate void LCD_SetPosition ( unsigned int cX );
#separate void LCD_PutChar ( unsigned int cX );
#separate void LCD_PutCmd ( unsigned int cX );
#separate void LCD_PulseEnable ( void );
#separate void LCD_SetData ( unsigned int cX );
#separate void SkipField ( char cCnt );
#separate char GetField ( void );
#separate void InitRxBuffer ( char cCode );
#separate char GetRxChar ( void );
#separate void DisplayLatLon ( void );
#separate void DisplayWaypoint ( void );
#separate void DisplayLatitude ( char cLine );
#separate void DisplayLongitude ( char cLine );
#separate void DisplayHeading ( char cLine );
#separate void DisplaySpeed ( char cLine );
#separate void DisplaySteer ( char cLine, char cX );
#separate void DisplayWaypointName ( char cLine, char cX );
#separate void DisplayDistance ( char cLine, char cX );
#separate void DisplayBearing ( char cLine, char cX );
#separate void GetUtcAndMagVar ( void );
#separate long TrueToMag ( long iH );
#separate long FieldFiveToLong ( void );
#separate void DisplayAnalog ( void );
#separate void DisplayScaledVoltage ( long iV, char cScale );
#separate void DisplayArrival ( char cLine );
#separate void DisplayMessage ( char cMsgNum );
#separate void DisplayTemplateLatLon ( void );
#separate void DisplayTemplateWaypoint ( void );
#separate void DisplayTemplateAnalog ( void );
#separate void Delay5mS ( char cCnt );
 
#fuses HS, NOPROTECT, PUT, NOWDT, BROWNOUT, NOLVP, NOCPD
#use standard_io ( A )
#use standard_io ( B )
#use standard_io ( C )
#use delay ( clock = CRYSTAL_FREQ )
#use rs232 ( baud=4800, xmit=PIN_C6, rcv=PIN_C7, ERRORS ) // XMIT must be assigned to enable hardward USART
#priority RDA, RTCC, EXT
 
static char cC [ 10 ]; // local buffer
static char cTimeOut;
static char cRxBuffer [ RX_BUFFER_SIZE ]; // Fifo
static char cRxByteCnt; // Number of bytes in the recv fifo
static char *cRxBufferWritePtr; // Pointers for the Rx buffer
static char *cRxBufferReadPtr;
static char cRxIsrState, cRxMsgTypeReceived, cRxMsgTypeDesired;
static char cRxMsgReady, cReceiveFlag;
static long iVar, iLastRange, iTimeOut;
static char cVarDir, cScreenChanged, cAdcDone;
static char cButtonPressed, cSkip, cButtonCount;
static char cScreen, cSavedScreen, cRmcTimer1, cRmcTimer2;
static char cToFrom [ 5 ], cIndicator, cIllumination, cRxErrorFlag;
static char cDone, cContrast;
 
/*******************************************************************/
#int_ad
void AdcInterrupt ( void )
{
/* Gets here when ADC is done conversion, sets flag */
cAdcDone = YES;
}
 
#int_timer1
void Timer1Interrupt ( void )
{
/* Periodic RMC data timer, gets here every 204mS */
/* This routine forces RMC to run every 10 minutes to update */
/* magnetic variation */
if ( cRmcTimer1-- == 0 )
{
cRmcTimer1 = 255; // 52 seconds @ 10.240MHz
if ( cRmcTimer2-- == 0 )
{
cRmcTimer2 = RMC_TIME; // triggers every 10 minutes
cSavedScreen = cScreen; // save current screen type
cScreen = HIDDEN_RMC; // force RMC to run
}
}
}
 
#int_rtcc
void Timer0Interrupt ( void )
{
// Gets here every 16.4mS at 8MHz, 8.2mS at 16MHz
// Handles data timeout and switch debounce.
 
// DATA TIMEOUT TIMER
if ( cTimeOut != 0 )
{
cTimeOut--;
}
 
// This timer is preset by the normal operating loop, unless the operating
// loop stops looping, at which point iTimeOut finally decrements to zero
// and resets CPU.
if ( iTimeOut != 0 )
{
iTimeOut--;
}
else
{
reset_cpu(); // force reset
}
 
if ( input ( BUTTON_2 ) == LOW ) // if button still pressed
{
cScreen = WAYPOINT_SCREEN;
cSkip = YES; // skip out of anything in process
cScreenChanged = YES; // repaint complete screen
}
 
if ( input ( BUTTON_3 ) == LOW ) // if button still pressed
{
cScreen = BATTERY_SCREEN;
cSkip = YES; // skip out of anything in process
cScreenChanged = YES; // repaint complete screen
}
 
// SWITCH DEBOUNCE
if ( input ( BUTTON_1 ) == LOW ) // if button still pressed
{
if ( cButtonCount < 255 ) // hold at 255
{
cButtonCount++; // otherwise increment
}
}
else // if button is unpressed
{
if ( cButtonCount > 2 ) // filter out glitches
{
//If button press is greater than 3.3 seconds, cold reset
if ( cButtonCount == 255 )
{
reset_cpu();
}
if ( ( cButtonCount > 57 ) && ( cButtonCount < 255 ) )
{
if ( cScreen != HIDDEN_RMC ) // if not in the middle of getting magnetic variation
{
// cIllumination ^= ON;
output_bit ( LCD_BACKLITE, cIllumination ^= ON );
}
}
// If button press is less than 0.5 second
if ( cButtonCount <= 57 )
{
if ( cScreen != HIDDEN_RMC ) // if not in the middle of getting magnetic variation
{
//if ( cScreen++ >= BATTERY_SCREEN ) // increment to next screen
{
cScreen = POSITION_SCREEN; // wrap
}
cSkip = YES; // skip out of anything in process
cScreenChanged = YES; // repaint complete screen
}
}
}
cButtonCount = 0; // restart
}
}
 
#int_rda
void SerialInterrupt ( void )
{
/*
Reads incoming data from the USART and puts in in a rolling buffer
( but in this application, it should never roll.)
If the buffer is full, this routine just discards the received byte.
Not checking the LRC byte at the end of the NMEA-0183 sentence.
*/
char cChar;
 
if ( rs232_errors & 0x04 ) // get framing error bit from Rx status reg
{
cRxErrorFlag = ON;
}
cChar = getchar(); // get char from UART, clear any errors
 
if ( cRxByteCnt == RX_BUFFER_SIZE ) // is recv fifo full ???
{
goto done;
}
switch ( cRxIsrState )
{
case 0:
{
if ( cChar == DOLLAR ) // if start of NMEA0183 message
{
cRxByteCnt = 0; // reset byte count
cReceiveFlag = OFF; // default to off
cRxMsgTypeReceived = NULL; // set hashed value to null
cRxIsrState++; // next state
}
break;
}
case 1: // five type characters to obtain
case 2:
case 3:
case 4:
case 5:
{
cRxMsgTypeReceived ^= cChar; // hash in msg type
if ( cRxIsrState++ == 5 ) // if time to check message type
{
if ( cRxMsgTypeReceived == cRxMsgTypeDesired ) // if good
{
cReceiveFlag = YES; // enable receiving
cRxBufferWritePtr = cRxBuffer; // reset to beginning of buffer
}
else // don't want this message
{
cRxIsrState = 0; // reset to look for next msg
}
}
break;
}
case 6:
{
/* Case 6 skips the comma character following msg type */
cRxIsrState++;
break;
}
default: // remainder of characters
{
if ( cReceiveFlag == YES ) // if this message is wanted
{
*cRxBufferWritePtr = cChar; // put char in fifo
cRxBufferWritePtr++; // increment pointer
if ( cRxBufferWritePtr == ( cRxBuffer + RX_BUFFER_SIZE ) ) // pointer past end ?
{
cRxBufferWritePtr = cRxBuffer; // set pointer to start of fifo
}
cRxByteCnt++; // Increment byte count
if ( cChar == CR )
{
cRxMsgReady = YES; // signal that message is ready
cReceiveFlag = NO; // no more receive
}
}
}
}
done:;
}
 
/*******************************************************************/
 
void main ( void )
{
char cX;
 
iTimeOut = 65535; // default to very long to get by init
/* INITIALIZE */
output_float ( RX_IN ); // ensure Rx input is HiZ
output_float ( BUTTON_1 ); // ensure switch input is HiZ
output_float ( BUTTON_2 ); // ensure switch input is HiZ
output_float ( BUTTON_3 ); // ensure switch input is HiZ
output_low ( LCD_BACKLITE ); // turn off backlighting
port_b_pullups ( ON ); // enable pullups on switches
 
// GET SAVED SETTINGS
cContrast = read_eeprom ( EEPROM_CONTRAST ); // get stored value
 
// PWM is for display contrast
setup_ccp2 ( CCP_PWM ); // set for PWM mode
//The cycle time will be (1/clock)*4*t2div*(period+1)
// 1/8000000 * 4 * 1 * 128 = 51.2uS = 19.5KHz
setup_timer_2 ( T2_DIV_BY_1, 255, 1 ); // set PWM period
// duty cycle = value*(1/clock)*t2div
// 10 * 1/8000000 * 1 = 1.2uS
set_pwm2_duty ( cContrast ); // set contrast duty cycle
 
// SETUP TIMER 0
// Need 8-bit Timer0 to roll over every 13mS, approximately.
// Roll time = 256 * 1 / ( clock_freq / prescaler setting / 4 )
#if CRYSTAL_FREQ >= 15000000
setup_counters ( RTCC_INTERNAL, RTCC_DIV_256 ); // ~13mS timer wrap
#elif CRYSTAL_FREQ >= 8000000
setup_counters ( RTCC_INTERNAL, RTCC_DIV_128 ); // ~13mS timer wrap
#elif CRYSTAL_FREQ < 8000000
setup_counters ( RTCC_INTERNAL, RTCC_DIV_64 ); // ~13mS timer wrap
#endif
 
// Timer 1 roll time = 65536 * 1 / ( clock_freq / prescaler setting / 4 )
setup_timer_1 ( T1_INTERNAL | T1_DIV_BY_8 ); // 16-bit timer
 
setup_adc_ports ( RA0_RA1_RA3_ANALOG ); /* these three statements set up the ADC */
setup_adc ( ADC_CLOCK_INTERNAL );
cIllumination = OFF;
 
LCD_Init(); // set up LCD for 4-wire bus, etc.
 
/* INIT MESSAGE */
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( LINE_1 + 0 );
printf ( LCD_PutChar, " Northern Light " ); // welcome screen
LCD_SetPosition ( LINE_2 + 2 );
printf ( LCD_PutChar, "Monitor/Repeater" );
LCD_SetPosition ( LINE_3 + 3 );
printf ( LCD_PutChar, "v18 06/21/03" );
LCD_SetPosition ( LINE_4 + 5 );
printf ( LCD_PutChar, "c Jon Fick" );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( LINE_1 + 0);
printf ( LCD_PutChar, " Northern Light " ); // welcome screen
LCD_SetPosition ( LINE_2 + 2 );
printf ( LCD_PutChar, "GPS Repeater" );
LCD_SetPosition ( LINE_3 + 1 );
printf ( LCD_PutChar, "v18 06/21/03" );
LCD_SetPosition ( LINE_4 + 3 );
printf ( LCD_PutChar, "c Jon Fick" );
#endif
delay_ms ( 1000 );
 
/* INSTRUCTION MESSAGE */
LCD_PutCmd ( CLEAR_DISP );
LCD_SetPosition ( LINE_1 + 0 );
printf ( LCD_PutChar, "BUTTONS:" );
LCD_SetPosition ( LINE_2 + 0 );
printf ( LCD_PutChar, "<-- Lat/Lon" );
LCD_SetPosition ( LINE_3 + 0 );
printf ( LCD_PutChar, "<-- Waypoint" );
LCD_SetPosition ( LINE_4 + 0 );
printf ( LCD_PutChar, "<-- Battery" );
delay_ms ( 2000 );
 
/* SETUP MODE */
if ( input ( BUTTON_1 ) == LOW ) // if button is pressed
{
LCD_PutCmd ( CLEAR_DISP );
LCD_SetPosition ( LINE_1 + 0 );
printf ( LCD_PutChar, "Set contrast:" );
LCD_SetPosition ( LINE_2 + 0 );
printf ( LCD_PutChar, "<-- More" );
LCD_SetPosition ( LINE_3 + 0 );
printf ( LCD_PutChar, "<-- DONE" );
LCD_SetPosition ( LINE_4 + 0 );
printf ( LCD_PutChar, "<-- Less" );
while ( input ( BUTTON_1 ) == LOW ); // wait for switch to be released after entering SETUP mode
cContrast = 120; // start at full contrast
cDone = NO;
while ( cDone == NO )
{
set_pwm2_duty ( cContrast ); // update contrast
if ( input ( BUTTON_1 ) == LOW )
{
if ( cContrast > 0 )
{
cContrast--; // more
}
}
if ( input ( BUTTON_2 ) == LOW )
{
cDone = YES; // done
}
if ( input ( BUTTON_3 ) == LOW )
{
if ( cContrast < 255 )
{
cContrast++; // less
}
}
delay_ms ( 30 ); // autorepeat
}
write_eeprom ( EEPROM_CONTRAST, cContrast ); // save CONTRAST to EEPROM
 
LCD_PutCmd ( CLEAR_DISP );
LCD_SetPosition ( LINE_2 + 0 );
printf ( LCD_PutChar, "<- Press initial" );
LCD_SetPosition ( LINE_3 + 0 );
printf ( LCD_PutChar, " bootup screen" );
while ( input ( BUTTON_1 ) == LOW ); // wait until button not pressed
cX = POSITION_SCREEN;
while ( TRUE )
{
LCD_SetPosition ( LINE_4 + 3 );
switch ( cX )
{
case POSITION_SCREEN:
{
printf ( LCD_PutChar, "POSITION " );
break;
}
case WAYPOINT_SCREEN:
{
printf ( LCD_PutChar, "WAYPOINT " );
break;
}
case BATTERY_SCREEN:
{
printf ( LCD_PutChar, "BATTERY " );
break;
}
}
delay_ms ( 750 );
if ( input ( BUTTON_1 ) == LOW ) // if button is pressed
{
write_eeprom ( EEPROM_INITIAL, cX ); // save screen number to EEPROM
break;
}
if ( cX++ == BATTERY_SCREEN )
{
cX = POSITION_SCREEN;
}
}
LCD_PutCmd ( CLEAR_DISP );
}
 
/* This IF/ENDIF is a tool for getting the $GP... codes */
/* that are used in the switch/case in the main loop. */
#if ( GET_GPS_CODE == YES )
printf ( LCD_PutChar, "%u", 'G'^'P'^'R'^'M'^'B');
while ( TRUE );
#endif
 
/* INTERRUPTS */
ext_int_edge ( H_TO_L ); // set falling edge ext interrupt
enable_interrupts ( INT_TIMER1 ); // enable Timer1 interrupt
enable_interrupts ( INT_RDA ); // enable serial interrupt
enable_interrupts ( INT_RTCC ); // enable Timer0 interrupt
enable_interrupts ( INT_AD ); // enable ADC interrupt
enable_interrupts ( GLOBAL ); // enable all interrupts
 
/* VARIABLES */
iVar = NULL; // default, no variation yet
cVarDir = SPACE; // default, no variation yet
cRmcTimer1 = 255; // initialize to 52 seconds
cRmcTimer2 = RMC_TIME; // trigger forced RMC after 10 minutes
cScreen = HIDDEN_RMC; // default screen, get magnetic variation first
cSavedScreen = read_eeprom ( EEPROM_INITIAL ); // restore initial screen
iLastRange = 65535; // make max by default
strcpy ( cToFrom, " " ); // blank by default
cScreenChanged = YES;
cIndicator = 0;
cButtonCount = 0;
cButtonPressed = NO;
cRxErrorFlag = OFF;
 
/* MAIN LOOP */
while ( TRUE )
{
cTimeOut = 188; // 231 * 0.013mS = 3 seconds
switch ( cScreen )
{
case HIDDEN_RMC:
{
InitRxBuffer( GPRMC_CODE ); // set code and turn on serial interrupt
while ( ( cRxMsgReady == NO ) && ( cTimeOut != 0 ) );
disable_interrupts ( INT_RDA ); // ignore rest of messages
if ( cTimeOut != 0 ) // if not timed out
{
GetUtcAndMagVar(); // get and store the magnetic variation
}
cScreen = cSavedScreen; // revert to previous screen
break;
}
case POSITION_SCREEN:
{
if ( cScreenChanged == YES )
{
disable_interrupts ( INT_RDA );
cScreenChanged = NO;
cSkip = NO;
LCD_PutCmd ( CLEAR_DISP );
DisplayTemplateLatLon();
enable_interrupts ( INT_RDA );
}
InitRxBuffer( GPRMC_CODE ); // set code and turn on serial interrupt
while ( ( cRxMsgReady == NO ) && ( cTimeOut != 0 ) && ( cScreenChanged != YES ) );
disable_interrupts ( INT_RDA ); // ignore rest of messages
if ( cScreenChanged == NO )
{
if ( cTimeOut != 0 )
{
DisplayLatLon();
}
else
{
DisplayMessage ( NODATA_MSG );
}
}
cRxErrorFlag = OFF;
break;
}
case WAYPOINT_SCREEN:
{
if ( cScreenChanged == YES )
{
disable_interrupts ( INT_RDA );
cScreenChanged = NO;
cSkip = NO;
LCD_PutCmd ( CLEAR_DISP );
DisplayTemplateWaypoint();
enable_interrupts ( INT_RDA );
}
cSkip = NO;
InitRxBuffer( GPRMB_CODE ); // set code and turn on serial interrupt
while ( ( cRxMsgReady == NO ) && ( cTimeOut != 0 ) && ( cScreenChanged != YES ) );
disable_interrupts ( INT_RDA ); // ignore rest of messages
if ( cScreenChanged == NO )
{
if ( cTimeOut != 0 )
{
DisplayWaypoint();
}
else
{
DisplayMessage ( NODATA_MSG );
}
}
break;
}
case BATTERY_SCREEN:
{
if ( cScreenChanged == YES )
{
disable_interrupts ( INT_RDA );
cScreenChanged = NO;
cSkip = NO;
LCD_PutCmd ( CLEAR_DISP );
DisplayTemplateAnalog();
}
DisplayAnalog();
break;
}
}
 
// Preset timeout counter each loop; RTCC interrupt decrements, resets if zero is reached
iTimeOut = 2000; // ~ 30 seconds
 
/* Flashing activity indicator in lower right of screen. */
cIndicator ^= 1;
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( LINE_4 + 19 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( LINE_4 + 15 );
#endif
if ( cIndicator == 1 )
{
printf ( LCD_PutChar, "%c", ACTIVITY_SYMBOL );
}
else
{
printf ( LCD_PutChar, " " );
}
}
}
 
#separate void DisplayTemplateLatLon ( void )
{
LCD_SetPosition ( LINE_1 );
printf ( LCD_PutChar, "LAT" );
LCD_SetPosition ( LINE_2 );
printf ( LCD_PutChar, "LON" );
LCD_SetPosition ( LINE_3 );
#if ( DISPLAY_COLS == 20 )
printf ( LCD_PutChar, "SPEED" );
LCD_SetPosition ( LINE_4 );
printf ( LCD_PutChar, "HEADING" );
#elif ( DISPLAY_COLS == 16 )
printf ( LCD_PutChar, "SPD" );
LCD_SetPosition ( LINE_4 );
printf ( LCD_PutChar, "HDG" );
#endif
}
 
#separate void DisplayTemplateWaypoint ( void )
{
LCD_SetPosition ( LINE_1 );
#if ( DISPLAY_COLS == 20 )
printf ( LCD_PutChar, "WAYPOINT" );
#elif ( DISPLAY_COLS == 16 )
printf ( LCD_PutChar, "WAYPT" );
#endif
LCD_SetPosition ( LINE_2 );
printf ( LCD_PutChar, "STEER" );
LCD_SetPosition ( LINE_3 );
printf ( LCD_PutChar, "DIST" );
LCD_SetPosition ( LINE_4 );
printf ( LCD_PutChar, "BEARING" );
}
 
#separate void DisplayTemplateAnalog ( void )
{
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( LINE_1 + 3 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( LINE_1 + 1 );
#endif
printf ( LCD_PutChar, "BATTERY STATUS" );
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( LINE_2 );
printf ( LCD_PutChar, "Primary" );
LCD_SetPosition ( LINE_3 );
printf ( LCD_PutChar, "Secondary" );
LCD_SetPosition ( LINE_4 );
printf ( LCD_PutChar, "Refrigerator" );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( LINE_2 );
printf ( LCD_PutChar, "Main#1 " );
LCD_SetPosition ( LINE_3 );
printf ( LCD_PutChar, "Main#2 " );
LCD_SetPosition ( LINE_4 );
printf ( LCD_PutChar, "Refrig " );
#endif
}
 
#separate void DisplayLatLon ( void )
{
SkipField ( 1 ); // skip UTC
GetField(); // A = OK, V = warning
if ( ( cC [ 0 ] == 'A' ) && ( !cSkip ) )
{
GetField(); // LAT
if ( !cSkip )
{
DisplayLatitude ( LINE_1 );
}
GetField(); // LON
if ( !cSkip )
{
DisplayLongitude ( LINE_2 );
}
GetField(); // SPEED
if ( !cSkip )
{
DisplaySpeed ( LINE_3 );
}
GetField(); // HEADING
if ( !cSkip )
{
DisplayHeading ( LINE_4 );
}
}
else
{
DisplayMessage( WARNING_MSG );
}
}
 
#separate void DisplayWaypoint ( void )
{
char cX;
 
GetField(); // A = OK, V = warning
if ( ( cC [ 0 ] == 'A' ) && ( !cSkip ) )
{
cX = GetField(); // XTE
if ( !cSkip )
{
DisplaySteer ( LINE_2, cX );
}
SkipField ( 1 ); // skip origin WP ID
GetField(); // DEST WP ID
if ( !cSkip )
{
DisplayWaypointName ( LINE_1, cX );
}
SkipField ( 4 ); // skip LAT, NS, LON, EW
cX = GetField(); // RANGE
if ( !cSkip )
{
DisplayDistance ( LINE_3, cX );
}
cX = GetField(); // BEARING
if ( !cSkip )
{
DisplayBearing ( LINE_4, cX );
}
SkipField ( 1 ); // skip SPEED TO DEST
GetField(); // ARRIVAL FLAG
if ( !cSkip )
{
DisplayArrival ( LINE_1 ); // overwrite RANGE if arrived
}
}
else
{
DisplayMessage( WARNING_MSG );
}
}
 
#separate void DisplayAnalog ( void )
{
long iX;
char cCnt;
 
set_adc_channel ( 0 ); // set channel
delay_us ( 100 ); // wait aquisition time
cAdcDone = NO;
if ( !cSkip )
{
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( LINE_2 + 13 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( LINE_2 + 8 );
#endif
DisplayScaledVoltage ( read_adc(), MAX_VOLTS );
printf ( LCD_PutChar, " V " );
}
set_adc_channel ( 1 );
delay_us ( 100 );
cAdcDone = NO;
if ( !cSkip )
{
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( LINE_3 + 13 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( LINE_3 + 8 );
#endif
DisplayScaledVoltage ( read_adc(), MAX_VOLTS );
printf ( LCD_PutChar, " V " );
}
set_adc_channel ( 3 );
delay_us ( 100 );
cAdcDone = NO;
if ( !cSkip )
{
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( LINE_4 + 13 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( LINE_4 + 8 );
#endif
DisplayScaledVoltage ( read_adc(), MAX_VOLTS );
printf ( LCD_PutChar, " V " );
}
Delay5mS ( 100 ); // slow loop down a bit
}
 
#separate void GetUtcAndMagVar ( void )
{
/*
This is a non-display version of the RMC sentence
to get the A/V warning, the magnetic variation, and the
magnetic direction.
*/
 
GetField(); // get UTC
GetField(); // A = OK, V = warning
if ( cC [ 0 ] == 'A' )
{
SkipField ( 7 ); // skip fields
GetField(); // MAGNETIC VARIATION
iVar = FieldFiveToLong(); // save to global variable, used in other sentences
GetField(); // EW
cVarDir = cC [ 0 ]; // save direction
}
else
{
iVar = NULL; // invalid
cVarDir = SPACE;
}
}
 
/******************************************************************/
 
#separate void DisplayScaledVoltage ( long iV, char cScale )
{
float fX;
 
/*
0 to 5V input at pin 2 results in 0 - 1023. This routine
scales it to something else.
*/
while ( cAdcDone == NO ); // wait for completion by ADC interrupt
if ( iV == 1023 )
{
printf ( LCD_PutChar, "O/L" ); /* print it to the screen */
}
else
{
fX = ( ( float ) iV ) / 1023 * ( float ) cScale; // scale to proper range, 1023 leaves room for out-of-range
printf ( LCD_PutChar, "%2.1f", fX ); /* print it to the screen */
}
}
 
#separate void DisplayArrival ( char cLine )
{
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( cLine + 11 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( cLine + 9 );
#endif
if ( cC [ 0 ] == 'A' )
{
printf ( LCD_PutChar, "Arrived" );
}
else
{
printf ( LCD_PutChar, " " );
}
}
 
#separate void DisplayWaypointName ( char cLine, char cX )
{
/* Displays waypoint name, pads field with blanks */
char cChar, cI;
 
LCD_SetPosition ( cLine );
if ( cX != 0 )
{
printf ( LCD_PutChar, "\"" );
for ( cI = 0; cI < 6; cI++ )
{
cChar = cC [ cI ];
if ( cChar == EOF )
{
break;
}
printf ( LCD_PutChar, "%c", cChar );
}
printf ( LCD_PutChar, "\"" );
// Blank remainder of field
cChar = SPACE;
for ( ; cI < 6; cI++ )
{
printf ( LCD_PutChar, "%c", cChar );
}
}
else
{
printf ( LCD_PutChar, "- none -" );
}
}
 
#separate void DisplaySteer ( char cLine, char cX )
{
/*
Displays A.BC literals, appends 'L' or 'R'.
If less than 1.0, displays feet rather than nm.
Doesn't display distance if on track.
*/
long iX;
char cCnt;
 
if ( cX != 0 )
{
if ( ( cC [ 0 ] != '0' ) || ( cC [ 2 ] != '0' ) || ( cC [ 3 ] != '0' ) ) // if not 0.00
{
LCD_SetPosition ( cLine + 14 );
#if ( DISPLAY_COLS == 20 )
printf ( LCD_PutChar, " " ); // blank possible characters
LCD_SetPosition ( cLine + 11 );
#elif ( DISPLAY_COLS == 16 )
printf ( LCD_PutChar, " " ); // blank possible characters
LCD_SetPosition ( cLine + 8);
#endif
if ( cC [ 0 ] == '0' ) // if less than 1.0 nm, display as feet
{
iX = ( 528 * ( long ) ( cC [ 2 ] - 0x30 ) ) + ( 52 * ( long ) ( cC [ 3 ] - 0x30 ) );
printf ( LCD_PutChar, "%luft ", iX );
}
else // if 1.0 nm or greater, display as nautical miles
{
printf ( LCD_PutChar, "%c%c%c%cmi ", cC [ 0 ], cC [ 1 ], cC [ 2 ] , cC [ 3 ] );
}
GetField(); // L or R
LCD_SetPosition ( cLine + 6 );
if ( cC [ 0 ] == 'L' )
{
#if ( DISPLAY_COLS == 20 )
printf ( LCD_PutChar, "PORT " );
#elif ( DISPLAY_COLS == 16 )
printf ( LCD_PutChar, "L" );
#endif
}
else
{
#if ( DISPLAY_COLS == 20 )
printf ( LCD_PutChar, "STBD " );
#elif ( DISPLAY_COLS == 16 )
printf ( LCD_PutChar, "R" );
#endif
}
}
else // if 0.00
{
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( cLine + 11 );
printf ( LCD_PutChar, "On track " );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( cLine + 6 );
printf ( LCD_PutChar, " On track" );
#endif
GetField(); // dummy L or R
}
}
else
{
LCD_SetPosition ( cLine + 6 );
printf ( LCD_PutChar, " " );
}
}
 
#separate void DisplayDistance ( char cLine, char cX )
{
/* Format: ABC.D nautical miles */
char cChar, cI;
long iThisRange;
 
if ( cX != 0 ) // if waypoint data to display
{
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( cLine + 11 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( cLine + 8 );
#endif
cI = 0;
for ( cI = 0; cI < 2; cI++ ) // find first non-zero
{
cChar = cC [ cI ];
if ( cChar != '0' )
{
break;
}
}
for ( ; cI < 5; cI++ ) // display from there on
{
printf ( LCD_PutChar, "%c", cC [ cI ] );
}
printf ( LCD_PutChar, "nm " ); // pad with blanks
 
/*
The least significant character from the GPS is 0.1 nm.
Multiply whole thing by 10 and make it type long.
Discern if increasing (FROM) or decreasing (TO).
*/
iThisRange = 1000 * ( long ) ( cC [ 0 ] - 0x30 );
iThisRange += 100 * ( long ) ( cC [ 1 ] - 0x30 );
iThisRange += 10 * ( long ) ( cC [ 2 ] - 0x30 );
iThisRange += ( long ) ( cC [ 4 ] - 0x30 );
if ( iThisRange < iLastRange )
{
#if ( DISPLAY_COLS == 20 )
strcpy ( cToFrom, "TO " );
#elif ( DISPLAY_COLS == 16 )
strcpy ( cToFrom, "TO" );
#endif
}
if ( iThisRange > iLastRange )
{
#if ( DISPLAY_COLS == 20 )
strcpy ( cToFrom, "FROM" );
#elif ( DISPLAY_COLS == 16 )
strcpy ( cToFrom, "FM" );
#endif
}
iLastRange = iThisRange; // save this range to compare next time
LCD_SetPosition ( cLine + 5 );
printf ( LCD_PutChar, cToFrom );
}
else
{
LCD_SetPosition ( cLine + 5 );
#if ( DISPLAY_COLS == 20 )
printf ( LCD_PutChar, " " );
#elif ( DISPLAY_COLS == 16 )
printf ( LCD_PutChar, " " );
#endif
}
}
 
#separate void DisplayBearing ( char cLine, char cX )
{
/*
Compass variation comes from RMC sentence. If RMC has not run yet
then "T" is displayed after bearing.
*/
long iHdg;
char cTrueIndicator;
 
if ( cX != 0 ) // if waypoint data to display
{
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( cLine + 11 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( cLine + 8 );
#endif
iHdg = FieldFiveToLong();
iHdg = TrueToMag ( iHdg ); // factor variation into heading
if ( ( iVar == NULL ) || ( cVarDir == SPACE ) )
{
cTrueIndicator = 'T';
}
else
{
cTrueIndicator = ' ';
}
printf ( LCD_PutChar, "%lu%c%c ", iHdg, DEGREE, cTrueIndicator ); // pad with blanks
}
else
{
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( cLine + 11 );
printf ( LCD_PutChar, " " );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( cLine + 8 );
printf ( LCD_PutChar, " " );
#endif
}
}
 
#separate void DisplayLatitude ( char cLine )
{
/* Displays latitude ABCD.EF as AB CD.EF, appends 'N' or 'S' */
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( cLine + 8 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( cLine + 5 );
#endif
if ( cC [ 0 ] == '0' )
{
cC [ 0 ] = SPACE;
}
printf ( LCD_PutChar, "%c%c%c", cC [ 0 ], cC [ 1 ], DEGREE );
printf ( LCD_PutChar, "%c%c%c%c%c%c", cC [ 2 ], cC [ 3 ], cC [ 4 ], cC [ 5 ], cC [ 6 ], cC [ 7 ] );
GetField(); // NS
printf ( LCD_PutChar, " %c", cC [ 0 ] );
}
 
#separate void DisplayLongitude ( char cLine )
{
/* Displays longitude ABCDE.FG as ABC DE.FG, appends 'E' or 'W' */
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( cLine + 7 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( cLine + 4 );
#endif
if ( cC [ 0 ] == '0' )
{
cC [ 0 ] = SPACE;
}
if ( cC [ 1 ] == '0' )
{
cC [ 1 ] = SPACE;
}
printf ( LCD_PutChar, "%c%c%c%c", cC [ 0 ], cC [ 1 ], cC [ 2 ], DEGREE );
printf ( LCD_PutChar, "%c%c%c%c%c%c", cC [ 3 ], cC [ 4 ], cC [ 5 ], cC [ 6 ], cC [ 7 ], cC [ 8 ] );
GetField(); // EW
printf ( LCD_PutChar, " %c", cC [ 0 ] );
}
 
#separate void DisplaySpeed ( char cLine )
{
float fX;
 
// Format ABC.D
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( cLine + 8 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( cLine + 5 );
#endif
fX = 100 * ( cC [ 0 ] - 0x30 );
fX += 10 * ( cC [ 1 ] - 0x30 );
fX += 1 * ( cC [ 2 ] - 0x30 );
fX += 0.1 * ( cC [ 4 ] - 0x30 );
#if SPEED_UNITS == 2
fX *= 1.852; // convert knots to km/h
#endif
#if SPEED_UNITS == 3
fX *= 1.151; // convert knots to mi/h
#endif
printf ( LCD_PutChar, "%3.1f ", fX ); // print it to the screen
#if SPEED_UNITS == 1
printf ( LCD_PutChar, "kts " ); // print it to the screen
#endif
#if SPEED_UNITS == 2
printf ( LCD_PutChar, "kph " ); // print it to the screen
#endif
#if SPEED_UNITS == 3
printf ( LCD_PutChar, "mph " ); // print it to the screen
#endif
}
 
#separate void DisplayHeading ( char cLine )
{
long iHdg;
 
#if ( DISPLAY_COLS == 20 )
LCD_SetPosition ( cLine + 8 );
#elif ( DISPLAY_COLS == 16 )
LCD_SetPosition ( cLine + 5 );
#endif
iHdg = FieldFiveToLong();
SkipField ( 1 ); // skip fix date
GetField(); // MAGNETIC VARIATION
iVar = FieldFiveToLong(); // save to global variable, used in other sentences
GetField(); // EW
cVarDir = cC [ 0 ]; // save direction
iHdg = TrueToMag ( iHdg ); // factor variation into heading
printf ( LCD_PutChar, "%lu%c ", iHdg, DEGREE ); // pad with blanks
}
 
#separate long FieldFiveToLong ( void )
{
/* Converts ABC.D to long, rounds decimal up or down */
long iX;
 
iX = 100 * ( long ) ( cC [ 0 ] - 0x30 );
iX += 10 * ( long ) ( cC [ 1 ] - 0x30 );
iX += ( long ) ( cC [ 2 ] - 0x30 );
if ( ( cC [ 3 ] == PERIOD ) && ( cC [ 4 ] >= '5' ) )
{
iX++; // round up
}
return ( iX );
}
 
#separate long TrueToMag ( long iH )
{
/* Magnetic variation information comes from the RMC sentence */
 
if ( cVarDir == 'W' )
{
iH += iVar;
}
else
{
if ( iH >= iVar )
{
iH -= iVar; // OK as-is
}
else
{
iH = iH + 360 - iVar; // correct for below zero
}
}
if ( iH >= 360 )
{
iH -= 360;
}
return ( iH );
}
 
#separate void DisplayMessage ( char cMsgNum )
{
LCD_PutCmd ( CLEAR_DISP );
LCD_SetPosition ( LINE_2 );
switch ( cMsgNum )
{
case WARNING_MSG:
{
#if ( DISPLAY_COLS == 20 )
printf ( LCD_PutChar, " GPS warning " );
#elif ( DISPLAY_COLS == 16 )
printf ( LCD_PutChar, " GPS warning" );
#endif
break;
}
case NODATA_MSG:
{
if ( cRxErrorFlag == OFF ) // is it a framing error problem ?
{
#if ( DISPLAY_COLS == 20 )
printf ( LCD_PutChar, " No data from GPS" );
#elif ( DISPLAY_COLS == 16 )
printf ( LCD_PutChar, "No data from GPS" );
#endif
}
else
{
#if ( DISPLAY_COLS == 20 )
printf ( LCD_PutChar, " Baud error" );
#elif ( DISPLAY_COLS == 16 )
printf ( LCD_PutChar, " Baud error" );
#endif
cRxErrorFlag = OFF;
}
break;
}
}
Delay5mS ( 255 ); // delay 1.25 seconds
iVar = NULL;
cVarDir = SPACE; // signal "no magnetic variation" yet
cScreenChanged = YES;
}
 
#separate void Delay5mS ( char cCnt )
{
char cX;
 
/* This variable-count 5mS delay is interruptable by a button press */
for ( cX = 0; cX < cCnt; cX++ )
{
if ( cScreenChanged == YES )
{
break;
}
delay_ms ( 5 );
}
}
 
#separate char GetField ( void )
{
char cX, cIndex;
 
cX = NULL;
cIndex = 0;
while ( !cSkip )
{
cX = GetRxChar();
if ( ( cX == COMMA ) || ( cX == CR ) )
{
break;
}
cC [ cIndex++ ] = cX;
}
cC [ cIndex ] = EOF;
return ( cIndex ); // return number of characters in field
}
 
#separate void SkipField ( char cCnt )
{
char cX;
 
for ( cX = 0; cX < cCnt; cX++ )
{
while ( GetRxChar() != COMMA );
}
}
 
/* RS232 FUNCTIONS ================================================== */
 
#separate void InitRxBuffer ( char cCode )
{
disable_interrupts ( INT_RDA );
cRxBufferWritePtr = cRxBuffer; // point to beginning of buffer
cRxBufferReadPtr = cRxBuffer;
cRxByteCnt = 0;
cRxIsrState = 0;
cRxMsgReady = NO;
cRxMsgTypeDesired = cCode;
enable_interrupts ( INT_RDA );
}
 
#separate char GetRxChar ( void )
{
// Get the next available byte in the recv fifo.
// Call this function ONLY if the recv fifo contains data.
char cValue;
 
cValue = 0;
if ( cRxByteCnt > 0 ) // For safety, check if there is any data
{
cValue = *cRxBufferReadPtr++; // Read byte from fifo
if ( cRxBufferReadPtr == ( cRxBuffer + RX_BUFFER_SIZE ) ) // Did tail ptr wrap ?
{
cRxBufferReadPtr = cRxBuffer; // If so, reset it to start of buffer
}
cRxByteCnt--; // Decrement byte count
}
return ( cValue );
}
 
/* LCD FUNCTIONS ================================= */
 
#separate void LCD_Init ( void )
{
LCD_SetData ( 0x00 );
delay_ms ( 200 ); /* wait enough time after Vdd rise */
output_low ( LCD_RS );
LCD_SetData ( 0x03 ); /* init with specific nibbles to start 4-bit mode */
LCD_PulseEnable();
LCD_PulseEnable();
LCD_PulseEnable();
LCD_SetData ( 0x02 ); /* set 4-bit interface */
LCD_PulseEnable(); /* send dual nibbles hereafter, MSN first */
LCD_PutCmd ( 0x2C ); /* function set (all lines, 5x7 characters) */
LCD_PutCmd ( 0x0C ); /* display ON, cursor off, no blink */
LCD_PutCmd ( 0x01 ); /* clear display */
LCD_PutCmd ( 0x06 ); /* entry mode set, increment & scroll left */
}
 
#separate void LCD_SetPosition ( unsigned int cX )
{
/* this subroutine works specifically for 4-bit Port A */
LCD_SetData ( swap ( cX ) | 0x08 );
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
}
 
#separate void LCD_PutChar ( unsigned int cX )
{
/* this subroutine works specifically for 4-bit Port A */
if ( !cSkip )
{
output_high ( LCD_RS );
LCD_SetData ( swap ( cX ) ); /* send high nibble */
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) ); /* send low nibble */
LCD_PulseEnable();
output_low ( LCD_RS );
}
}
 
#separate void LCD_PutCmd ( unsigned int cX )
{
/* this subroutine works specifically for 4-bit Port A */
LCD_SetData ( swap ( cX ) ); /* send high nibble */
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) ); /* send low nibble */
LCD_PulseEnable();
}
 
#separate void LCD_PulseEnable ( void )
{
output_high ( LCD_EN );
delay_us ( 3 ); // was 10
output_low ( LCD_EN );
delay_ms ( 3 ); // was 5
}
 
#separate void LCD_SetData ( unsigned int cX )
{
output_bit ( LCD_D0, cX & 0x01 );
output_bit ( LCD_D1, cX & 0x02 );
output_bit ( LCD_D2, cX & 0x04 );
output_bit ( LCD_D3, cX & 0x08 );
}