Add files via upload
rodzic
719ce5dc9d
commit
eeda58d760
|
@ -0,0 +1,78 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<MCU_DEVICE_FLAGS>
|
||||||
|
<DEVICE>
|
||||||
|
<DEVICE_NAME>P16F1938</DEVICE_NAME>
|
||||||
|
<DEVICE_CLOCK>16</DEVICE_CLOCK>
|
||||||
|
<SETTINGS>
|
||||||
|
<COUNT>17</COUNT>
|
||||||
|
<SETTING0>
|
||||||
|
<NAME>Oscillator Selection</NAME>
|
||||||
|
<DESCRIPTION>INTOSC oscillator: I/O function on CLKIN pin</DESCRIPTION>
|
||||||
|
</SETTING0>
|
||||||
|
<SETTING1>
|
||||||
|
<NAME>Watchdog Timer Enable</NAME>
|
||||||
|
<DESCRIPTION>Enabled</DESCRIPTION>
|
||||||
|
</SETTING1>
|
||||||
|
<SETTING2>
|
||||||
|
<NAME>Power-up Timer Enable</NAME>
|
||||||
|
<DESCRIPTION>Enabled</DESCRIPTION>
|
||||||
|
</SETTING2>
|
||||||
|
<SETTING3>
|
||||||
|
<NAME>MCLR Pin Function Select</NAME>
|
||||||
|
<DESCRIPTION>Enabled</DESCRIPTION>
|
||||||
|
</SETTING3>
|
||||||
|
<SETTING4>
|
||||||
|
<NAME>Flash Program Memory Code Protection</NAME>
|
||||||
|
<DESCRIPTION>Disabled</DESCRIPTION>
|
||||||
|
</SETTING4>
|
||||||
|
<SETTING5>
|
||||||
|
<NAME>Data Memory Code Protection</NAME>
|
||||||
|
<DESCRIPTION>Disabled</DESCRIPTION>
|
||||||
|
</SETTING5>
|
||||||
|
<SETTING6>
|
||||||
|
<NAME>Brown-out Reset Enable</NAME>
|
||||||
|
<DESCRIPTION>Enabled</DESCRIPTION>
|
||||||
|
</SETTING6>
|
||||||
|
<SETTING7>
|
||||||
|
<NAME>Clock Out Enable</NAME>
|
||||||
|
<DESCRIPTION>Disabled</DESCRIPTION>
|
||||||
|
</SETTING7>
|
||||||
|
<SETTING8>
|
||||||
|
<NAME>Internal/External Switchover</NAME>
|
||||||
|
<DESCRIPTION>Enabled</DESCRIPTION>
|
||||||
|
</SETTING8>
|
||||||
|
<SETTING9>
|
||||||
|
<NAME>Fail-Safe Clock Monitor Enable</NAME>
|
||||||
|
<DESCRIPTION>Enabled</DESCRIPTION>
|
||||||
|
</SETTING9>
|
||||||
|
<SETTING10>
|
||||||
|
<NAME>Flash Memory Self-Write Protection</NAME>
|
||||||
|
<DESCRIPTION>Disabled</DESCRIPTION>
|
||||||
|
</SETTING10>
|
||||||
|
<SETTING11>
|
||||||
|
<NAME>Voltage Regulator Capacitor Enable</NAME>
|
||||||
|
<DESCRIPTION>Disabled</DESCRIPTION>
|
||||||
|
</SETTING11>
|
||||||
|
<SETTING12>
|
||||||
|
<NAME>PLL Enable</NAME>
|
||||||
|
<DESCRIPTION>Disabled</DESCRIPTION>
|
||||||
|
</SETTING12>
|
||||||
|
<SETTING13>
|
||||||
|
<NAME>Stack Overflow/Underflow Reset Enable</NAME>
|
||||||
|
<DESCRIPTION>Enabled</DESCRIPTION>
|
||||||
|
</SETTING13>
|
||||||
|
<SETTING14>
|
||||||
|
<NAME>Brown-out Reset Voltage Selection</NAME>
|
||||||
|
<DESCRIPTION>Brown-out Reset Voltage (Vbor), high trip point selected.</DESCRIPTION>
|
||||||
|
</SETTING14>
|
||||||
|
<SETTING15>
|
||||||
|
<NAME>In-Circuit Debugger Mode</NAME>
|
||||||
|
<DESCRIPTION>Disabled</DESCRIPTION>
|
||||||
|
</SETTING15>
|
||||||
|
<SETTING16>
|
||||||
|
<NAME>Low-Voltage Programming Enable</NAME>
|
||||||
|
<DESCRIPTION>Disabled</DESCRIPTION>
|
||||||
|
</SETTING16>
|
||||||
|
</SETTINGS>
|
||||||
|
</DEVICE>
|
||||||
|
</MCU_DEVICE_FLAGS>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<MCU_DEVICE_FLAGS>
|
||||||
|
<DEVICE>
|
||||||
|
<DEVICE_NAME>P16F1938</DEVICE_NAME>
|
||||||
|
<VALUE>
|
||||||
|
<COUNT>2</COUNT>
|
||||||
|
<VALUE0>
|
||||||
|
<VAL>$008007:$3FDC</VAL>
|
||||||
|
</VALUE0>
|
||||||
|
<VALUE1>
|
||||||
|
<VAL>$008008:$1233</VAL>
|
||||||
|
</VALUE1>
|
||||||
|
</VALUE>
|
||||||
|
</DEVICE>
|
||||||
|
</MCU_DEVICE_FLAGS>
|
Plik binarny nie jest wyświetlany.
Plik diff jest za duży
Load Diff
Plik binarny nie jest wyświetlany.
|
@ -0,0 +1,34 @@
|
||||||
|
:020000040001F9
|
||||||
|
:10E000004E00010000001500130005000000010093
|
||||||
|
:10E01000020000001000FF00FF00FF00FF00FF00F3
|
||||||
|
:10E020000100100002002000040050001000000059
|
||||||
|
:10E0300022000000FF00FF00FF00FF00FF00FF00C4
|
||||||
|
:10E040000000100000002200000047000100000056
|
||||||
|
:10E0500002002000FF00FF00FF00FF00FF00FF00A4
|
||||||
|
:10E06000000001000000FF00FF00FF00FF00FF00B4
|
||||||
|
:10E07000FF00FF00FF00FF00FF00FF00FF00FF00A8
|
||||||
|
:10E08000FF00FF00FF00FF00FF00FF00FF00FF0098
|
||||||
|
:10E09000FF00FF00FF00FF00FF00FF00FF00FF0088
|
||||||
|
:10E0A000FF00FF00FF00FF00FF00FF00FF00FF0078
|
||||||
|
:10E0B000FF00FF00FF00FF00FF00FF00FF00FF0068
|
||||||
|
:10E0C000FF00FF00FF00FF00FF00FF00FF00FF0058
|
||||||
|
:10E0D000FF00FF00FF00FF00FF00FF00FF00FF0048
|
||||||
|
:10E0E000FF00FF00FF00FF00FF00FF00FF00FF0038
|
||||||
|
:10E0F000FF00FF00FF00FF00FF00FF00FF00FF0028
|
||||||
|
:10E10000FF00FF00FF00FF00FF00FF00FF00FF0017
|
||||||
|
:10E11000FF00FF00FF00FF00FF00FF00FF00FF0007
|
||||||
|
:10E12000FF00FF00FF00FF00FF00FF00FF00FF00F7
|
||||||
|
:10E13000FF00FF00FF00FF00FF00FF00FF00FF00E7
|
||||||
|
:10E14000FF00FF00FF00FF00FF00FF00FF00FF00D7
|
||||||
|
:10E15000FF00FF00FF00FF00FF00FF00FF00FF00C7
|
||||||
|
:10E16000FF00FF00FF00FF00FF00FF00FF00FF00B7
|
||||||
|
:10E17000FF00FF00FF00FF00FF00FF00FF00FF00A7
|
||||||
|
:10E18000FF00FF00FF00FF00FF00FF00FF00FF0097
|
||||||
|
:10E19000FF00FF00FF00FF00FF00FF00FF00FF0087
|
||||||
|
:10E1A000FF00FF00FF00FF00FF00FF00FF00FF0077
|
||||||
|
:10E1B000FF00FF00FF00FF00FF00FF00FF00FF0067
|
||||||
|
:10E1C000FF00FF00FF00FF00FF00FF00FF00FF0057
|
||||||
|
:10E1D000FF00FF00FF00FF00FF00FF00FF00FF0047
|
||||||
|
:10E1E000FF00FF00FF00FF00FF00FF00FF00FF0037
|
||||||
|
:10E1F000FF00FF00FF00FF00FF0001000000000023
|
||||||
|
:00000001FF
|
|
@ -0,0 +1,15 @@
|
||||||
|
0 1 mikroCPIC1618.exe -MSF -DBG -pP16F1938 -DL -O11111114 -fo16 -EH"E:\ATU-100\fw_mini\1938_mini_board_sources_V_3.1\atu_100_fw_00.ihex" -N"E:\ATU-100\fw_mini\1938_mini_board_sources_V_3.1\atu_100_fw_00.mcppi" -SP"D:\UserData\z00453wn\Documents\Mikroelektronika\mikroC PRO for PIC\Defs\" -SP"D:\UserData\z00453wn\Documents\Mikroelektronika\mikroC PRO for PIC\Uses\P16_Enh\" -SP"E:\ATU-100\fw_mini\1938_mini_board_sources_V_3.1\" -IP"D:\UserData\z00453wn\Documents\Mikroelektronika\mikroC PRO for PIC\Uses\P16_Enh\" "pic_init.c" "oled_control.c" "main.c" "__Lib_Math.mcl" "__Lib_MathDouble.mcl" "__Lib_System.mcl" "__Lib_Delays.mcl" "__Lib_Conversions.mcl" "__Lib_Button.mcl" "__Lib_ADC.mcl" "__Lib_EEPROM.mcl"
|
||||||
|
hint: 0 1139 Available RAM: 1016 [bytes], Available ROM: 16384 [bytes]
|
||||||
|
diagnostics: 0 122 Compilation Started pic_init.c
|
||||||
|
diagnostics: 47 123 Compiled Successfully pic_init.c
|
||||||
|
diagnostics: 0 122 Compilation Started oled_control.h
|
||||||
|
diagnostics: 406 123 Compiled Successfully oled_control.c
|
||||||
|
diagnostics: 0 122 Compilation Started oled_control.h
|
||||||
|
diagnostics: 859 123 Compiled Successfully main.c
|
||||||
|
diagnostics: 0 127 All files Compiled in 1000 ms
|
||||||
|
hint: 0 1144 Used RAM (bytes): 796 (78%) Free RAM (bytes): 220 (22%) Used RAM (bytes): 796 (78%) Free RAM (bytes): 220 (22%)
|
||||||
|
hint: 0 1144 Used ROM (program words): 14114 (86%) Free ROM (program words): 2270 (14%) Used ROM (program words): 14114 (86%) Free ROM (program words): 2270 (14%)
|
||||||
|
diagnostics: 0 125 Project Linked Successfully atu_100_fw_00.mcppi
|
||||||
|
diagnostics: 0 128 Linked in 235 ms
|
||||||
|
diagnostics: 0 129 Project 'atu_100_fw_00.mcppi' completed: 1297 ms
|
||||||
|
diagnostics: 0 103 Finished successfully: 04 Nov 2020, 15:40:30 atu_100_fw_00.mcppi
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,68 @@
|
||||||
|
[DEVICE]
|
||||||
|
Name=P16F1938
|
||||||
|
Clock=16000000
|
||||||
|
[MEMORY_MODEL]
|
||||||
|
Value=0
|
||||||
|
[BUILD_TYPE]
|
||||||
|
Value=0
|
||||||
|
[ACTIVE_TAB]
|
||||||
|
Value=main.c
|
||||||
|
[USE_EEPROM]
|
||||||
|
Value=1
|
||||||
|
[EEPROM_DEFINITION]
|
||||||
|
Value=
|
||||||
|
[USE_HEAP]
|
||||||
|
Value=0
|
||||||
|
[HEAP_SIZE]
|
||||||
|
Value=2000
|
||||||
|
[FILES]
|
||||||
|
File0=pic_init.c
|
||||||
|
File1=oled_control.c
|
||||||
|
File2=main.c
|
||||||
|
Count=3
|
||||||
|
[BINARIES]
|
||||||
|
Count=0
|
||||||
|
[IMAGES]
|
||||||
|
Count=0
|
||||||
|
ActiveImageIndex=-1
|
||||||
|
[OPENED_FILES]
|
||||||
|
File0=main.h
|
||||||
|
File1=oled_control.c
|
||||||
|
File2=oled_control.h
|
||||||
|
File3=main.c
|
||||||
|
File4=pic_init.c
|
||||||
|
File5=pic_init.h
|
||||||
|
Count=6
|
||||||
|
[EEPROM]
|
||||||
|
File0=atu_100_fw_00.ihex
|
||||||
|
Count=1
|
||||||
|
[ACTIVE_COMMENTS_FILES]
|
||||||
|
Count=0
|
||||||
|
[OTHER_FILES]
|
||||||
|
Count=0
|
||||||
|
[SEARCH_PATH]
|
||||||
|
Count=0
|
||||||
|
[HEADER_PATH]
|
||||||
|
Count=0
|
||||||
|
[HEADERS]
|
||||||
|
File0=main.h
|
||||||
|
File1=oled_control.h
|
||||||
|
File2=pic_init.h
|
||||||
|
Count=3
|
||||||
|
[PLDS]
|
||||||
|
Count=0
|
||||||
|
[Useses]
|
||||||
|
File0=ADC
|
||||||
|
File1=Conversions
|
||||||
|
File2=Button
|
||||||
|
File3=EEPROM
|
||||||
|
Count=4
|
||||||
|
[EXPANDED_NODES]
|
||||||
|
Count=0
|
||||||
|
[LIB_EXPANDED_NODES]
|
||||||
|
0=mikroE Libraries
|
||||||
|
1=System Libraries
|
||||||
|
30=Conversions
|
||||||
|
126=EEPROM
|
||||||
|
162=FLASH
|
||||||
|
Count=6
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Bookmarks]
|
||||||
|
Count=0
|
||||||
|
[Position]
|
||||||
|
Line=3
|
||||||
|
Column=1
|
||||||
|
[BreakPoints]
|
||||||
|
Count=0
|
||||||
|
[FoldedLines]
|
||||||
|
Count=0
|
Plik binarny nie jest wyświetlany.
|
@ -0,0 +1,100 @@
|
||||||
|
static const char font5x8[] = {
|
||||||
|
//
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,// (space)
|
||||||
|
0x00, 0x00, 0x5F, 0x00, 0x00,// !
|
||||||
|
0x00, 0x07, 0x00, 0x07, 0x00,// "
|
||||||
|
0x14, 0x7F, 0x14, 0x7F, 0x14,// #
|
||||||
|
0x24, 0x2A, 0x7F, 0x2A, 0x12,// $
|
||||||
|
0x23, 0x13, 0x08, 0x64, 0x62,// %
|
||||||
|
0x36, 0x49, 0x55, 0x22, 0x50,// &
|
||||||
|
0x00, 0x05, 0x03, 0x00, 0x00,// '
|
||||||
|
0x00, 0x1C, 0x22, 0x41, 0x00,// (
|
||||||
|
0x00, 0x41, 0x22, 0x1C, 0x00,// )
|
||||||
|
0x08, 0x2A, 0x1C, 0x2A, 0x08,// *
|
||||||
|
0x08, 0x08, 0x3E, 0x08, 0x08,// +
|
||||||
|
0x00, 0x50, 0x30, 0x00, 0x00,// ,
|
||||||
|
0x08, 0x08, 0x08, 0x08, 0x08,// -
|
||||||
|
0x00, 0x30, 0x30, 0x00, 0x00,// .
|
||||||
|
0x20, 0x10, 0x08, 0x04, 0x02,// /
|
||||||
|
0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
|
||||||
|
0x00, 0x42, 0x7F, 0x40, 0x00,// 1
|
||||||
|
0x42, 0x61, 0x51, 0x49, 0x46,// 2
|
||||||
|
0x21, 0x41, 0x45, 0x4B, 0x31,// 3
|
||||||
|
0x18, 0x14, 0x12, 0x7F, 0x10,// 4
|
||||||
|
0x27, 0x45, 0x45, 0x45, 0x39,// 5
|
||||||
|
0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
|
||||||
|
0x01, 0x71, 0x09, 0x05, 0x03,// 7
|
||||||
|
0x36, 0x49, 0x49, 0x49, 0x36,// 8
|
||||||
|
0x06, 0x49, 0x49, 0x29, 0x1E,// 9
|
||||||
|
0x00, 0x36, 0x36, 0x00, 0x00,// :
|
||||||
|
0x00, 0x56, 0x36, 0x00, 0x00,// ;
|
||||||
|
0x00, 0x08, 0x14, 0x22, 0x41,// <
|
||||||
|
0x14, 0x14, 0x14, 0x14, 0x14,// =
|
||||||
|
0x41, 0x22, 0x14, 0x08, 0x00,// >
|
||||||
|
0x02, 0x01, 0x51, 0x09, 0x06,// ?
|
||||||
|
0x32, 0x49, 0x79, 0x41, 0x3E,// @
|
||||||
|
0x7E, 0x11, 0x11, 0x11, 0x7E,// A
|
||||||
|
0x7F, 0x49, 0x49, 0x49, 0x36,// B
|
||||||
|
0x3E, 0x41, 0x41, 0x41, 0x22,// C
|
||||||
|
0x7F, 0x41, 0x41, 0x22, 0x1C,// D
|
||||||
|
0x7F, 0x49, 0x49, 0x49, 0x41,// E
|
||||||
|
0x7F, 0x09, 0x09, 0x01, 0x01,// F
|
||||||
|
0x3E, 0x41, 0x41, 0x51, 0x32,// G
|
||||||
|
0x7F, 0x08, 0x08, 0x08, 0x7F,// H
|
||||||
|
0x00, 0x41, 0x7F, 0x41, 0x00,// I
|
||||||
|
0x20, 0x40, 0x41, 0x3F, 0x01,// J
|
||||||
|
0x7F, 0x08, 0x14, 0x22, 0x41,// K
|
||||||
|
0x7F, 0x40, 0x40, 0x40, 0x40,// L
|
||||||
|
0x7F, 0x02, 0x04, 0x02, 0x7F,// M
|
||||||
|
0x7F, 0x04, 0x08, 0x10, 0x7F,// N
|
||||||
|
0x3E, 0x41, 0x41, 0x41, 0x3E,// O
|
||||||
|
0x7F, 0x09, 0x09, 0x09, 0x06,// P
|
||||||
|
0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
|
||||||
|
0x7F, 0x09, 0x19, 0x29, 0x46,// R
|
||||||
|
0x46, 0x49, 0x49, 0x49, 0x31,// S
|
||||||
|
0x01, 0x01, 0x7F, 0x01, 0x01,// T
|
||||||
|
0x3F, 0x40, 0x40, 0x40, 0x3F,// U
|
||||||
|
0x1F, 0x20, 0x40, 0x20, 0x1F,// V
|
||||||
|
0x7F, 0x20, 0x18, 0x20, 0x7F,// W
|
||||||
|
0x63, 0x14, 0x08, 0x14, 0x63,// X
|
||||||
|
0x03, 0x04, 0x78, 0x04, 0x03,// Y
|
||||||
|
0x61, 0x51, 0x49, 0x45, 0x43,// Z
|
||||||
|
0x00, 0x00, 0x7F, 0x41, 0x41,// [
|
||||||
|
0x02, 0x04, 0x08, 0x10, 0x20,// "\"
|
||||||
|
0x41, 0x41, 0x7F, 0x00, 0x00,// ]
|
||||||
|
0x04, 0x02, 0x01, 0x02, 0x04,// ^
|
||||||
|
0x40, 0x40, 0x40, 0x40, 0x40,// _
|
||||||
|
0x00, 0x01, 0x02, 0x04, 0x00,// `
|
||||||
|
0x20, 0x54, 0x54, 0x54, 0x78,// a
|
||||||
|
0x7F, 0x48, 0x44, 0x44, 0x38,// b
|
||||||
|
0x38, 0x44, 0x44, 0x44, 0x20,// c
|
||||||
|
0x38, 0x44, 0x44, 0x48, 0x7F,// d
|
||||||
|
0x38, 0x54, 0x54, 0x54, 0x18,// e
|
||||||
|
0x08, 0x7E, 0x09, 0x01, 0x02,// f
|
||||||
|
0x08, 0x14, 0x54, 0x54, 0x3C,// g
|
||||||
|
0x7F, 0x08, 0x04, 0x04, 0x78,// h
|
||||||
|
0x00, 0x44, 0x7D, 0x40, 0x00,// i
|
||||||
|
0x20, 0x40, 0x44, 0x3D, 0x00,// j
|
||||||
|
0x00, 0x7F, 0x10, 0x28, 0x44,// k
|
||||||
|
0x00, 0x41, 0x7F, 0x40, 0x00,// l
|
||||||
|
0x7C, 0x04, 0x18, 0x04, 0x78,// m
|
||||||
|
0x7C, 0x08, 0x04, 0x04, 0x78,// n
|
||||||
|
0x38, 0x44, 0x44, 0x44, 0x38,// o
|
||||||
|
0x7C, 0x14, 0x14, 0x14, 0x08,// p
|
||||||
|
0x08, 0x14, 0x14, 0x18, 0x7C,// q
|
||||||
|
0x7C, 0x08, 0x04, 0x04, 0x08,// r
|
||||||
|
0x48, 0x54, 0x54, 0x54, 0x20,// s
|
||||||
|
0x04, 0x3F, 0x44, 0x40, 0x20,// t
|
||||||
|
0x3C, 0x40, 0x40, 0x20, 0x7C,// u
|
||||||
|
0x1C, 0x20, 0x40, 0x20, 0x1C,// v
|
||||||
|
0x3C, 0x40, 0x30, 0x40, 0x3C,// w
|
||||||
|
0x44, 0x28, 0x10, 0x28, 0x44,// x
|
||||||
|
0x0C, 0x50, 0x50, 0x50, 0x3C,// y
|
||||||
|
0x44, 0x64, 0x54, 0x4C, 0x44,// z
|
||||||
|
0x00, 0x08, 0x36, 0x41, 0x00,// {
|
||||||
|
0x00, 0x00, 0x7F, 0x00, 0x00,// |
|
||||||
|
0x00, 0x41, 0x36, 0x08, 0x00,// }
|
||||||
|
0x08, 0x08, 0x2A, 0x1C, 0x08,// ->
|
||||||
|
0x08, 0x1C, 0x2A, 0x08, 0x08 // <-
|
||||||
|
};
|
||||||
|
//
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Bookmarks]
|
||||||
|
Count=0
|
||||||
|
[Position]
|
||||||
|
Line=19
|
||||||
|
Column=43
|
||||||
|
[BreakPoints]
|
||||||
|
Count=0
|
||||||
|
[FoldedLines]
|
||||||
|
Count=0
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,860 @@
|
||||||
|
// ATU-100 project
|
||||||
|
// David Fainitski
|
||||||
|
// 2016
|
||||||
|
|
||||||
|
#include "oled_control.h"
|
||||||
|
#include "pic_init.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
int SWR_fixed = 0, SWR_fixed_old = 0, Power, work_int;
|
||||||
|
char work_char, work_str[7], work_str_2[7];
|
||||||
|
float Forward;
|
||||||
|
int Power_old = 10000;
|
||||||
|
int SWR_old = 10000;
|
||||||
|
char m_nibble = 0, l_nibble = 0;
|
||||||
|
char type, Soft_tune = 0, Auto = 0, Track = 0;
|
||||||
|
char bypas = 0, cap_mem = 0, ind_mem = 0, SW_mem = 0, Auto_mem = 0;
|
||||||
|
int Auto_delta;
|
||||||
|
char Restart = 0, Test = 0, lcd_prep_short = 0;
|
||||||
|
char L = 1, but = 0;
|
||||||
|
int Cap1, Cap2, Cap3, Cap4, Cap5;
|
||||||
|
int Ind1, Ind2, Ind3, Ind4, Ind5;
|
||||||
|
char Dysp_delay = 0;
|
||||||
|
int dysp_cnt = 0;
|
||||||
|
float dysp_cnt_mult = 2.3;
|
||||||
|
char Loss_mode = 0, Fid_loss;
|
||||||
|
|
||||||
|
/*
|
||||||
|
void interrupt () {
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
if(STATUS.B4==0) Restart = 1;
|
||||||
|
pic_init();
|
||||||
|
//
|
||||||
|
Delay_ms (300);
|
||||||
|
asm CLRWDT;
|
||||||
|
cells_init();
|
||||||
|
Soft_I2C_Init();
|
||||||
|
if(type==0) { // 2-colors led reset
|
||||||
|
LATB.B6 = 1;
|
||||||
|
LATB.B7 = 1;
|
||||||
|
}
|
||||||
|
else if(type==6){
|
||||||
|
LATB.B6 = 0;
|
||||||
|
LATB.B7 = 0;
|
||||||
|
}
|
||||||
|
Low = 0;
|
||||||
|
Mid = 0;
|
||||||
|
High = 0;
|
||||||
|
dysp_cnt = Dysp_delay * dysp_cnt_mult;
|
||||||
|
//
|
||||||
|
Delay_ms(300);
|
||||||
|
asm CLRWDT;
|
||||||
|
if(PORTB.B4==0 & PORTB.B5==0) { // Test mode
|
||||||
|
Test = 1;
|
||||||
|
Auto = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Delay_ms(300);
|
||||||
|
asm CLRWDT;
|
||||||
|
|
||||||
|
led_init();
|
||||||
|
if(PORTB.B4==0 & PORTB.B5==0 & PORTB.B0==0) { // Fast Test mode (loop)
|
||||||
|
if(type==4 | type==5) led_wr_str (0, 12, "FAST TEST", 9); // 128*64
|
||||||
|
else if(type!=0) led_wr_str (0, 3, "FAST TEST", 9); // 1602 | 128*32
|
||||||
|
set_cap(255);
|
||||||
|
set_ind(255);
|
||||||
|
set_sw(1);
|
||||||
|
asm CLRWDT;
|
||||||
|
while(1) {Delay_ms(500);asm CLRWDT;}
|
||||||
|
}
|
||||||
|
asm CLRWDT;
|
||||||
|
//
|
||||||
|
if(Button(&PORTB, 0, 100, 0)) { // Fider loss input
|
||||||
|
if(type==4 | type==5) { led_wr_str (0, 6, "Fider Loss", 10); // 128*64
|
||||||
|
led_wr_str (1, 6, "input", 5); }
|
||||||
|
else if(type!=0) led_wr_str (0, 0, "Fider Loss input", 16); // 1602 | 128*32
|
||||||
|
Fid_loss = Bcd2Dec(EEPROM_Read(0x32));
|
||||||
|
show_loss();
|
||||||
|
//
|
||||||
|
while(1) {
|
||||||
|
if(Button(&PORTB, 5, 50, 0)){ // BYP button
|
||||||
|
if(Fid_loss<99) {
|
||||||
|
Fid_loss ++;
|
||||||
|
show_loss();
|
||||||
|
EEPROM_Write(0x32, Dec2Bcd(Fid_loss));
|
||||||
|
}
|
||||||
|
while(Button(&PORTB, 5, 50, 0)) asm CLRWDT;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if(Button(&PORTB, 4, 50, 0)){ // AUTO button
|
||||||
|
if(Fid_loss>0) {
|
||||||
|
Fid_loss --;
|
||||||
|
show_loss();
|
||||||
|
EEPROM_Write(0x32, Dec2Bcd(Fid_loss));
|
||||||
|
}
|
||||||
|
while(Button(&PORTB, 4, 50, 0)) asm CLRWDT;
|
||||||
|
}
|
||||||
|
asm CLRWDT;
|
||||||
|
} // while
|
||||||
|
} // Fider loss input
|
||||||
|
//
|
||||||
|
if(Test==0) {
|
||||||
|
cap = EEPROM_Read(255);
|
||||||
|
ind = EEPROM_Read(254);
|
||||||
|
SW = EEPROM_Read(253);
|
||||||
|
swr_a = EEPROM_Read(252) * 256;
|
||||||
|
swr_a += EEPROM_Read(251);
|
||||||
|
set_ind(ind);
|
||||||
|
set_cap(cap);
|
||||||
|
set_sw(SW);
|
||||||
|
if(Restart==1 ) lcd_prep_short = 1;
|
||||||
|
lcd_prep();
|
||||||
|
}
|
||||||
|
else Test_init();
|
||||||
|
|
||||||
|
lcd_ind();
|
||||||
|
|
||||||
|
//*******************************
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
asm CLRWDT;
|
||||||
|
lcd_pwr();
|
||||||
|
//
|
||||||
|
if(Test==0) button_proc();
|
||||||
|
else button_proc_test();
|
||||||
|
//
|
||||||
|
if(dysp_cnt!=0) dysp_cnt --;
|
||||||
|
else if(Test==0 & Dysp_delay!=0) dysp_off();
|
||||||
|
|
||||||
|
// next While code
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//***************** Routines *****************
|
||||||
|
|
||||||
|
void button_proc_test(void) {
|
||||||
|
if(Button(&PORTB, 0, 50, 0)){ // Tune btn
|
||||||
|
Delay_ms(250);
|
||||||
|
asm CLRWDT;
|
||||||
|
if(PORTB.B0==1) { // short press button
|
||||||
|
if(SW==0) SW = 1; else SW = 0;
|
||||||
|
set_sw(SW);
|
||||||
|
lcd_ind();
|
||||||
|
}
|
||||||
|
else { // long press button
|
||||||
|
if(L==1) L = 0; else L = 1;
|
||||||
|
if(L==1) {
|
||||||
|
if(type==4 |type==5) // 128*64 OLED
|
||||||
|
led_wr_str (0, 16+12*8, "l", 1);
|
||||||
|
else if(type!=0 & type!=6) // 1602 LCD & 128*32 OLED
|
||||||
|
led_wr_str (0, 8, "l", 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(type==4 |type==5) // 128*64 OLED
|
||||||
|
led_wr_str (0, 16+12*8, "c", 1);
|
||||||
|
else if(type!=0 & type !=6) // 1602 LCD & 128*32 OLED
|
||||||
|
led_wr_str (0, 8, "c", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while(Button(&PORTB, 0, 50, 0)) {lcd_pwr(); asm CLRWDT; }
|
||||||
|
} // END Tune btn
|
||||||
|
//
|
||||||
|
if(Button(&PORTB, 5, 50, 0)){ // BYP button
|
||||||
|
asm CLRWDT;
|
||||||
|
while(PORTB.B5==0) {
|
||||||
|
if(L & ind<31) {
|
||||||
|
ind ++;
|
||||||
|
set_ind(ind);
|
||||||
|
}
|
||||||
|
else if(!L & cap<31) {
|
||||||
|
cap ++;
|
||||||
|
set_cap(cap);
|
||||||
|
}
|
||||||
|
lcd_ind();
|
||||||
|
lcd_pwr();
|
||||||
|
Delay_ms(30);
|
||||||
|
asm CLRWDT;
|
||||||
|
}
|
||||||
|
} // end of BYP button
|
||||||
|
//
|
||||||
|
if(Button(&PORTB, 4, 50, 0) & Bypas==0){ // Auto button
|
||||||
|
asm CLRWDT;
|
||||||
|
while(PORTB.B4==0) {
|
||||||
|
if(L & ind>0) {
|
||||||
|
ind --;
|
||||||
|
set_ind(ind);
|
||||||
|
}
|
||||||
|
else if(!L & cap>0) {
|
||||||
|
cap --;
|
||||||
|
set_cap(cap);
|
||||||
|
}
|
||||||
|
lcd_ind();
|
||||||
|
lcd_pwr();
|
||||||
|
Delay_ms(30);
|
||||||
|
asm CLRWDT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void button_proc(void) {
|
||||||
|
if(Button(&PORTB, 0, 50, 0) | Soft_tune){
|
||||||
|
dysp_on();
|
||||||
|
dysp_cnt = Dysp_delay * dysp_cnt_mult;
|
||||||
|
Delay_ms(250);
|
||||||
|
asm CLRWDT;
|
||||||
|
if(Soft_tune == 0 & PORTB.B0==1) { // short press button
|
||||||
|
show_reset();
|
||||||
|
bypas =0;
|
||||||
|
}
|
||||||
|
else { // long press button
|
||||||
|
p_Tx = 1; //
|
||||||
|
n_Tx = 0; // TX request
|
||||||
|
asm CLRWDT;
|
||||||
|
Delay_ms(250); //
|
||||||
|
asm CLRWDT;
|
||||||
|
btn_push();
|
||||||
|
bypas = 0;
|
||||||
|
while(Button(&PORTB, 0, 50, 0)) {lcd_pwr(); asm CLRWDT; }
|
||||||
|
Soft_tune = 0;
|
||||||
|
}
|
||||||
|
//if(Loss_ind==0) lcd_ind();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if(Button(&PORTB, 5, 50, 0)){ // BYP button
|
||||||
|
dysp_on();
|
||||||
|
dysp_cnt = Dysp_delay * dysp_cnt_mult;
|
||||||
|
asm CLRWDT;
|
||||||
|
if(bypas == 0) {
|
||||||
|
bypas = 1;
|
||||||
|
cap_mem = cap;
|
||||||
|
ind_mem = ind;
|
||||||
|
SW_mem = SW;
|
||||||
|
cap = 0;
|
||||||
|
ind = 0;
|
||||||
|
SW = 1;
|
||||||
|
set_ind(ind);
|
||||||
|
set_cap(cap);
|
||||||
|
set_SW(SW);
|
||||||
|
if(Loss_mode==0) lcd_ind();
|
||||||
|
Auto_mem = Auto;
|
||||||
|
Auto = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bypas = 0;
|
||||||
|
cap = cap_mem;
|
||||||
|
ind = ind_mem;
|
||||||
|
SW = SW_mem;
|
||||||
|
set_cap(cap);
|
||||||
|
set_ind(ind);
|
||||||
|
set_SW(SW);
|
||||||
|
if(Loss_mode==0) lcd_ind();
|
||||||
|
Auto = Auto_mem;
|
||||||
|
}
|
||||||
|
if(type==4 | type==5) { // 128*64 OLED
|
||||||
|
if(Auto & !Bypas) led_wr_str (0, 16+8*12, ".", 1);
|
||||||
|
else if(!Auto & Bypas) led_wr_str (0, 16+8*12, "_", 1);
|
||||||
|
else led_wr_str (0, 16+8*12, " ", 1);
|
||||||
|
}
|
||||||
|
else if(type!=0 & type!=6) { // 1602 LCD or 128*32 OLED
|
||||||
|
if(Auto & !Bypas) led_wr_str (0, 8, ".", 1);
|
||||||
|
else if(!Auto & Bypas) led_wr_str (0, 8, "_", 1);
|
||||||
|
else led_wr_str (0, 8, " ", 1);
|
||||||
|
}
|
||||||
|
while(Button(&PORTB, 5, 50, 0)) {lcd_pwr(); asm CLRWDT; }
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if(Button(&PORTB, 4, 50, 0) & Bypas==0){ // Auto button
|
||||||
|
dysp_on();
|
||||||
|
dysp_cnt = Dysp_delay * dysp_cnt_mult;
|
||||||
|
asm CLRWDT;
|
||||||
|
if(Auto == 0) Auto = 1;
|
||||||
|
else Auto = 0;
|
||||||
|
EEPROM_Write(2, Auto);
|
||||||
|
if(type==4 | type==5) { // 128*64 OLED
|
||||||
|
if(Auto & !Bypas) led_wr_str (0, 16+8*12, ".", 1);
|
||||||
|
else if(!Auto & Bypas) led_wr_str (0, 16+8*12, "_", 1);
|
||||||
|
else led_wr_str (0, 16+8*12, " ", 1);
|
||||||
|
}
|
||||||
|
else if(type!=0 & type!=6) { // 1602 LCD or 128*32 OLED
|
||||||
|
if(Auto & !Bypas) led_wr_str (0, 8, ".", 1);
|
||||||
|
else if(!Auto & Bypas) led_wr_str (0, 8, "_", 1);
|
||||||
|
else led_wr_str (0, 8, " ", 1);
|
||||||
|
}
|
||||||
|
while(Button(&PORTB, 4, 50, 0)) {lcd_pwr(); asm CLRWDT; }
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void show_reset() {
|
||||||
|
asm CLRWDT;
|
||||||
|
atu_reset();
|
||||||
|
SW = 1;
|
||||||
|
set_sw(SW);
|
||||||
|
EEPROM_Write(255, 0);
|
||||||
|
EEPROM_Write(254, 0);
|
||||||
|
EEPROM_Write(253, 1);
|
||||||
|
EEPROM_Write(252, 0);
|
||||||
|
EEPROM_Write(251, 0);
|
||||||
|
lcd_ind();
|
||||||
|
Loss_mode = 0;
|
||||||
|
p_Tx = 0;
|
||||||
|
n_Tx = 1;
|
||||||
|
SWR = 0;
|
||||||
|
PWR = 0;
|
||||||
|
SWR_fixed_old = 0;
|
||||||
|
if(type==4 | type==5) { // 128*64 OLED
|
||||||
|
led_wr_str (2, 16, "RESET ", 8);
|
||||||
|
asm CLRWDT;
|
||||||
|
delay_ms(600);
|
||||||
|
led_wr_str (2, 16, "SWR=0.00", 8);
|
||||||
|
asm CLRWDT;
|
||||||
|
}
|
||||||
|
else if(type!=0 & type!=6) {// 1602 LCD & 128*32 OLED
|
||||||
|
led_wr_str (1, 0, "RESET ", 8);
|
||||||
|
asm CLRWDT;
|
||||||
|
delay_ms(600);
|
||||||
|
led_wr_str (1, 0, "SWR=0.00", 8);
|
||||||
|
asm CLRWDT;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LATB.B6 = 1;
|
||||||
|
LATB.B7 = 1;
|
||||||
|
}
|
||||||
|
Low = 0;
|
||||||
|
Mid = 0;
|
||||||
|
High = 0;
|
||||||
|
SWR_old = 10000;
|
||||||
|
Power_old = 10000;
|
||||||
|
lcd_pwr();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void btn_push() {
|
||||||
|
asm CLRWDT;
|
||||||
|
if(type==4 | type==5) { // 128*64 OLED
|
||||||
|
led_wr_str (2, 16+12*4, "TUNE", 4);
|
||||||
|
}
|
||||||
|
else if(type!=0 & type!=6) { // 1602 LCD & 128*32 OLED
|
||||||
|
led_wr_str (1, 4, "TUNE", 4);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LATB.B6 = 1;
|
||||||
|
LATB.B7 = 1;
|
||||||
|
}
|
||||||
|
Low = 0;
|
||||||
|
Mid = 0;
|
||||||
|
High = 0;
|
||||||
|
tune();
|
||||||
|
if(type==0) { // real-time 2-colors led work
|
||||||
|
if(swr<=150) { LATB.B6 = 0; LATB.B7 = 1; } // Green
|
||||||
|
else if(swr<=250) {PORTB.B6 = 0; PORTB.B7 = 0;} // Orange
|
||||||
|
else { PORTB.B6 = 1; PORTB.B7 = 0; } // Red
|
||||||
|
}
|
||||||
|
else if(type==6){
|
||||||
|
if(swr<=150) { LATB.B6 = 1; LATB.B7 = 0; } // Green
|
||||||
|
else if(swr<=250) {PORTB.B6 = 1; PORTB.B7 = 1;} // Orange
|
||||||
|
else { PORTB.B6 = 0; PORTB.B7 = 1; } // Red
|
||||||
|
}
|
||||||
|
else if(Loss_mode==0 | Loss_ind==0) lcd_ind();
|
||||||
|
if(SWR<=150) Low = 1;
|
||||||
|
else if(SWR<=250) Mid = 1;
|
||||||
|
else High = 1;
|
||||||
|
EEPROM_Write(255, cap);
|
||||||
|
EEPROM_Write(254, ind);
|
||||||
|
EEPROM_Write(253, SW);
|
||||||
|
EEPROM_Write(252, swr_a/256);
|
||||||
|
EEPROM_Write(251, swr_a%256);
|
||||||
|
SWR_old = 10000;
|
||||||
|
Power_old = 10000;
|
||||||
|
lcd_pwr();
|
||||||
|
SWR_fixed_old = SWR;
|
||||||
|
p_Tx = 0;
|
||||||
|
n_Tx = 1;
|
||||||
|
asm CLRWDT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_prep() {
|
||||||
|
asm CLRWDT;
|
||||||
|
if(type==4 |type==5){ // 128*64 OLED
|
||||||
|
if(lcd_prep_short==0) {
|
||||||
|
led_wr_str (0, 22, "ATU-100", 7);
|
||||||
|
led_wr_str (2, 4, "mini board", 10);
|
||||||
|
led_wr_str (4, 16, "by N7DDC", 8);
|
||||||
|
led_wr_str (6, 4, "FW ver 3.1", 10);
|
||||||
|
asm CLRWDT;
|
||||||
|
Delay_ms(600);
|
||||||
|
asm CLRWDT;
|
||||||
|
Delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (0, 16, " ", 8);
|
||||||
|
led_wr_str (2, 4, " ", 10);
|
||||||
|
led_wr_str (4, 16, " ", 8);
|
||||||
|
led_wr_str (6, 4, " ", 10);
|
||||||
|
}
|
||||||
|
Delay_ms(150);
|
||||||
|
led_wr_str (0, 16, "PWR=0.0W", 8);
|
||||||
|
led_wr_str (2, 16, "SWR=0.00", 8);
|
||||||
|
if(Auto) led_wr_str (0, 16+8*12, ".", 1);
|
||||||
|
}
|
||||||
|
else if(type!=0 & type!=6) { // 1602 LCD & 128*32 OLED
|
||||||
|
if(lcd_prep_short==0) {
|
||||||
|
led_wr_str (0, 4, "ATU-100", 7);
|
||||||
|
led_wr_str (1, 3, "mini board", 10);
|
||||||
|
asm CLRWDT;
|
||||||
|
Delay_ms(700);
|
||||||
|
asm CLRWDT;
|
||||||
|
Delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (0, 4, "by N7DDC", 8);
|
||||||
|
led_wr_str (1, 3, "FW ver 3.1", 10);
|
||||||
|
asm CLRWDT;
|
||||||
|
Delay_ms(600);
|
||||||
|
asm CLRWDT;
|
||||||
|
Delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (0, 4, " ", 8);
|
||||||
|
led_wr_str (1, 3, " ", 10);
|
||||||
|
}
|
||||||
|
Delay_ms(150);
|
||||||
|
led_wr_str (0, 0, "PWR=0.0W", 8);
|
||||||
|
led_wr_str (1, 0, "SWR=0.00", 8);
|
||||||
|
if(Auto) led_wr_str (0, 8, ".", 1);
|
||||||
|
}
|
||||||
|
asm CLRWDT;
|
||||||
|
lcd_ind();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void lcd_swr(int swr) {
|
||||||
|
asm CLRWDT;
|
||||||
|
if(swr!=SWR_old) {
|
||||||
|
SWR_old = swr;
|
||||||
|
if(swr==1) { // Low power
|
||||||
|
if(type==4 | type==5) led_wr_str (2, 16+4*12, "0.00", 4); // 128*64 OLED
|
||||||
|
else if(type!=0 & type!=6) led_wr_str (1, 4, "0.00", 4); // 1602 & 128*32 OLED
|
||||||
|
else if(type==0) { // real-time 2-colors led work
|
||||||
|
LATB.B6 = 1;
|
||||||
|
LATB.B7 = 1;
|
||||||
|
}
|
||||||
|
else if(type==6){
|
||||||
|
LATB.B6 = 0;
|
||||||
|
LATB.B7 = 0;
|
||||||
|
}
|
||||||
|
Low = 0;
|
||||||
|
Mid = 0;
|
||||||
|
High = 0;
|
||||||
|
SWR_old = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SWR_old = swr;
|
||||||
|
IntToStr(swr, work_str);
|
||||||
|
work_str_2[0] = work_str[3];
|
||||||
|
work_str_2[1] = '.';
|
||||||
|
work_str_2[2] = work_str[4];
|
||||||
|
work_str_2[3] = work_str[5];
|
||||||
|
if(type==4 | type==5) led_wr_str (2, 16+4*12, work_str_2, 4); // 128*64 OLED
|
||||||
|
else if(type!=0 & type!=6) led_wr_str (1, 4, work_str_2, 4); // 1602 & 128*32
|
||||||
|
else if(type==0) { // real-time 2-colors led work
|
||||||
|
if(swr<=150) { LATB.B6 = 0; LATB.B7 = 1; } // Green
|
||||||
|
else if(swr<=250) {PORTB.B6 = 0; PORTB.B7 = 0;} // Orange
|
||||||
|
else { PORTB.B6 = 1; PORTB.B7 = 0; } // Red
|
||||||
|
}
|
||||||
|
else if(type==6){
|
||||||
|
if(swr<=150) { LATB.B6 = 1; LATB.B7 = 0; } // Green
|
||||||
|
else if(swr<=250) {PORTB.B6 = 1; PORTB.B7 = 1;} // Orange
|
||||||
|
else { PORTB.B6 = 0; PORTB.B7 = 1; } // Red
|
||||||
|
}
|
||||||
|
if(SWR<=150) {Low = 1; Mid = 0; High = 0;}
|
||||||
|
else if(SWR<=250) {Low = 0; Mid = 1; High = 0;}
|
||||||
|
else {Low = 0; Mid = 0; High = 1; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
asm CLRWDT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void button_delay() {
|
||||||
|
if((Button(&PORTB, 0, 25, 0)) | (Button(&PORTB, 1, 25, 0)) | (Button(&PORTB, 2, 25, 0))) {
|
||||||
|
but = 1;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void show_pwr(int Power, int SWR) {
|
||||||
|
float a, b;
|
||||||
|
int p_ant, eff;
|
||||||
|
asm CLRWDT;
|
||||||
|
//
|
||||||
|
if(Test==0 & Loss_ind==1 & SWR>=100) {
|
||||||
|
if(Loss_mode==0) { // prepare
|
||||||
|
if(type==4 |type==5){ // 128*64 OLED
|
||||||
|
led_wr_str(4, 16, "ANT=0.0W", 8);
|
||||||
|
led_wr_str(6, 16, "EFF= 0%", 8);
|
||||||
|
}
|
||||||
|
else if(type==2 | type==3) { // 128*32 OLED
|
||||||
|
led_wr_str (0, 9, "ANT=0.0W", 8);
|
||||||
|
led_wr_str (1, 9, "EFF= 0%", 8);
|
||||||
|
}
|
||||||
|
else if(type==1) { // 1602 LCD
|
||||||
|
led_wr_str (0, 9, "AN=0.0W", 7);
|
||||||
|
led_wr_str (1, 9, "EFF= 0%", 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loss_mode = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(Loss_mode==1) lcd_ind();
|
||||||
|
Loss_mode = 0;
|
||||||
|
}
|
||||||
|
asm CLRWDT;
|
||||||
|
if(Power != Power_old) {
|
||||||
|
Power_old = Power;
|
||||||
|
//
|
||||||
|
if(1) {
|
||||||
|
if(Power >= 100) { // > 10 W
|
||||||
|
Power += 5; // rounding to 1 W
|
||||||
|
IntToStr(Power, work_str);
|
||||||
|
work_str_2[0] = work_str[2];
|
||||||
|
work_str_2[1] = work_str[3];
|
||||||
|
work_str_2[2] = work_str[4];
|
||||||
|
work_str_2[3] = 'W';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IntToStr(Power, work_str);
|
||||||
|
if(work_str[4] != ' ') work_str_2[0] = work_str[4]; else work_str_2[0] = '0';
|
||||||
|
work_str_2[1] = '.';
|
||||||
|
if(work_str[5] != ' ') work_str_2[2] = work_str[5]; else work_str_2[2] = '0';
|
||||||
|
work_str_2[3] = 'W';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(type==4 | type==5) led_wr_str (0, 16+4*12, work_str_2, 4); // 128*64 OLED
|
||||||
|
else if(type!=0 & type!=6) led_wr_str (0, 4, work_str_2, 4); // 1602 & 128*32
|
||||||
|
//
|
||||||
|
// Loss indication
|
||||||
|
if(Loss_mode==1) {
|
||||||
|
if(ind==0 & cap==0) swr_a = SWR;
|
||||||
|
a = 1.0 / ((swr_a/100.0 + 100.0/swr_a) * Fid_loss/10.0 * 0.115 + 1.0); // Fider loss
|
||||||
|
b = 4.0 / (2.0 + SWR/100.0 + 100.0/SWR); // SWR loss
|
||||||
|
if(a>=1.0) a = 1.0;
|
||||||
|
if(b>=1.0) b = 1.0;
|
||||||
|
p_ant = Power * a * b;
|
||||||
|
eff = a * b * 100;
|
||||||
|
if(eff>=100) eff = 99;
|
||||||
|
//
|
||||||
|
if(1) {
|
||||||
|
if(p_ant >= 100) { // > 10 W
|
||||||
|
p_ant += 5; // rounding to 1 W
|
||||||
|
IntToStr(p_ant, work_str);
|
||||||
|
work_str_2[0] = work_str[2];
|
||||||
|
work_str_2[1] = work_str[3];
|
||||||
|
work_str_2[2] = work_str[4];
|
||||||
|
work_str_2[3] = 'W';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IntToStr(p_ant, work_str);
|
||||||
|
if(work_str[4] != ' ') work_str_2[0] = work_str[4]; else work_str_2[0] = '0';
|
||||||
|
work_str_2[1] = '.';
|
||||||
|
if(work_str[5] != ' ') work_str_2[2] = work_str[5]; else work_str_2[2] = '0';
|
||||||
|
work_str_2[3] = 'W';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(type==4 | type==5) led_wr_str (4, 16+4*12, work_str_2, 4); // 128*64 OLED
|
||||||
|
else if(type==2 | type==3) led_wr_str (0, 13, work_str_2, 4); // 128*32
|
||||||
|
else if(type==1) led_wr_str (0, 12, work_str_2, 4); // 1602
|
||||||
|
//
|
||||||
|
IntToStr(eff, work_str);
|
||||||
|
work_str_2[0] = work_str[4];
|
||||||
|
work_str_2[1] = work_str[5];
|
||||||
|
if(type==4 | type==5) led_wr_str(6, 16+5*12, work_str_2, 2);
|
||||||
|
else if(type==2 | type==3) led_wr_str(1, 14, work_str_2, 2);
|
||||||
|
else if(type==1) led_wr_str(1, 13, work_str_2, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
asm CLRWDT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void lcd_pwr() {
|
||||||
|
int p = 0;
|
||||||
|
char peak_cnt;
|
||||||
|
int delta = Auto_delta - 100;
|
||||||
|
char cnt;
|
||||||
|
int SWR_fixed = 1;
|
||||||
|
PWR = 0;
|
||||||
|
asm CLRWDT;
|
||||||
|
// peak detector
|
||||||
|
cnt = 120;
|
||||||
|
for(peak_cnt = 0; peak_cnt < cnt; peak_cnt++){
|
||||||
|
if(PORTB.B4==0 | PORTB.B5==0 | PORTB.B0==0) {button_delay(); if(but==1) {but = 0; return;} }
|
||||||
|
get_pwr();
|
||||||
|
if(PWR>p) {p = PWR; SWR_fixed = SWR;}
|
||||||
|
Delay_ms(3);
|
||||||
|
}
|
||||||
|
asm CLRWDT;
|
||||||
|
Power = p;
|
||||||
|
lcd_swr(SWR_fixed);
|
||||||
|
if(SWR_fixed>=100) {
|
||||||
|
dysp_on(); // dysplay ON
|
||||||
|
dysp_cnt = Dysp_delay * dysp_cnt_mult;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if(Auto & SWR_fixed>=Auto_delta & ((SWR_fixed>SWR_fixed_old & (SWR_fixed-SWR_fixed_old)>delta) | (SWR_fixed<SWR_fixed_old & (SWR_fixed_old-SWR_fixed)>delta) | SWR_fixed_old==999))
|
||||||
|
Soft_tune = 1;
|
||||||
|
//
|
||||||
|
if(PORTB.B4==0 | PORTB.B5==0 | PORTB.B0==0) {button_delay(); if(but==1) {but = 0; return;} } // Fast return if button pressed
|
||||||
|
show_pwr(Power, SWR_fixed);
|
||||||
|
//
|
||||||
|
if(PORTB.B4==0 | PORTB.B5==0 | PORTB.B0==0) {button_delay(); if(but==1) {but = 0; return;} }
|
||||||
|
asm CLRWDT;
|
||||||
|
if(Overload==1) {
|
||||||
|
if(type==4 | type==5) { // 128*64 OLED
|
||||||
|
led_wr_str (2, 16, " ", 8);
|
||||||
|
delay_ms(100);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (2, 16, "OVERLOAD", 8);
|
||||||
|
delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (2, 16, " ", 8);
|
||||||
|
delay_ms(300);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (2, 16, "OVERLOAD", 8);
|
||||||
|
delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (2, 16, " ", 8);
|
||||||
|
delay_ms(300);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (2, 16, "OVERLOAD", 8);
|
||||||
|
delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (2, 16, " ", 8);
|
||||||
|
delay_ms(100);
|
||||||
|
led_wr_str (2, 16, "SWR= ", 8);
|
||||||
|
}
|
||||||
|
else if(type!=0 & type!=6) { // 1602 & 128*32// 1602
|
||||||
|
led_wr_str (1, 0, " ", 8);
|
||||||
|
delay_ms(100);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (1, 0, "OVERLOAD", 8);
|
||||||
|
delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (1, 0, " ", 8);
|
||||||
|
delay_ms(300);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (1, 0, "OVERLOAD", 8);
|
||||||
|
delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (1, 0, " ", 8);
|
||||||
|
delay_ms(300);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (1, 0, "OVERLOAD", 8);
|
||||||
|
delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
led_wr_str (1, 0, " ", 8);
|
||||||
|
delay_ms(100);
|
||||||
|
led_wr_str (1, 0, "SWR= ", 8);
|
||||||
|
}
|
||||||
|
asm CLRWDT;
|
||||||
|
SWR_old = 10000;
|
||||||
|
lcd_swr(SWR_fixed);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_ind() {
|
||||||
|
char column;
|
||||||
|
asm CLRWDT;
|
||||||
|
if(1) {
|
||||||
|
work_int = 0;
|
||||||
|
if(ind.B0) work_int += Ind1;
|
||||||
|
if(ind.B1) work_int += Ind2;
|
||||||
|
if(ind.B2) work_int += Ind3;
|
||||||
|
if(ind.B3) work_int += Ind4;
|
||||||
|
if(ind.B4) work_int += Ind5;
|
||||||
|
if(type==1) { // 1602 LCD
|
||||||
|
if(work_int>9999) { // more then 9999 nH
|
||||||
|
work_int += 500; // round
|
||||||
|
IntToStr(work_int, work_str);
|
||||||
|
work_str_2[0] = ' ';
|
||||||
|
work_str_2[1] = work_str[1];
|
||||||
|
work_str_2[2] = work_str[2];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
work_int += 50; // Round
|
||||||
|
IntToStr(work_int, work_str);
|
||||||
|
if(work_str[2] != ' ') work_str_2[0] = work_str[2]; else work_str_2[0] = '0';
|
||||||
|
work_str_2[1] = '.';
|
||||||
|
if(work_str[3] != ' ') work_str_2[2] = work_str[3]; else work_str_2[2] = '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(work_int>9999) {// more then 9999 nH
|
||||||
|
work_int += 50; // Round
|
||||||
|
IntToStr(work_int, work_str);
|
||||||
|
work_str_2[0] = work_str[1];
|
||||||
|
work_str_2[1] = work_str[2];
|
||||||
|
work_str_2[2] = '.';
|
||||||
|
work_str_2[3] = work_str[3];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IntToStr(work_int, work_str);
|
||||||
|
if(work_str[2] != ' ') work_str_2[0] = work_str[2]; else work_str_2[0] = '0';
|
||||||
|
work_str_2[1] = '.';
|
||||||
|
if(work_str[3] != ' ') work_str_2[2] = work_str[3]; else work_str_2[2] = '0';
|
||||||
|
if(work_str[4] != ' ') work_str_2[3] = work_str[4]; else work_str_2[3] = '0';
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if(type==1) {
|
||||||
|
if(SW==1) column = 0; else column = 1;
|
||||||
|
led_wr_str (column, 9, "L=", 2);
|
||||||
|
led_wr_str (column, 14, "uH", 2);
|
||||||
|
led_wr_str (column, 11, work_str_2, 3);
|
||||||
|
}
|
||||||
|
else if(type==4 | type==5) { // 128*64 OLED
|
||||||
|
if(SW==1) column = 4; else column = 6;
|
||||||
|
led_wr_str (column, 16, "L=", 2);
|
||||||
|
led_wr_str (column, 16+6*12, "uH", 2);
|
||||||
|
led_wr_str (column, 16+2*12, work_str_2, 4);
|
||||||
|
}
|
||||||
|
else if(type==2 | type==3) {// 128*32 OLED
|
||||||
|
if(SW==1) column = 0; else column = 1;
|
||||||
|
led_wr_str (column, 9, "L=", 2);
|
||||||
|
led_wr_str (column, 15, "uH", 2);
|
||||||
|
led_wr_str (column, 11, work_str_2, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
asm CLRWDT;
|
||||||
|
if(1) {
|
||||||
|
work_int = 0;
|
||||||
|
if(cap.B0) work_int += Cap1;
|
||||||
|
if(cap.B1) work_int += Cap2;
|
||||||
|
if(cap.B2) work_int += Cap3;
|
||||||
|
if(cap.B3) work_int += Cap4;
|
||||||
|
if(cap.B4) work_int += Cap5;
|
||||||
|
//
|
||||||
|
if(type==4 | type==5) { // 128*64 OLED
|
||||||
|
IntToStr(work_int, work_str);
|
||||||
|
work_str_2[0] = work_str[2];
|
||||||
|
work_str_2[1] = work_str[3];
|
||||||
|
work_str_2[2] = work_str[4];
|
||||||
|
work_str_2[3] = work_str[5];
|
||||||
|
if(SW==1) column = 6; else column = 4;
|
||||||
|
led_wr_str (column, 16, "C=", 2);
|
||||||
|
led_wr_str (column, 16+6*12, "pF", 2);
|
||||||
|
led_wr_str (column, 16+2*12, work_str_2, 4);
|
||||||
|
}
|
||||||
|
else if(type==2 | type==3) {// 128*32 OLED
|
||||||
|
IntToStr(work_int, work_str);
|
||||||
|
work_str_2[0] = work_str[2];
|
||||||
|
work_str_2[1] = work_str[3];
|
||||||
|
work_str_2[2] = work_str[4];
|
||||||
|
work_str_2[3] = work_str[5];
|
||||||
|
if(SW==1) column = 1; else column = 0;
|
||||||
|
led_wr_str (column, 9, "C=", 2);
|
||||||
|
led_wr_str (column, 15, "pF", 2);
|
||||||
|
led_wr_str (column, 11, work_str_2, 4);
|
||||||
|
}
|
||||||
|
else if(type==1) { // 1602 LCD
|
||||||
|
IntToStr(work_int, work_str);
|
||||||
|
work_str_2[0] = work_str[3];
|
||||||
|
work_str_2[1] = work_str[4];
|
||||||
|
work_str_2[2] = work_str[5];
|
||||||
|
if(SW==1) column = 1; else column = 0;
|
||||||
|
led_wr_str (column, 9, "C=", 2);
|
||||||
|
led_wr_str (column, 14, "pF", 2);
|
||||||
|
led_wr_str (column, 11, work_str_2, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
asm CLRWDT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Test_init(void) { // Test mode
|
||||||
|
if(type==4 | type==5) // 128*64 OLED
|
||||||
|
led_wr_str (0, 10, "TEST MODE", 9);
|
||||||
|
else if(type!=0 & type!=6) // 1602 LCD or 128*32 OLED
|
||||||
|
led_wr_str (0, 3, "TEST MODE", 9);
|
||||||
|
asm CLRWDT;
|
||||||
|
Delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
Delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
Delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
Delay_ms(500);
|
||||||
|
asm CLRWDT;
|
||||||
|
if(type==4 | type==5) // 128*64 OLED
|
||||||
|
led_wr_str (0, 10, " ", 9);
|
||||||
|
else if(type!=0 & type!=6) // 1602 LCD or 128*32 OLED
|
||||||
|
led_wr_str (0, 3, " ", 9);
|
||||||
|
atu_reset();
|
||||||
|
SW = 1; // C to OUT
|
||||||
|
set_sw(SW);
|
||||||
|
EEPROM_Write(255, cap);
|
||||||
|
EEPROM_Write(254, ind);
|
||||||
|
EEPROM_Write(253, SW);
|
||||||
|
//
|
||||||
|
if(type==4 | type==5) // 128*64 OLED
|
||||||
|
led_wr_str (0, 16+12*8, "l", 1);
|
||||||
|
else if(type!=0 & type!=6) // 1602 LCD or 128*32 OLED
|
||||||
|
led_wr_str (0, 8, "l", 1);
|
||||||
|
//
|
||||||
|
lcd_prep_short = 1;
|
||||||
|
lcd_prep();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cells_init(void) {
|
||||||
|
// Cells init
|
||||||
|
asm CLRWDT;
|
||||||
|
//oled_addr = EEPROM_Read(0); // address
|
||||||
|
type = EEPROM_Read(1); // type of display
|
||||||
|
if(EEPROM_Read(2) == 1) Auto = 1;
|
||||||
|
Rel_Del = Bcd2Dec(EEPROM_Read(3)); // Relay's Delay
|
||||||
|
Auto_delta = Bcd2Dec(EEPROM_Read(4)) * 10; // Auto_delta
|
||||||
|
min_for_start = Bcd2Dec(EEPROM_Read(5)) * 10; // min_for_start
|
||||||
|
max_for_start = Bcd2Dec(EEPROM_Read(6)) * 10; // max_for_start
|
||||||
|
max_swr = Bcd2Dec(EEPROM_Read(9)) * 10; // Max SWR
|
||||||
|
K_Mult = Bcd2Dec(EEPROM_Read(10)); // Tandem Match rate
|
||||||
|
//
|
||||||
|
asm CLRWDT;
|
||||||
|
Ind1 = Bcd2Dec(EEPROM_Read(16)) * 100 + Bcd2Dec(EEPROM_Read(17)); // Ind1
|
||||||
|
Ind2 = Bcd2Dec(EEPROM_Read(18)) * 100 + Bcd2Dec(EEPROM_Read(19)); // Ind2
|
||||||
|
Ind3 = Bcd2Dec(EEPROM_Read(20)) * 100 + Bcd2Dec(EEPROM_Read(21)); // Ind3
|
||||||
|
Ind4 = Bcd2Dec(EEPROM_Read(22)) * 100 + Bcd2Dec(EEPROM_Read(23)); // Ind4
|
||||||
|
Ind5 = Bcd2Dec(EEPROM_Read(24)) * 100 + Bcd2Dec(EEPROM_Read(25)); // Ind5
|
||||||
|
//
|
||||||
|
Cap1 = Bcd2Dec(EEPROM_Read(32)) * 100 + Bcd2Dec(EEPROM_Read(33)); // Cap1
|
||||||
|
Cap2 = Bcd2Dec(EEPROM_Read(34)) * 100 + Bcd2Dec(EEPROM_Read(35)); // Cap2
|
||||||
|
Cap3 = Bcd2Dec(EEPROM_Read(36)) * 100 + Bcd2Dec(EEPROM_Read(37)); // Cap3
|
||||||
|
Cap4 = Bcd2Dec(EEPROM_Read(38)) * 100 + Bcd2Dec(EEPROM_Read(39)); // Cap4
|
||||||
|
Cap5 = Bcd2Dec(EEPROM_Read(40)) * 100 + Bcd2Dec(EEPROM_Read(41)); // Cap5
|
||||||
|
//
|
||||||
|
Dysp_delay = Bcd2Dec(EEPROM_Read(0x30)); // Dysplay ON delay
|
||||||
|
Loss_ind = EEPROM_Read(0x31);
|
||||||
|
Fid_loss = Bcd2Dec(EEPROM_Read(0x32));
|
||||||
|
asm CLRWDT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void show_loss(void) {
|
||||||
|
IntToStr(Fid_loss, work_str);
|
||||||
|
if(Fid_loss>=10) work_str_2[0] = work_str[4];
|
||||||
|
else work_str_2[0] = '0';
|
||||||
|
work_str_2[1] = '.';
|
||||||
|
work_str_2[2] = work_str[5];
|
||||||
|
if(type==4 | type==5) led_wr_str (2, 6, work_str_2, 3); // 128*64
|
||||||
|
else if(type!=0) led_wr_str (1, 3, work_str_2, 3); // 1602 | 128*32
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Bookmarks]
|
||||||
|
Count=0
|
||||||
|
[Position]
|
||||||
|
Line=89
|
||||||
|
Column=33
|
||||||
|
[BreakPoints]
|
||||||
|
Count=0
|
||||||
|
[FoldedLines]
|
||||||
|
Count=0
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,373 @@
|
||||||
|
// Main.h
|
||||||
|
// David Fainitski
|
||||||
|
// ATU-100 project 2016
|
||||||
|
|
||||||
|
//
|
||||||
|
static char ind = 0, cap = 0, SW = 0, step_cap = 0, step_ind = 0, Overload = 0, Loss_ind = 0, K_mult = 10;
|
||||||
|
static int Rel_Del, min_for_start, max_for_start, max_swr;
|
||||||
|
int SWR, PWR, P_max = 0, swr_a;
|
||||||
|
char rready = 0, p_cnt = 0;
|
||||||
|
//
|
||||||
|
void btn_push(void);
|
||||||
|
void lcd_prep(void);
|
||||||
|
void lcd_swr(int);
|
||||||
|
void lcd_pwr(void);
|
||||||
|
void lcd_ind(void);
|
||||||
|
void crypto(void);
|
||||||
|
void show_reset(void);
|
||||||
|
void show_pwr(int, int);
|
||||||
|
void cells_init(void);
|
||||||
|
void test_init(void);
|
||||||
|
void button_proc(void);
|
||||||
|
void button_proc_test(void);
|
||||||
|
void button_delay(void);
|
||||||
|
void show_loss(void);
|
||||||
|
//
|
||||||
|
void atu_reset(void);
|
||||||
|
int get_reverse(void);
|
||||||
|
int get_forward(void);
|
||||||
|
int correction(int);
|
||||||
|
int get_swr(void);
|
||||||
|
void get_pwr(void);
|
||||||
|
void set_sw(char);
|
||||||
|
void coarse_cap();
|
||||||
|
void sharp_cap();
|
||||||
|
void sharp_ind();
|
||||||
|
void coarse_tune();
|
||||||
|
void tune(void);
|
||||||
|
//
|
||||||
|
|
||||||
|
int correction(int input) {
|
||||||
|
input *= 3; // Devider compensation
|
||||||
|
//
|
||||||
|
if(input <= 80) return 0;
|
||||||
|
if(input <= 171) input += 244;
|
||||||
|
else if(input <= 328) input += 254;
|
||||||
|
else if(input <= 582) input += 280;
|
||||||
|
else if(input <= 820) input += 297;
|
||||||
|
else if(input <= 1100) input += 310;
|
||||||
|
else if(input <= 2181) input += 430;
|
||||||
|
else if(input <= 3322) input += 484;
|
||||||
|
else if(input <= 4623) input += 530;
|
||||||
|
else if(input <= 5862) input += 648;
|
||||||
|
else if(input <= 7146) input += 743;
|
||||||
|
else if(input <= 8502) input += 820;
|
||||||
|
else if(input <= 10500) input += 900;
|
||||||
|
else input += 850;
|
||||||
|
//
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
int get_reverse() {
|
||||||
|
int Reverse;
|
||||||
|
FVRCON = 0b10000001; // ADC 1024 vmV Vref
|
||||||
|
while(FVRCON.B6 == 0);
|
||||||
|
Reverse = ADC_Get_Sample(1);
|
||||||
|
if(Reverse <= 1000) return Reverse;
|
||||||
|
FVRCON = 0b10000010; // ADC 2048 vmV Vref
|
||||||
|
while(FVRCON.B6 == 0);
|
||||||
|
Reverse = ADC_Get_Sample(1);
|
||||||
|
if(Reverse <= 1000) return Reverse * 2;
|
||||||
|
FVRCON = 0b10000011; // ADC 4096 vmV Vref
|
||||||
|
while(FVRCON.B6 == 0);
|
||||||
|
Reverse = ADC_Get_Sample(1);
|
||||||
|
return Reverse * 4;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
int get_forward() {
|
||||||
|
int Forward;
|
||||||
|
FVRCON = 0b10000001; // ADC 1024 vmV Vref
|
||||||
|
while(FVRCON.B6 == 0);
|
||||||
|
Forward = ADC_Get_Sample(0);
|
||||||
|
if(Forward <= 1000) return Forward;
|
||||||
|
FVRCON = 0b10000010; // ADC 2048 vmV Vref
|
||||||
|
while(FVRCON.B6 == 0);
|
||||||
|
Forward = ADC_Get_Sample(0);
|
||||||
|
if(Forward <= 1000) return Forward * 2;
|
||||||
|
FVRCON = 0b10000011; // ADC 4096 vmV Vref
|
||||||
|
while(FVRCON.B6 == 0);
|
||||||
|
Forward = ADC_Get_Sample(0);
|
||||||
|
if(Forward == 1023) Overload = 1;
|
||||||
|
else Overload = 0;
|
||||||
|
return Forward * 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_pwr() {
|
||||||
|
long Forward, Reverse;
|
||||||
|
float p;
|
||||||
|
asm CLRWDT;
|
||||||
|
//
|
||||||
|
Forward = get_forward();
|
||||||
|
Reverse = get_reverse();
|
||||||
|
p = correction(Forward);
|
||||||
|
//
|
||||||
|
if(Reverse >= Forward)
|
||||||
|
Forward = 999;
|
||||||
|
else {
|
||||||
|
Forward = ((Forward + Reverse) * 100) / (Forward - Reverse);
|
||||||
|
if(Forward>999) Forward = 999;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
p = p * k_mult / 1000; // mV to Volts
|
||||||
|
p = p / 1.414;
|
||||||
|
p = p * p / 5;
|
||||||
|
p = p + 0.5; // rounding to 0.1 W
|
||||||
|
PWR = p; // 0 - 1510 (151.0 Watts)
|
||||||
|
if(PWR<10) SWR = 1;
|
||||||
|
else if(Forward<100) SWR = 999;
|
||||||
|
else SWR = Forward;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_swr() {
|
||||||
|
get_pwr();
|
||||||
|
if(p_cnt!=100) {
|
||||||
|
p_cnt += 1;
|
||||||
|
if(PWR>P_max) P_max = PWR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p_cnt = 0;
|
||||||
|
show_pwr(P_max, SWR);
|
||||||
|
P_max = 0;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
while((PWR<min_for_start | (PWR> max_for_start & max_for_start>0))) { // waiting for good power
|
||||||
|
asm CLRWDT;
|
||||||
|
get_pwr();
|
||||||
|
if(p_cnt!=100) {
|
||||||
|
p_cnt += 1;
|
||||||
|
if(PWR>P_max) P_max = PWR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p_cnt = 0;
|
||||||
|
show_pwr(P_max, SWR);
|
||||||
|
P_max = 0;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if(Button(&PORTB, 0, 5, 1)) rready = 1;
|
||||||
|
if(rready==1 & Button(&PORTB, 0, 5, 0)) { // press button Tune
|
||||||
|
show_reset();
|
||||||
|
SWR = 0;
|
||||||
|
return SWR;
|
||||||
|
}
|
||||||
|
} // good power
|
||||||
|
return SWR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_ind(char Ind) { // 0 - 31
|
||||||
|
//
|
||||||
|
Ind_011 = Ind.B0;
|
||||||
|
Ind_022 = Ind.B1;
|
||||||
|
Ind_045 = Ind.B2;
|
||||||
|
Ind_1 = Ind.B3;
|
||||||
|
Ind_22 = Ind.B4;
|
||||||
|
//
|
||||||
|
Vdelay_ms(Rel_Del);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_cap(char Cap) { // 0 - 31
|
||||||
|
Cap_10 = Cap.B0;
|
||||||
|
Cap_22 = Cap.B1;
|
||||||
|
Cap_47 = Cap.B2;
|
||||||
|
Cap_100 = Cap.B3;
|
||||||
|
Cap_220 = Cap.B4;
|
||||||
|
//
|
||||||
|
Vdelay_ms(Rel_Del);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_sw(char SW) { // 0 - IN, 1 - OUT
|
||||||
|
Cap_sw = SW;
|
||||||
|
Vdelay_ms(Rel_Del);
|
||||||
|
}
|
||||||
|
|
||||||
|
void atu_reset() {
|
||||||
|
ind = 0;
|
||||||
|
cap = 0;
|
||||||
|
set_ind(ind);
|
||||||
|
set_cap(cap);
|
||||||
|
Vdelay_ms(Rel_Del);
|
||||||
|
}
|
||||||
|
|
||||||
|
void coarse_cap() {
|
||||||
|
char step = 3;
|
||||||
|
char count;
|
||||||
|
int min_swr;
|
||||||
|
|
||||||
|
cap = 0;
|
||||||
|
set_cap(cap);
|
||||||
|
SWR = get_swr();
|
||||||
|
min_swr = SWR + SWR/20;
|
||||||
|
for(count=step; count<=31;) {
|
||||||
|
set_cap(count);
|
||||||
|
SWR = get_swr();
|
||||||
|
if(SWR < min_swr) {
|
||||||
|
min_swr = SWR + SWR/20;
|
||||||
|
cap = count;
|
||||||
|
step_cap = step;
|
||||||
|
if(SWR<120) break;
|
||||||
|
count += step;
|
||||||
|
if(count==9) count = 8;
|
||||||
|
else if(count==17) {count = 16; step = 4;}
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
set_cap(cap);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void coarse_tune() {
|
||||||
|
char step = 3;
|
||||||
|
char count;
|
||||||
|
char mem_cap, mem_step_cap;
|
||||||
|
int min_swr;
|
||||||
|
|
||||||
|
mem_cap = 0;
|
||||||
|
step_ind = step;
|
||||||
|
mem_step_cap = 3;
|
||||||
|
min_swr = SWR + SWR/20;
|
||||||
|
for(count=0; count<=31;) {
|
||||||
|
set_ind(count);
|
||||||
|
coarse_cap();
|
||||||
|
SWR = get_swr();
|
||||||
|
if(SWR < min_swr) {
|
||||||
|
min_swr = SWR + SWR/20;
|
||||||
|
ind = count;
|
||||||
|
mem_cap = cap;
|
||||||
|
step_ind = step;
|
||||||
|
mem_step_cap = step_cap;
|
||||||
|
if(SWR<120) break;
|
||||||
|
count += step;
|
||||||
|
if(count==9) count = 8;
|
||||||
|
else if(count==17) {count = 16; step = 4;}
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
cap = mem_cap;
|
||||||
|
set_ind(ind);
|
||||||
|
set_cap(cap);
|
||||||
|
step_cap = mem_step_cap;
|
||||||
|
Delay_ms(10);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sharp_cap() {
|
||||||
|
char range, count, max_range, min_range;
|
||||||
|
int min_swr;
|
||||||
|
range = step_cap;
|
||||||
|
//
|
||||||
|
max_range = cap + range;
|
||||||
|
if(max_range>31) max_range = 31;
|
||||||
|
if(cap>range) min_range = cap - range; else min_range = 0;
|
||||||
|
cap = min_range;
|
||||||
|
set_cap(cap);
|
||||||
|
SWR = get_swr();
|
||||||
|
if(SWR==0) return;
|
||||||
|
min_SWR = SWR;
|
||||||
|
for(count=min_range+1; count<=max_range; count++) {
|
||||||
|
set_cap(count);
|
||||||
|
SWR = get_swr();
|
||||||
|
if(SWR==0) return;
|
||||||
|
if(SWR>=min_SWR) { Delay_ms(10); SWR = get_swr(); }
|
||||||
|
if(SWR>=min_SWR) { Delay_ms(10); SWR = get_swr(); }
|
||||||
|
if(SWR < min_SWR) {
|
||||||
|
min_SWR = SWR;
|
||||||
|
cap = count;
|
||||||
|
if(SWR<120) break;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
set_cap(cap);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sharp_ind() {
|
||||||
|
char range, count, max_range, min_range;
|
||||||
|
int min_SWR;
|
||||||
|
range = step_ind;
|
||||||
|
//
|
||||||
|
max_range = ind + range;
|
||||||
|
if(max_range>31) max_range = 31;
|
||||||
|
if(ind>range) min_range = ind - range; else min_range = 0;
|
||||||
|
ind = min_range;
|
||||||
|
set_ind(ind);
|
||||||
|
SWR = get_swr();
|
||||||
|
if(SWR==0) return;
|
||||||
|
min_SWR = SWR;
|
||||||
|
for(count=min_range+1; count<=max_range; count++) {
|
||||||
|
set_ind(count);
|
||||||
|
SWR = get_swr();
|
||||||
|
if(SWR==0) return;
|
||||||
|
if(SWR>=min_SWR) { Delay_ms(10); SWR = get_swr(); }
|
||||||
|
if(SWR>=min_SWR) { Delay_ms(10); SWR = get_swr(); }
|
||||||
|
if(SWR < min_SWR) {
|
||||||
|
min_SWR = SWR;
|
||||||
|
ind = count;
|
||||||
|
if(SWR<120) break;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
set_ind(ind);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void tune() {
|
||||||
|
int swr_mem, ind_mem, cap_mem;
|
||||||
|
asm CLRWDT;
|
||||||
|
rready = 0;
|
||||||
|
P_max = 0;
|
||||||
|
p_cnt = 0;
|
||||||
|
get_swr();
|
||||||
|
if(SWR<110) return;
|
||||||
|
atu_reset();
|
||||||
|
if(Loss_ind==0) lcd_ind();
|
||||||
|
Delay_ms(50);
|
||||||
|
get_swr();
|
||||||
|
swr_a = SWR;
|
||||||
|
if(SWR<110) return;
|
||||||
|
if(max_swr>110 & SWR>max_swr) return;
|
||||||
|
//
|
||||||
|
swr_mem = SWR;
|
||||||
|
coarse_tune(); if(SWR==0) {atu_reset(); return;}
|
||||||
|
get_swr(); if(SWR<120) return;
|
||||||
|
sharp_ind(); if(SWR==0) {atu_reset(); return;}
|
||||||
|
get_swr(); if(SWR<120) return;
|
||||||
|
sharp_cap(); if(SWR==0) {atu_reset(); return;}
|
||||||
|
get_swr(); if(SWR<120) return;
|
||||||
|
//
|
||||||
|
if(SWR<200 & SWR<swr_mem & (swr_mem-SWR)>100) return;
|
||||||
|
swr_mem = SWR;
|
||||||
|
ind_mem = ind;
|
||||||
|
cap_mem = cap;
|
||||||
|
//
|
||||||
|
if(SW==1) SW = 0; else SW = 1;
|
||||||
|
atu_reset();
|
||||||
|
set_sw(SW);
|
||||||
|
Delay_ms(50);
|
||||||
|
get_swr(); if(SWR<120) return;
|
||||||
|
//
|
||||||
|
coarse_tune(); if(SWR==0) {atu_reset(); return;}
|
||||||
|
get_swr(); if(SWR<120) return;
|
||||||
|
sharp_ind(); if(SWR==0) {atu_reset(); return;}
|
||||||
|
get_swr(); if(SWR<120) return;
|
||||||
|
sharp_cap(); if(SWR==0) {atu_reset(); return;}
|
||||||
|
get_swr(); if(SWR<120) return;
|
||||||
|
//
|
||||||
|
if(SWR>swr_mem) {
|
||||||
|
if(SW==1) SW = 0; else SW = 1;
|
||||||
|
set_sw(SW);
|
||||||
|
ind = ind_mem;
|
||||||
|
cap = cap_mem;
|
||||||
|
set_ind(ind);
|
||||||
|
set_cap(cap);
|
||||||
|
SWR = swr_mem;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
asm CLRWDT;
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Bookmarks]
|
||||||
|
Count=0
|
||||||
|
[Position]
|
||||||
|
Line=24
|
||||||
|
Column=22
|
||||||
|
[BreakPoints]
|
||||||
|
Count=0
|
||||||
|
[FoldedLines]
|
||||||
|
Count=0
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Bookmarks]
|
||||||
|
Count=0
|
||||||
|
[Position]
|
||||||
|
Line=42
|
||||||
|
Column=34
|
||||||
|
[BreakPoints]
|
||||||
|
Count=0
|
||||||
|
[FoldedLines]
|
||||||
|
Count=0
|
Plik binarny nie jest wyświetlany.
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,406 @@
|
||||||
|
|
||||||
|
#include "oled_control.h"
|
||||||
|
#include "font5x8.h"
|
||||||
|
//
|
||||||
|
|
||||||
|
void led_send (char nible) {
|
||||||
|
char sdata;
|
||||||
|
sdata = 0;
|
||||||
|
RW = 0; E = 1;
|
||||||
|
sdata = sdata + nible;
|
||||||
|
sdata = sdata << 4;
|
||||||
|
if(LED) sdata = sdata + 8;
|
||||||
|
if(E) sdata = sdata + 4;
|
||||||
|
if(RW) sdata = sdata + 2;
|
||||||
|
if(RS) sdata = sdata + 1;
|
||||||
|
//
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr); // device addres
|
||||||
|
Soft_I2C_Write(sdata); //
|
||||||
|
Soft_I2C_Stop();
|
||||||
|
delay_ms(1);
|
||||||
|
sdata = sdata - 4; // E = 0
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr); // device addres
|
||||||
|
Soft_I2C_Write(sdata); //
|
||||||
|
Soft_I2C_Stop();
|
||||||
|
delay_ms(1);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
void led_init (void) {
|
||||||
|
led_type = EEPROM_read(1);
|
||||||
|
shift_line = EEPROM_read(7);
|
||||||
|
oled_shift = EEPROM_read(8);
|
||||||
|
if(led_type!=1) oled_init(); // OLED
|
||||||
|
else{ // 1602 LCD display init
|
||||||
|
LED = 1;
|
||||||
|
RS = 0; // Command
|
||||||
|
//
|
||||||
|
led_send(3);
|
||||||
|
delay_ms(5);
|
||||||
|
led_send(3);
|
||||||
|
delay_ms(1);
|
||||||
|
led_send(3);
|
||||||
|
led_send(2);
|
||||||
|
//
|
||||||
|
led_send(2);
|
||||||
|
led_send(8); //
|
||||||
|
//
|
||||||
|
led_send(0);
|
||||||
|
led_send(8); // LCD OFF
|
||||||
|
//
|
||||||
|
led_send(0);
|
||||||
|
led_send(1); // LCD clear
|
||||||
|
delay_ms(5);
|
||||||
|
//
|
||||||
|
led_send(0);
|
||||||
|
led_send(4 + 2); // I/D, S
|
||||||
|
//
|
||||||
|
led_send(0);
|
||||||
|
led_send(8 + 4 + 0 + 0); // LCD ON, Cursor, Blink Cursor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void oled_init (void) { // OLED init
|
||||||
|
char i, r;
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr); // device addres
|
||||||
|
Soft_I2C_Write(0); // 0 - continious mode, command; 64 - Co, data
|
||||||
|
Soft_I2C_Write (0xAE); // display OFF
|
||||||
|
//
|
||||||
|
if(led_type==2 | led_type==3) { // 128*32 OLED
|
||||||
|
Soft_I2C_Write (0xD5); // clock division
|
||||||
|
Soft_I2C_Write (0x80); // ratio
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xA8); // multiplexer
|
||||||
|
Soft_I2C_Write (0x3f); //
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xD3); // offset
|
||||||
|
if(led_type==2) Soft_I2C_Write (0 + shift_line); // column shift
|
||||||
|
else Soft_I2C_Write (31 + shift_line); // column shift
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x40); // set line, line = 0
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x8D); // charge pump
|
||||||
|
Soft_I2C_Write (0x14); // 0x10 - external, 0x14 - internal
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x81); // contrast
|
||||||
|
Soft_I2C_Write (180); // 0-255
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xD9); // pre-charge
|
||||||
|
Soft_I2C_Write (0x22); // 0x22 - external, 0xF1 - internal
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x20); // memory addressing mode
|
||||||
|
Soft_I2C_Write (0x02); // page addressing mode
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x21); // set column range
|
||||||
|
Soft_I2C_Write (0); // column start
|
||||||
|
Soft_I2C_Write (127); // column stop
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x2E); // stop scrolling
|
||||||
|
//
|
||||||
|
if(led_type==2) {
|
||||||
|
Soft_I2C_Write (0xA0); // segment re-map, A0 - normal, A1 - remapped
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xC0); // scan direction, C0 - normal, C8 - remapped
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Soft_I2C_Write (0xA1); // segment re-map, A0 - normal, A1 - remapped
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xC8); // scan direction, C0 - normal, C8 - remapped
|
||||||
|
}
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xDA); // COM pins configure
|
||||||
|
Soft_I2C_Write (0x02); // 12 for x64
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xDB); // V-COM detect
|
||||||
|
Soft_I2C_Write (0x40); //
|
||||||
|
//
|
||||||
|
}
|
||||||
|
else { // 128*64 OLED
|
||||||
|
Soft_I2C_Write (0xD5); // clock division
|
||||||
|
Soft_I2C_Write (0x80); // ratio
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xA8); // multiplexer
|
||||||
|
Soft_I2C_Write (63); //
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xD3); // offset
|
||||||
|
Soft_I2C_Write (shift_line); // no offset for x64 !
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x40); // set line, line = 0
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x8D); // charge pump
|
||||||
|
Soft_I2C_Write (0x14); // 0x10 - external, 0x14 - internal
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x81); // contrast
|
||||||
|
Soft_I2C_Write (255); // 0-255
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xD9); // pre-charge
|
||||||
|
Soft_I2C_Write (0xf1); // 0x22 - external, 0xF1 - internal
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x20); // memory addressing mode
|
||||||
|
Soft_I2C_Write (0x02); // page addressing mode 02
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x21); // set column range
|
||||||
|
Soft_I2C_Write (0); // column start
|
||||||
|
Soft_I2C_Write (127); // column stop
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0x2E); // stop scrolling
|
||||||
|
//
|
||||||
|
if(led_type==4) {
|
||||||
|
Soft_I2C_Write (0xA0); // segment re-map, A0 - normal, A1 - remapped
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xC0); // scan direction, C0 - normal, C8 - remapped
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Soft_I2C_Write (0xA1); // segment re-map, A0 - normal, A1 - remapped
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xC8); // scan direction, C0 - normal, C8 - remapped
|
||||||
|
}
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xDA); // COM pins configure
|
||||||
|
Soft_I2C_Write (0x12); // 12 for x64
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xDB); // V-COM detect
|
||||||
|
Soft_I2C_Write (0x40); //
|
||||||
|
}
|
||||||
|
Soft_I2C_Write (0xA4); // display entire ON
|
||||||
|
//
|
||||||
|
Soft_I2C_Write (0xA6); // 0xA6 - normal, 0xA7 - inverse
|
||||||
|
//
|
||||||
|
Soft_I2C_Stop ();
|
||||||
|
//
|
||||||
|
// ********clear OLED***********
|
||||||
|
//
|
||||||
|
Delay_ms(100);
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr); // device addres
|
||||||
|
Soft_I2C_Write(64); // 0 - continious mode, command; 64 - Co, data
|
||||||
|
//
|
||||||
|
if(led_type==2 | led_type==3) { // 128*32 OLED
|
||||||
|
for (r = 0; r <=3; r++) {
|
||||||
|
set_addressing (r, 0); // clear all 4 pages
|
||||||
|
for (i = 0; i < 128; i++, Soft_I2C_Write(0)); // clear one page pixels
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { // 128*64 OLED
|
||||||
|
for (r = 0; r <=7; r++) {
|
||||||
|
set_addressing (r, 0); // clear all 8 pages
|
||||||
|
for (i = 0; i < 128; i++, Soft_I2C_Write(0x00)); // clear one page pixels
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//
|
||||||
|
Soft_I2C_Stop ();
|
||||||
|
send_command (0xAF); // display ON
|
||||||
|
//
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void dysp_on() {
|
||||||
|
if(led_type > 1) send_command(0xAF); // display ON
|
||||||
|
else if(led_type==1) {
|
||||||
|
LED = 1;
|
||||||
|
RS = 0;
|
||||||
|
led_send(0);
|
||||||
|
led_send(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dysp_off() {
|
||||||
|
if(led_type > 1) send_command(0xAE); // display OFF
|
||||||
|
else if(led_type==1) {
|
||||||
|
LED = 0;
|
||||||
|
RS = 0;
|
||||||
|
led_send(0);
|
||||||
|
led_send(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void send_command (char oled_command) {
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr); // device addres
|
||||||
|
Soft_I2C_Write(128); // 128 - command, 192 - data
|
||||||
|
Soft_I2C_Write(oled_command);
|
||||||
|
Soft_I2C_Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_addressing (char pagenum, char c_start) {
|
||||||
|
char a, b, c;
|
||||||
|
c = c_start + oled_shift;
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr); // device addres
|
||||||
|
Soft_I2C_Write(0); // 0 - continious mode, command; 64 - Co, data
|
||||||
|
Soft_I2C_Write(0xB0 + pagenum); // set page number
|
||||||
|
//
|
||||||
|
if (c <= 15) { a = c; b = 0; }
|
||||||
|
else { b = c / 16; a = c - b * 16; }
|
||||||
|
Soft_I2C_Write (a); // set lower nibble of start address
|
||||||
|
Soft_I2C_Write (0x10 + b); // set higher nibble of start address
|
||||||
|
//
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr); // device addres
|
||||||
|
Soft_I2C_Write(64); // 0 - continious mode, command; 64 - Co, data
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
void led_wr_str (char col, char pos, char str[], char leng ) { //
|
||||||
|
char i;
|
||||||
|
if(led_type==4 | led_type==5) oled_wr_str(pos, col, str, leng); // 128*64 OLED display
|
||||||
|
else if(led_type==2 | led_type==3) oled_wr_str(7*pos+4, col*2, str, leng); // 128*32 OLED display
|
||||||
|
else { // 1602 LCD
|
||||||
|
// Set address
|
||||||
|
RS = 0;
|
||||||
|
led_send(8 + col*4);
|
||||||
|
led_send(pos);
|
||||||
|
//
|
||||||
|
RS = 1;
|
||||||
|
for (i = 0; i < leng; i++) { // write string
|
||||||
|
// write letter
|
||||||
|
led_send(str[i] >> 4);
|
||||||
|
led_send(str[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
void oled_wr_str (char col, char page, char str[], char leng ) { // 128*32 or 128*64 OLED
|
||||||
|
char i, h, g, w1, w2;
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr); // device addres
|
||||||
|
Soft_I2C_Write(64); // 0 - continious mode, command; 64 - Co, data
|
||||||
|
//
|
||||||
|
set_addressing (page, col);
|
||||||
|
//
|
||||||
|
for (i = 0; i < leng; i++) { // write string
|
||||||
|
if (str[i] == 0) g = 0; else g = str[i] - 32; // NULL detection
|
||||||
|
for (h = 0; h <= 4; h++) { // write letter
|
||||||
|
w1 = font5x8[g*5+h];
|
||||||
|
if(page!=2 & page!=4 & page!=6) {
|
||||||
|
w2.B7 = w1.B3;
|
||||||
|
w2.B6 = w1.B3;
|
||||||
|
w2.B5 = w1.B2;
|
||||||
|
w2.B4 = w1.B2;
|
||||||
|
w2.B3 = w1.B1;
|
||||||
|
w2.B2 = w1.B1;
|
||||||
|
w2.B1 = w1.B0;
|
||||||
|
w2.B0 = w1.B0; }
|
||||||
|
else {
|
||||||
|
w2.B7 = w1.B2;
|
||||||
|
w2.B6 = w1.B2;
|
||||||
|
w2.B5 = w1.B1;
|
||||||
|
w2.B4 = w1.B1;
|
||||||
|
w2.B3 = w1.B0;
|
||||||
|
w2.B2 = w1.B0;
|
||||||
|
w2.B1 = 0;
|
||||||
|
w2.B0 = 0;
|
||||||
|
}
|
||||||
|
Soft_I2C_Write(w2);
|
||||||
|
if(led_type==4 | led_type==5) Soft_I2C_Write(w2); // 128*64
|
||||||
|
}
|
||||||
|
Soft_I2C_Write (0);
|
||||||
|
Soft_I2C_Write (0);
|
||||||
|
//if(led_type==2 | led_type==3) Soft_I2C_Write (0); // 128*32
|
||||||
|
}
|
||||||
|
set_addressing (page+1, col);
|
||||||
|
//
|
||||||
|
for (i = 0; i < leng; i++) { // write string
|
||||||
|
if (str[i] == 0) g = 0; else g = str[i] - 32; // NULL detection
|
||||||
|
for (h = 0; h <= 4; h++) { // write letter
|
||||||
|
w1 = font5x8[g*5+h];
|
||||||
|
if(page!=2 & page!=4 & page!=6) {
|
||||||
|
w2.B7 = w1.B7;
|
||||||
|
w2.B6 = w1.B7;
|
||||||
|
w2.B5 = w1.B6;
|
||||||
|
w2.B4 = w1.B6;
|
||||||
|
w2.B3 = w1.B5;
|
||||||
|
w2.B2 = w1.B5;
|
||||||
|
w2.B1 = w1.B4;
|
||||||
|
w2.B0 = w1.B4; }
|
||||||
|
else {
|
||||||
|
w2.B7 = w1.B6;
|
||||||
|
w2.B6 = w1.B6;
|
||||||
|
w2.B5 = w1.B5;
|
||||||
|
w2.B4 = w1.B5;
|
||||||
|
w2.B3 = w1.B4;
|
||||||
|
w2.B2 = w1.B4;
|
||||||
|
w2.B1 = w1.B3;
|
||||||
|
w2.B0 = w1.B3;
|
||||||
|
}
|
||||||
|
Soft_I2C_Write(w2);
|
||||||
|
if(led_type==4 | led_type==5) Soft_I2C_Write(w2); // 128*64
|
||||||
|
}
|
||||||
|
Soft_I2C_Write (0);
|
||||||
|
Soft_I2C_Write (0);
|
||||||
|
//if(led_type==2 | led_type==3) Soft_I2C_Write (0); // 128*32
|
||||||
|
}
|
||||||
|
Soft_I2C_Stop ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Soft_I2C_Init () {
|
||||||
|
led_addr = EEPROM_read(0); // 4E,7E for 1602 or 78, 7A for OLED
|
||||||
|
led_type = EEPROM_read(1);
|
||||||
|
//led = EEPROM_read(1);
|
||||||
|
if(led_type==0) {
|
||||||
|
Soft_I2C_Scl_Direction = 0;
|
||||||
|
Soft_I2C_Sda_Direction = 0;
|
||||||
|
LATB.B6 = 1;
|
||||||
|
LATB.B7 = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Soft_I2C_Scl_Direction = 1;
|
||||||
|
Soft_I2C_Sda_Direction = 1;
|
||||||
|
Soft_I2C_Scl = 0;
|
||||||
|
Soft_I2C_Sda = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Soft_I2C_Start () {
|
||||||
|
if(led_type!=0) {
|
||||||
|
Soft_I2C_Scl_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Sda_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Sda_Direction = 0;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 0;
|
||||||
|
Delay_us(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Soft_I2C_Write (char d) {
|
||||||
|
char i;
|
||||||
|
if(led_type!=0) {
|
||||||
|
for(i=0; i<=7; i++) {
|
||||||
|
if(d.B7==0) Soft_I2C_Sda_Direction = 0; else Soft_I2C_Sda_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 0;
|
||||||
|
Delay_us(5);
|
||||||
|
d = d << 1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
Soft_I2C_Sda_Direction = 1; //ACK
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 0;
|
||||||
|
Delay_us(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Soft_I2C_Stop () {
|
||||||
|
if(led_type!=0) {
|
||||||
|
Soft_I2C_Sda_Direction = 0;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Sda_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Bookmarks]
|
||||||
|
Count=0
|
||||||
|
[Position]
|
||||||
|
Line=218
|
||||||
|
Column=2
|
||||||
|
[BreakPoints]
|
||||||
|
Count=0
|
||||||
|
[FoldedLines]
|
||||||
|
Count=0
|
|
@ -0,0 +1,535 @@
|
||||||
|
#line 1 "E:/ATU-100/fw_mini/1938_mini_board_sources_V_3.1/oled_control.c"
|
||||||
|
#line 1 "e:/atu-100/fw_mini/1938_mini_board_sources_v_3.1/oled_control.h"
|
||||||
|
|
||||||
|
|
||||||
|
sbit Soft_I2C_Scl at LATB6_bit;
|
||||||
|
sbit Soft_I2C_Sda at LATB7_bit;
|
||||||
|
sbit Soft_I2C_Scl_Direction at TRISB6_bit;
|
||||||
|
sbit Soft_I2C_Sda_Direction at TRISB7_bit;
|
||||||
|
|
||||||
|
static char RS, RW, E, LED, nible;
|
||||||
|
|
||||||
|
static char led_addr;
|
||||||
|
static char led_type;
|
||||||
|
static char shift_line;
|
||||||
|
|
||||||
|
static char oled_shift;
|
||||||
|
|
||||||
|
void set_addressing (char, char);
|
||||||
|
void led_send (char);
|
||||||
|
void led_init (void);
|
||||||
|
void oled_init (void);
|
||||||
|
void dysp_on (void);
|
||||||
|
void dysp_off (void);
|
||||||
|
void send_command (char);
|
||||||
|
void set_addressing (char, char);
|
||||||
|
void led_wr_str (char, char, char*, char);
|
||||||
|
void oled_wr_str (char, char, char*, char);
|
||||||
|
|
||||||
|
|
||||||
|
void Soft_I2C_Init (void);
|
||||||
|
void Soft_I2C_Start (void);
|
||||||
|
void Soft_I2C_Write (char);
|
||||||
|
void Soft_I2C_Stop (void);
|
||||||
|
#line 1 "e:/atu-100/fw_mini/1938_mini_board_sources_v_3.1/font5x8.h"
|
||||||
|
static const char font5x8[] = {
|
||||||
|
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x5F, 0x00, 0x00,
|
||||||
|
0x00, 0x07, 0x00, 0x07, 0x00,
|
||||||
|
0x14, 0x7F, 0x14, 0x7F, 0x14,
|
||||||
|
0x24, 0x2A, 0x7F, 0x2A, 0x12,
|
||||||
|
0x23, 0x13, 0x08, 0x64, 0x62,
|
||||||
|
0x36, 0x49, 0x55, 0x22, 0x50,
|
||||||
|
0x00, 0x05, 0x03, 0x00, 0x00,
|
||||||
|
0x00, 0x1C, 0x22, 0x41, 0x00,
|
||||||
|
0x00, 0x41, 0x22, 0x1C, 0x00,
|
||||||
|
0x08, 0x2A, 0x1C, 0x2A, 0x08,
|
||||||
|
0x08, 0x08, 0x3E, 0x08, 0x08,
|
||||||
|
0x00, 0x50, 0x30, 0x00, 0x00,
|
||||||
|
0x08, 0x08, 0x08, 0x08, 0x08,
|
||||||
|
0x00, 0x30, 0x30, 0x00, 0x00,
|
||||||
|
0x20, 0x10, 0x08, 0x04, 0x02,
|
||||||
|
0x3E, 0x51, 0x49, 0x45, 0x3E,
|
||||||
|
0x00, 0x42, 0x7F, 0x40, 0x00,
|
||||||
|
0x42, 0x61, 0x51, 0x49, 0x46,
|
||||||
|
0x21, 0x41, 0x45, 0x4B, 0x31,
|
||||||
|
0x18, 0x14, 0x12, 0x7F, 0x10,
|
||||||
|
0x27, 0x45, 0x45, 0x45, 0x39,
|
||||||
|
0x3C, 0x4A, 0x49, 0x49, 0x30,
|
||||||
|
0x01, 0x71, 0x09, 0x05, 0x03,
|
||||||
|
0x36, 0x49, 0x49, 0x49, 0x36,
|
||||||
|
0x06, 0x49, 0x49, 0x29, 0x1E,
|
||||||
|
0x00, 0x36, 0x36, 0x00, 0x00,
|
||||||
|
0x00, 0x56, 0x36, 0x00, 0x00,
|
||||||
|
0x00, 0x08, 0x14, 0x22, 0x41,
|
||||||
|
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||||
|
0x41, 0x22, 0x14, 0x08, 0x00,
|
||||||
|
0x02, 0x01, 0x51, 0x09, 0x06,
|
||||||
|
0x32, 0x49, 0x79, 0x41, 0x3E,
|
||||||
|
0x7E, 0x11, 0x11, 0x11, 0x7E,
|
||||||
|
0x7F, 0x49, 0x49, 0x49, 0x36,
|
||||||
|
0x3E, 0x41, 0x41, 0x41, 0x22,
|
||||||
|
0x7F, 0x41, 0x41, 0x22, 0x1C,
|
||||||
|
0x7F, 0x49, 0x49, 0x49, 0x41,
|
||||||
|
0x7F, 0x09, 0x09, 0x01, 0x01,
|
||||||
|
0x3E, 0x41, 0x41, 0x51, 0x32,
|
||||||
|
0x7F, 0x08, 0x08, 0x08, 0x7F,
|
||||||
|
0x00, 0x41, 0x7F, 0x41, 0x00,
|
||||||
|
0x20, 0x40, 0x41, 0x3F, 0x01,
|
||||||
|
0x7F, 0x08, 0x14, 0x22, 0x41,
|
||||||
|
0x7F, 0x40, 0x40, 0x40, 0x40,
|
||||||
|
0x7F, 0x02, 0x04, 0x02, 0x7F,
|
||||||
|
0x7F, 0x04, 0x08, 0x10, 0x7F,
|
||||||
|
0x3E, 0x41, 0x41, 0x41, 0x3E,
|
||||||
|
0x7F, 0x09, 0x09, 0x09, 0x06,
|
||||||
|
0x3E, 0x41, 0x51, 0x21, 0x5E,
|
||||||
|
0x7F, 0x09, 0x19, 0x29, 0x46,
|
||||||
|
0x46, 0x49, 0x49, 0x49, 0x31,
|
||||||
|
0x01, 0x01, 0x7F, 0x01, 0x01,
|
||||||
|
0x3F, 0x40, 0x40, 0x40, 0x3F,
|
||||||
|
0x1F, 0x20, 0x40, 0x20, 0x1F,
|
||||||
|
0x7F, 0x20, 0x18, 0x20, 0x7F,
|
||||||
|
0x63, 0x14, 0x08, 0x14, 0x63,
|
||||||
|
0x03, 0x04, 0x78, 0x04, 0x03,
|
||||||
|
0x61, 0x51, 0x49, 0x45, 0x43,
|
||||||
|
0x00, 0x00, 0x7F, 0x41, 0x41,
|
||||||
|
0x02, 0x04, 0x08, 0x10, 0x20,
|
||||||
|
0x41, 0x41, 0x7F, 0x00, 0x00,
|
||||||
|
0x04, 0x02, 0x01, 0x02, 0x04,
|
||||||
|
0x40, 0x40, 0x40, 0x40, 0x40,
|
||||||
|
0x00, 0x01, 0x02, 0x04, 0x00,
|
||||||
|
0x20, 0x54, 0x54, 0x54, 0x78,
|
||||||
|
0x7F, 0x48, 0x44, 0x44, 0x38,
|
||||||
|
0x38, 0x44, 0x44, 0x44, 0x20,
|
||||||
|
0x38, 0x44, 0x44, 0x48, 0x7F,
|
||||||
|
0x38, 0x54, 0x54, 0x54, 0x18,
|
||||||
|
0x08, 0x7E, 0x09, 0x01, 0x02,
|
||||||
|
0x08, 0x14, 0x54, 0x54, 0x3C,
|
||||||
|
0x7F, 0x08, 0x04, 0x04, 0x78,
|
||||||
|
0x00, 0x44, 0x7D, 0x40, 0x00,
|
||||||
|
0x20, 0x40, 0x44, 0x3D, 0x00,
|
||||||
|
0x00, 0x7F, 0x10, 0x28, 0x44,
|
||||||
|
0x00, 0x41, 0x7F, 0x40, 0x00,
|
||||||
|
0x7C, 0x04, 0x18, 0x04, 0x78,
|
||||||
|
0x7C, 0x08, 0x04, 0x04, 0x78,
|
||||||
|
0x38, 0x44, 0x44, 0x44, 0x38,
|
||||||
|
0x7C, 0x14, 0x14, 0x14, 0x08,
|
||||||
|
0x08, 0x14, 0x14, 0x18, 0x7C,
|
||||||
|
0x7C, 0x08, 0x04, 0x04, 0x08,
|
||||||
|
0x48, 0x54, 0x54, 0x54, 0x20,
|
||||||
|
0x04, 0x3F, 0x44, 0x40, 0x20,
|
||||||
|
0x3C, 0x40, 0x40, 0x20, 0x7C,
|
||||||
|
0x1C, 0x20, 0x40, 0x20, 0x1C,
|
||||||
|
0x3C, 0x40, 0x30, 0x40, 0x3C,
|
||||||
|
0x44, 0x28, 0x10, 0x28, 0x44,
|
||||||
|
0x0C, 0x50, 0x50, 0x50, 0x3C,
|
||||||
|
0x44, 0x64, 0x54, 0x4C, 0x44,
|
||||||
|
0x00, 0x08, 0x36, 0x41, 0x00,
|
||||||
|
0x00, 0x00, 0x7F, 0x00, 0x00,
|
||||||
|
0x00, 0x41, 0x36, 0x08, 0x00,
|
||||||
|
0x08, 0x08, 0x2A, 0x1C, 0x08,
|
||||||
|
0x08, 0x1C, 0x2A, 0x08, 0x08
|
||||||
|
};
|
||||||
|
#line 6 "E:/ATU-100/fw_mini/1938_mini_board_sources_V_3.1/oled_control.c"
|
||||||
|
void led_send (char nible) {
|
||||||
|
char sdata;
|
||||||
|
sdata = 0;
|
||||||
|
RW = 0; E = 1;
|
||||||
|
sdata = sdata + nible;
|
||||||
|
sdata = sdata << 4;
|
||||||
|
if(LED) sdata = sdata + 8;
|
||||||
|
if(E) sdata = sdata + 4;
|
||||||
|
if(RW) sdata = sdata + 2;
|
||||||
|
if(RS) sdata = sdata + 1;
|
||||||
|
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr);
|
||||||
|
Soft_I2C_Write(sdata);
|
||||||
|
Soft_I2C_Stop();
|
||||||
|
delay_ms(1);
|
||||||
|
sdata = sdata - 4;
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr);
|
||||||
|
Soft_I2C_Write(sdata);
|
||||||
|
Soft_I2C_Stop();
|
||||||
|
delay_ms(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void led_init (void) {
|
||||||
|
led_type = EEPROM_read(1);
|
||||||
|
shift_line = EEPROM_read(7);
|
||||||
|
oled_shift = EEPROM_read(8);
|
||||||
|
if(led_type!=1) oled_init();
|
||||||
|
else{
|
||||||
|
LED = 1;
|
||||||
|
RS = 0;
|
||||||
|
|
||||||
|
led_send(3);
|
||||||
|
delay_ms(5);
|
||||||
|
led_send(3);
|
||||||
|
delay_ms(1);
|
||||||
|
led_send(3);
|
||||||
|
led_send(2);
|
||||||
|
|
||||||
|
led_send(2);
|
||||||
|
led_send(8);
|
||||||
|
|
||||||
|
led_send(0);
|
||||||
|
led_send(8);
|
||||||
|
|
||||||
|
led_send(0);
|
||||||
|
led_send(1);
|
||||||
|
delay_ms(5);
|
||||||
|
|
||||||
|
led_send(0);
|
||||||
|
led_send(4 + 2);
|
||||||
|
|
||||||
|
led_send(0);
|
||||||
|
led_send(8 + 4 + 0 + 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void oled_init (void) {
|
||||||
|
char i, r;
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr);
|
||||||
|
Soft_I2C_Write(0);
|
||||||
|
Soft_I2C_Write (0xAE);
|
||||||
|
|
||||||
|
if(led_type==2 | led_type==3) {
|
||||||
|
Soft_I2C_Write (0xD5);
|
||||||
|
Soft_I2C_Write (0x80);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xA8);
|
||||||
|
Soft_I2C_Write (0x3f);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xD3);
|
||||||
|
if(led_type==2) Soft_I2C_Write (0 + shift_line);
|
||||||
|
else Soft_I2C_Write (31 + shift_line);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x40);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x8D);
|
||||||
|
Soft_I2C_Write (0x14);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x81);
|
||||||
|
Soft_I2C_Write (180);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xD9);
|
||||||
|
Soft_I2C_Write (0x22);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x20);
|
||||||
|
Soft_I2C_Write (0x02);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x21);
|
||||||
|
Soft_I2C_Write (0);
|
||||||
|
Soft_I2C_Write (127);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x2E);
|
||||||
|
|
||||||
|
if(led_type==2) {
|
||||||
|
Soft_I2C_Write (0xA0);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xC0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Soft_I2C_Write (0xA1);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xC8);
|
||||||
|
}
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xDA);
|
||||||
|
Soft_I2C_Write (0x02);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xDB);
|
||||||
|
Soft_I2C_Write (0x40);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Soft_I2C_Write (0xD5);
|
||||||
|
Soft_I2C_Write (0x80);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xA8);
|
||||||
|
Soft_I2C_Write (63);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xD3);
|
||||||
|
Soft_I2C_Write (shift_line);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x40);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x8D);
|
||||||
|
Soft_I2C_Write (0x14);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x81);
|
||||||
|
Soft_I2C_Write (255);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xD9);
|
||||||
|
Soft_I2C_Write (0xf1);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x20);
|
||||||
|
Soft_I2C_Write (0x02);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x21);
|
||||||
|
Soft_I2C_Write (0);
|
||||||
|
Soft_I2C_Write (127);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0x2E);
|
||||||
|
|
||||||
|
if(led_type==4) {
|
||||||
|
Soft_I2C_Write (0xA0);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xC0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Soft_I2C_Write (0xA1);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xC8);
|
||||||
|
}
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xDA);
|
||||||
|
Soft_I2C_Write (0x12);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xDB);
|
||||||
|
Soft_I2C_Write (0x40);
|
||||||
|
}
|
||||||
|
Soft_I2C_Write (0xA4);
|
||||||
|
|
||||||
|
Soft_I2C_Write (0xA6);
|
||||||
|
|
||||||
|
Soft_I2C_Stop ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Delay_ms(100);
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr);
|
||||||
|
Soft_I2C_Write(64);
|
||||||
|
|
||||||
|
if(led_type==2 | led_type==3) {
|
||||||
|
for (r = 0; r <=3; r++) {
|
||||||
|
set_addressing (r, 0);
|
||||||
|
for (i = 0; i < 128; i++, Soft_I2C_Write(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (r = 0; r <=7; r++) {
|
||||||
|
set_addressing (r, 0);
|
||||||
|
for (i = 0; i < 128; i++, Soft_I2C_Write(0x00));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Soft_I2C_Stop ();
|
||||||
|
send_command (0xAF);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void dysp_on() {
|
||||||
|
if(led_type > 1) send_command(0xAF);
|
||||||
|
else if(led_type==1) {
|
||||||
|
LED = 1;
|
||||||
|
RS = 0;
|
||||||
|
led_send(0);
|
||||||
|
led_send(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dysp_off() {
|
||||||
|
if(led_type > 1) send_command(0xAE);
|
||||||
|
else if(led_type==1) {
|
||||||
|
LED = 0;
|
||||||
|
RS = 0;
|
||||||
|
led_send(0);
|
||||||
|
led_send(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void send_command (char oled_command) {
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr);
|
||||||
|
Soft_I2C_Write(128);
|
||||||
|
Soft_I2C_Write(oled_command);
|
||||||
|
Soft_I2C_Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_addressing (char pagenum, char c_start) {
|
||||||
|
char a, b, c;
|
||||||
|
c = c_start + oled_shift;
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr);
|
||||||
|
Soft_I2C_Write(0);
|
||||||
|
Soft_I2C_Write(0xB0 + pagenum);
|
||||||
|
|
||||||
|
if (c <= 15) { a = c; b = 0; }
|
||||||
|
else { b = c / 16; a = c - b * 16; }
|
||||||
|
Soft_I2C_Write (a);
|
||||||
|
Soft_I2C_Write (0x10 + b);
|
||||||
|
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr);
|
||||||
|
Soft_I2C_Write(64);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void led_wr_str (char col, char pos, char str[], char leng ) {
|
||||||
|
char i;
|
||||||
|
if(led_type==4 | led_type==5) oled_wr_str(pos, col, str, leng);
|
||||||
|
else if(led_type==2 | led_type==3) oled_wr_str(7*pos+4, col*2, str, leng);
|
||||||
|
else {
|
||||||
|
|
||||||
|
RS = 0;
|
||||||
|
led_send(8 + col*4);
|
||||||
|
led_send(pos);
|
||||||
|
|
||||||
|
RS = 1;
|
||||||
|
for (i = 0; i < leng; i++) {
|
||||||
|
|
||||||
|
led_send(str[i] >> 4);
|
||||||
|
led_send(str[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void oled_wr_str (char col, char page, char str[], char leng ) {
|
||||||
|
char i, h, g, w1, w2;
|
||||||
|
Soft_I2C_Start();
|
||||||
|
Soft_I2C_Write(led_addr);
|
||||||
|
Soft_I2C_Write(64);
|
||||||
|
|
||||||
|
set_addressing (page, col);
|
||||||
|
|
||||||
|
for (i = 0; i < leng; i++) {
|
||||||
|
if (str[i] == 0) g = 0; else g = str[i] - 32;
|
||||||
|
for (h = 0; h <= 4; h++) {
|
||||||
|
w1 = font5x8[g*5+h];
|
||||||
|
if(page!=2 & page!=4 & page!=6) {
|
||||||
|
w2.B7 = w1.B3;
|
||||||
|
w2.B6 = w1.B3;
|
||||||
|
w2.B5 = w1.B2;
|
||||||
|
w2.B4 = w1.B2;
|
||||||
|
w2.B3 = w1.B1;
|
||||||
|
w2.B2 = w1.B1;
|
||||||
|
w2.B1 = w1.B0;
|
||||||
|
w2.B0 = w1.B0; }
|
||||||
|
else {
|
||||||
|
w2.B7 = w1.B2;
|
||||||
|
w2.B6 = w1.B2;
|
||||||
|
w2.B5 = w1.B1;
|
||||||
|
w2.B4 = w1.B1;
|
||||||
|
w2.B3 = w1.B0;
|
||||||
|
w2.B2 = w1.B0;
|
||||||
|
w2.B1 = 0;
|
||||||
|
w2.B0 = 0;
|
||||||
|
}
|
||||||
|
Soft_I2C_Write(w2);
|
||||||
|
if(led_type==4 | led_type==5) Soft_I2C_Write(w2);
|
||||||
|
}
|
||||||
|
Soft_I2C_Write (0);
|
||||||
|
Soft_I2C_Write (0);
|
||||||
|
|
||||||
|
}
|
||||||
|
set_addressing (page+1, col);
|
||||||
|
|
||||||
|
for (i = 0; i < leng; i++) {
|
||||||
|
if (str[i] == 0) g = 0; else g = str[i] - 32;
|
||||||
|
for (h = 0; h <= 4; h++) {
|
||||||
|
w1 = font5x8[g*5+h];
|
||||||
|
if(page!=2 & page!=4 & page!=6) {
|
||||||
|
w2.B7 = w1.B7;
|
||||||
|
w2.B6 = w1.B7;
|
||||||
|
w2.B5 = w1.B6;
|
||||||
|
w2.B4 = w1.B6;
|
||||||
|
w2.B3 = w1.B5;
|
||||||
|
w2.B2 = w1.B5;
|
||||||
|
w2.B1 = w1.B4;
|
||||||
|
w2.B0 = w1.B4; }
|
||||||
|
else {
|
||||||
|
w2.B7 = w1.B6;
|
||||||
|
w2.B6 = w1.B6;
|
||||||
|
w2.B5 = w1.B5;
|
||||||
|
w2.B4 = w1.B5;
|
||||||
|
w2.B3 = w1.B4;
|
||||||
|
w2.B2 = w1.B4;
|
||||||
|
w2.B1 = w1.B3;
|
||||||
|
w2.B0 = w1.B3;
|
||||||
|
}
|
||||||
|
Soft_I2C_Write(w2);
|
||||||
|
if(led_type==4 | led_type==5) Soft_I2C_Write(w2);
|
||||||
|
}
|
||||||
|
Soft_I2C_Write (0);
|
||||||
|
Soft_I2C_Write (0);
|
||||||
|
|
||||||
|
}
|
||||||
|
Soft_I2C_Stop ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Soft_I2C_Init () {
|
||||||
|
led_addr = EEPROM_read(0);
|
||||||
|
led_type = EEPROM_read(1);
|
||||||
|
|
||||||
|
if(led_type==0) {
|
||||||
|
Soft_I2C_Scl_Direction = 0;
|
||||||
|
Soft_I2C_Sda_Direction = 0;
|
||||||
|
LATB.B6 = 1;
|
||||||
|
LATB.B7 = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Soft_I2C_Scl_Direction = 1;
|
||||||
|
Soft_I2C_Sda_Direction = 1;
|
||||||
|
Soft_I2C_Scl = 0;
|
||||||
|
Soft_I2C_Sda = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Soft_I2C_Start () {
|
||||||
|
if(led_type!=0) {
|
||||||
|
Soft_I2C_Scl_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Sda_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Sda_Direction = 0;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 0;
|
||||||
|
Delay_us(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Soft_I2C_Write (char d) {
|
||||||
|
char i;
|
||||||
|
if(led_type!=0) {
|
||||||
|
for(i=0; i<=7; i++) {
|
||||||
|
if(d.B7==0) Soft_I2C_Sda_Direction = 0; else Soft_I2C_Sda_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 0;
|
||||||
|
Delay_us(5);
|
||||||
|
d = d << 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Soft_I2C_Sda_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 0;
|
||||||
|
Delay_us(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Soft_I2C_Stop () {
|
||||||
|
if(led_type!=0) {
|
||||||
|
Soft_I2C_Sda_Direction = 0;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Scl_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
Soft_I2C_Sda_Direction = 1;
|
||||||
|
Delay_us(5);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
// Software I2C connections
|
||||||
|
//
|
||||||
|
sbit Soft_I2C_Scl at LATB6_bit;
|
||||||
|
sbit Soft_I2C_Sda at LATB7_bit;
|
||||||
|
sbit Soft_I2C_Scl_Direction at TRISB6_bit;
|
||||||
|
sbit Soft_I2C_Sda_Direction at TRISB7_bit;
|
||||||
|
//
|
||||||
|
static char RS, RW, E, LED, nible;
|
||||||
|
|
||||||
|
static char led_addr;
|
||||||
|
static char led_type;
|
||||||
|
static char shift_line;
|
||||||
|
|
||||||
|
static char oled_shift;
|
||||||
|
//
|
||||||
|
void set_addressing (char, char);
|
||||||
|
void led_send (char);
|
||||||
|
void led_init (void);
|
||||||
|
void oled_init (void);
|
||||||
|
void dysp_on (void);
|
||||||
|
void dysp_off (void);
|
||||||
|
void send_command (char);
|
||||||
|
void set_addressing (char, char);
|
||||||
|
void led_wr_str (char, char, char*, char);
|
||||||
|
void oled_wr_str (char, char, char*, char);
|
||||||
|
//
|
||||||
|
|
||||||
|
void Soft_I2C_Init (void);
|
||||||
|
void Soft_I2C_Start (void);
|
||||||
|
void Soft_I2C_Write (char);
|
||||||
|
void Soft_I2C_Stop (void);
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Bookmarks]
|
||||||
|
Count=0
|
||||||
|
[Position]
|
||||||
|
Line=21
|
||||||
|
Column=8
|
||||||
|
[BreakPoints]
|
||||||
|
Count=0
|
||||||
|
[FoldedLines]
|
||||||
|
Count=0
|
Plik binarny nie jest wyświetlany.
|
@ -0,0 +1,72 @@
|
||||||
|
|
||||||
|
_pic_init:
|
||||||
|
|
||||||
|
;pic_init.c,6 :: void pic_init (void) {
|
||||||
|
;pic_init.c,7 :: WDTCON.B5 = 0;
|
||||||
|
BCF WDTCON+0, 5
|
||||||
|
;pic_init.c,8 :: WDTCON.B4 = 1;
|
||||||
|
BSF WDTCON+0, 4
|
||||||
|
;pic_init.c,9 :: WDTCON.B3 = 0; // 1 sec WDT
|
||||||
|
BCF WDTCON+0, 3
|
||||||
|
;pic_init.c,10 :: WDTCON.B2 = 1;
|
||||||
|
BSF WDTCON+0, 2
|
||||||
|
;pic_init.c,11 :: WDTCON.B1 = 0;
|
||||||
|
BCF WDTCON+0, 1
|
||||||
|
;pic_init.c,12 :: asm CLRWDT
|
||||||
|
CLRWDT
|
||||||
|
;pic_init.c,14 :: ANSELA = 0;
|
||||||
|
CLRF ANSELA+0
|
||||||
|
;pic_init.c,15 :: ANSA0_bit = 1; // analog inputs
|
||||||
|
BSF ANSA0_bit+0, BitPos(ANSA0_bit+0)
|
||||||
|
;pic_init.c,16 :: ANSA1_bit = 1;
|
||||||
|
BSF ANSA1_bit+0, BitPos(ANSA1_bit+0)
|
||||||
|
;pic_init.c,17 :: ANSELB = 0; // all as digital
|
||||||
|
CLRF ANSELB+0
|
||||||
|
;pic_init.c,19 :: C1ON_bit = 0; // Disable comparators
|
||||||
|
BCF C1ON_bit+0, BitPos(C1ON_bit+0)
|
||||||
|
;pic_init.c,20 :: C2ON_bit = 0;
|
||||||
|
BCF C2ON_bit+0, BitPos(C2ON_bit+0)
|
||||||
|
;pic_init.c,22 :: OSCCON = 0b01111000; // 16 MHz oscillator
|
||||||
|
MOVLW 120
|
||||||
|
MOVWF OSCCON+0
|
||||||
|
;pic_init.c,24 :: PORTA = 0;
|
||||||
|
CLRF PORTA+0
|
||||||
|
;pic_init.c,25 :: PORTB = 0;
|
||||||
|
CLRF PORTB+0
|
||||||
|
;pic_init.c,26 :: PORTC = 0;
|
||||||
|
CLRF PORTC+0
|
||||||
|
;pic_init.c,27 :: LATA = 0b00001000; // PORT3 /Tx_req to 1
|
||||||
|
MOVLW 8
|
||||||
|
MOVWF LATA+0
|
||||||
|
;pic_init.c,28 :: LATB = 0;
|
||||||
|
CLRF LATB+0
|
||||||
|
;pic_init.c,29 :: LATC = 0;
|
||||||
|
CLRF LATC+0
|
||||||
|
;pic_init.c,30 :: TRISA = 0b00000011;
|
||||||
|
MOVLW 3
|
||||||
|
MOVWF TRISA+0
|
||||||
|
;pic_init.c,31 :: TRISB = 0b11111111;
|
||||||
|
MOVLW 255
|
||||||
|
MOVWF TRISB+0
|
||||||
|
;pic_init.c,32 :: TRISC = 0b00000000; //
|
||||||
|
CLRF TRISC+0
|
||||||
|
;pic_init.c,34 :: ADC_Init();
|
||||||
|
CALL _ADC_Init+0
|
||||||
|
;pic_init.c,37 :: ADCON1.B0 = 1; // ADC with the internal reference
|
||||||
|
BSF ADCON1+0, 0
|
||||||
|
;pic_init.c,38 :: ADCON1.B1 = 1;
|
||||||
|
BSF ADCON1+0, 1
|
||||||
|
;pic_init.c,40 :: OPTION_REG.B7 = 0;
|
||||||
|
BCF OPTION_REG+0, 7
|
||||||
|
;pic_init.c,41 :: WPUB.B0 = 1; // PORTB0 Pull-up resistor
|
||||||
|
BSF WPUB+0, 0
|
||||||
|
;pic_init.c,42 :: WPUB.B1 = 1; // PORTB1 Pull-up resistor
|
||||||
|
BSF WPUB+0, 1
|
||||||
|
;pic_init.c,43 :: WPUB.B2 = 1; // PORTB2 Pull-up resistor
|
||||||
|
BSF WPUB+0, 2
|
||||||
|
;pic_init.c,45 :: GIE_bit = 0;
|
||||||
|
BCF GIE_bit+0, BitPos(GIE_bit+0)
|
||||||
|
;pic_init.c,47 :: }
|
||||||
|
L_end_pic_init:
|
||||||
|
RETURN
|
||||||
|
; end of _pic_init
|
|
@ -0,0 +1,47 @@
|
||||||
|
// pic_init unit for Micro C PRO
|
||||||
|
// David Fainitski for ATU-100 project
|
||||||
|
// PIC18F2520 Microchip
|
||||||
|
|
||||||
|
|
||||||
|
void pic_init (void) {
|
||||||
|
WDTCON.B5 = 0;
|
||||||
|
WDTCON.B4 = 1;
|
||||||
|
WDTCON.B3 = 0; // 1 sec WDT
|
||||||
|
WDTCON.B2 = 1;
|
||||||
|
WDTCON.B1 = 0;
|
||||||
|
asm CLRWDT
|
||||||
|
|
||||||
|
ANSELA = 0;
|
||||||
|
ANSA0_bit = 1; // analog inputs
|
||||||
|
ANSA1_bit = 1;
|
||||||
|
ANSELB = 0; // all as digital
|
||||||
|
|
||||||
|
C1ON_bit = 0; // Disable comparators
|
||||||
|
C2ON_bit = 0;
|
||||||
|
|
||||||
|
OSCCON = 0b01111000; // 16 MHz oscillator
|
||||||
|
|
||||||
|
PORTA = 0;
|
||||||
|
PORTB = 0;
|
||||||
|
PORTC = 0;
|
||||||
|
LATA = 0b00001000; // PORT3 /Tx_req to 1
|
||||||
|
LATB = 0;
|
||||||
|
LATC = 0;
|
||||||
|
TRISA = 0b00000011;
|
||||||
|
TRISB = 0b11111111;
|
||||||
|
TRISC = 0b00000000; //
|
||||||
|
//
|
||||||
|
ADC_Init();
|
||||||
|
//
|
||||||
|
|
||||||
|
ADCON1.B0 = 1; // ADC with the internal reference
|
||||||
|
ADCON1.B1 = 1;
|
||||||
|
//
|
||||||
|
OPTION_REG.B7 = 0;
|
||||||
|
WPUB.B0 = 1; // PORTB0 Pull-up resistor
|
||||||
|
WPUB.B1 = 1; // PORTB1 Pull-up resistor
|
||||||
|
WPUB.B2 = 1; // PORTB2 Pull-up resistor
|
||||||
|
//interrupt setting
|
||||||
|
GIE_bit = 0;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Bookmarks]
|
||||||
|
Count=0
|
||||||
|
[Position]
|
||||||
|
Line=43
|
||||||
|
Column=43
|
||||||
|
[BreakPoints]
|
||||||
|
Count=0
|
||||||
|
[FoldedLines]
|
||||||
|
Count=0
|
|
@ -0,0 +1,48 @@
|
||||||
|
#line 1 "E:/ATU-100/fw_mini/1938_mini_board_sources_V_3.1/pic_init.c"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void pic_init (void) {
|
||||||
|
WDTCON.B5 = 0;
|
||||||
|
WDTCON.B4 = 1;
|
||||||
|
WDTCON.B3 = 0;
|
||||||
|
WDTCON.B2 = 1;
|
||||||
|
WDTCON.B1 = 0;
|
||||||
|
asm CLRWDT
|
||||||
|
|
||||||
|
ANSELA = 0;
|
||||||
|
ANSA0_bit = 1;
|
||||||
|
ANSA1_bit = 1;
|
||||||
|
ANSELB = 0;
|
||||||
|
|
||||||
|
C1ON_bit = 0;
|
||||||
|
C2ON_bit = 0;
|
||||||
|
|
||||||
|
OSCCON = 0b01111000;
|
||||||
|
|
||||||
|
PORTA = 0;
|
||||||
|
PORTB = 0;
|
||||||
|
PORTC = 0;
|
||||||
|
LATA = 0b00001000;
|
||||||
|
LATB = 0;
|
||||||
|
LATC = 0;
|
||||||
|
TRISA = 0b00000011;
|
||||||
|
TRISB = 0b11111111;
|
||||||
|
TRISC = 0b00000000;
|
||||||
|
|
||||||
|
ADC_Init();
|
||||||
|
|
||||||
|
|
||||||
|
ADCON1.B0 = 1;
|
||||||
|
ADCON1.B1 = 1;
|
||||||
|
|
||||||
|
OPTION_REG.B7 = 0;
|
||||||
|
WPUB.B0 = 1;
|
||||||
|
WPUB.B1 = 1;
|
||||||
|
WPUB.B2 = 1;
|
||||||
|
|
||||||
|
GIE_bit = 0;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Connections
|
||||||
|
//
|
||||||
|
sbit Low at LATC0_bit;
|
||||||
|
sbit Mid at LATC6_bit;
|
||||||
|
sbit High at LATC7_bit;
|
||||||
|
sbit n_Tx at LATA3_bit;
|
||||||
|
sbit p_Tx at LATA7_bit;
|
||||||
|
//
|
||||||
|
//sbit Button at RB0_bit;
|
||||||
|
//sbit BYP_button at RB5_bit;
|
||||||
|
//sbit Auto_button at RB4_bit;
|
||||||
|
//
|
||||||
|
sbit Cap_10 at LATC1_bit;
|
||||||
|
sbit Cap_22 at LATC2_bit;
|
||||||
|
sbit Cap_47 at LATC3_bit;
|
||||||
|
sbit Cap_100 at LATC4_bit;
|
||||||
|
sbit Cap_220 at LATC5_bit;
|
||||||
|
sbit Cap_sw at LATA6_bit;
|
||||||
|
//
|
||||||
|
sbit Ind_011 at LATB1_bit;
|
||||||
|
sbit Ind_022 at LATB2_bit;
|
||||||
|
sbit Ind_045 at LATA2_bit;
|
||||||
|
sbit Ind_1 at LATA4_bit;
|
||||||
|
sbit Ind_22 at LATA5_bit;
|
||||||
|
//
|
||||||
|
void pic_init (void);
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Bookmarks]
|
||||||
|
Count=0
|
||||||
|
[Position]
|
||||||
|
Line=26
|
||||||
|
Column=22
|
||||||
|
[BreakPoints]
|
||||||
|
Count=0
|
||||||
|
[FoldedLines]
|
||||||
|
Count=0
|
Plik binarny nie jest wyświetlany.
Ładowanie…
Reference in New Issue