'18LF46k20 8Mhz RX 2XPIC HC-12 AK8963C 271118 1600 PCB TEST
'R= HC-12, G= GPS, A=ALT, C=COMPASS, S=SCREEN. (1 BEGINNING OF SECTION 2 END OF SECTION)
Define CONFIG1L = 0x00
Define CONFIG1H = 0x08 'INT OSC
'Define CONFIG1H = 0x06 'HS OSC PLL EN CLK = 4 X FOSC1 [[[Doesn't work ????]]]
Define CONFIG2L = 0x1e
Define CONFIG2H = 0x00
Define CONFIG3L = 0x00
Define CONFIG3H = 0x81 'Set for HVP
Define CONFIG4L = 0x80
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40
'Define SIMULATION_WAITMS_VALUE = 1 'Comment in for SIM out for PIC
Define CLOCK_FREQUENCY = 32
Define SINGLE_DECIMAL_PLACES = 2
Define STRING_MAX_LENGTH = 70 'Needs setting to fit the whole NMEA or BASE sentence for transmit>>>>>>>>>>
AllDigital
'SET PIN IN/OUT
TRISA = %00000000 '7=XTL 6=XTL 5=0=Slave select
TRISB = %00000000 '7=PGD 6=PGC 543210 OLD SERVOS
TRISC = %10010000 '7=RX=1 6=RX=0 5=SDO 4=SDI=1 3=SCK=0 1=LCD5110 RST=0 0=LCD5110 DATA=1 COMMAND=0
TRISD = %00000011 '7=RX SWITCH 6=CS3 COMPASS 5=CS2 altmtr c/s=0 4=CS1 lcd5110 c/s=0 3=SET HC-12 C/S=0 1=18lf2520 READY 0=18lf2520 ERROR
TRISE = %00000100 '2=Button 1=RlED 0=YLED
'SET BITS ON/OFF
PORTA = %00000000 'ON/OFF
PORTB = %00000000
LATB = 0
PORTC = %00000000
PORTD = %11110000 'ALL C/S HIGH
PORTE = %00000000 'POSS MCLR RE3
WaitMs 10
OSCCON = %01110110
OSCTUNE.PLLEN = 1
'SPI
''Define SPI_CS_REG = PORTD [USED WHEN IN SLAVE MODE]
''Define SPI_CS_BIT = 4[USED WHEN IN SLAVE MODE]
Define SPI_SCK_REG = PORTC
Define SPI_SCK_BIT = 3
Define SPI_SDI_REG = PORTC 'not used, but left in so OSH does not burp
Define SPI_SDI_BIT = 4
Define SPI_SDO_REG = PORTC
Define SPI_SDO_BIT = 5
SPIPrepare
Symbol yled = LATE.0
Symbol rled = LATE.1
main:
PORTA = 255
PORTB = 255
PORTC = 255
PORTD = 255
PORTE = 255
WaitMs 1000
PORTA = 0
PORTB = 0
PORTC = 0
PORTD = 0
PORTE = 0
WaitMs 1000
Goto main