JI1FGX/DU9 ミンダナオ日記 AVRマイコンのプログラミング(2010/06/07) |
|
---|---|
以前日本の共立電子デジットで購入したAVR ATMEGA88を使ってレピーターコントローラーを作っていました 途中体調不良や暑くて逃避モードに入って中々進みませんでしたが、やっと全体像が見えてきました 開発環境はBASCOM-AVRベーシックのお試し版 ところが途中で4KBを超えてしまい、1万円を出して正式版を購入しました ターゲットはMEGA-8-V1とそれに独自で作ったインターフェースです |
|
このソースコードはATMEGA88にあわせて作られています。 レピーターコントロール部分は完成していますが、このCWルーチンのマージが終わってから全体像を公開します。 それにしてもいまだにベーシックから抜け出せない悲しさ。コーア技研戦闘員からはCかアセンブラですよねと冷たく突き放されています |
|
' Copyright ©2008-2009 JI1FGX Kouichi Ueno ' $regfile = "m88def.dat" ' specify the used micro $crystal = 1280000 ' used crystal frequency $baud = 19200 ' use baud rate $hwstack = 32 ' default use 32 for the hardware stack $swstack = 10 ' default use 10 for the SW stack $framesize = 40 ' default use 40 for the frame space $default Eram Dim Eeprom_value(22) As Eram Byte At $01 $default Sram Dim Modechar(5) As String * 20 Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 Config Lcdpin = Pin , E = Portb.3 , Rs = Portb.2 Modechar(5) = "DE JI1FGX/DU9" Declare Sub Cw() Config Lcd = 20 * 4 'configure lcd screen Config Portd = Input Config Portd.7 = Output Config Portd.7 = Output Config Portc = &B110000 Set Portc.5 Set Portc.6 '&B110000 Call Cw End Sub Cw() Dim In_char As String * 1 Dim CW_data As String * 5 Dim M As String * 1 Dim Cwlen As Byte Dim Cwcodelen As Byte Cls For Cwlen = 1 To Len(modechar(5)) Locate 2 , Cwlen Lcd Mid(modechar(5) , Cwlen , 1) In_char = Mid(modechar(5) , Cwlen , 1) If In_char = " " Then CW_data = " " If In_char = "A" Then CW_data = ".-" If In_char = "B" Then CW_data = "-..." If In_char = "C" Then CW_data = "-.-." If In_char = "D" Then CW_data = "-.." If In_char = "E" Then CW_data = "." If In_char = "F" Then CW_data = "..-." If In_char = "G" Then CW_data = "--." If In_char = "H" Then CW_data = "...." If In_char = "I" Then CW_data = ".." If In_char = "J" Then CW_data = ".---" If In_char = "K" Then CW_data = "-.-" If In_char = "L" Then CW_data = ".-.." If In_char = "M" Then CW_data = "--" If In_char = "N" Then CW_data = "-." If In_char = "O" Then CW_data = "---" If In_char = "P" Then CW_data = ".--." If In_char = "Q" Then CW_data = "--.-" If In_char = "R" Then CW_data = ".-." If In_char = "S" Then CW_data = "..." If In_char = "T" Then CW_data = "-" If In_char = "U" Then CW_data = "..-" If In_char = "V" Then CW_data = "...-" If In_char = "W" Then CW_data = ".--" If In_char = "X" Then CW_data = "-..-" If In_char = "Y" Then CW_data = "-.--" If In_char = "Z" Then CW_data = "--.." If In_char = "0" Then CW_data = "-----" If In_char = "1" Then CW_data = ".----" If In_char = "2" Then CW_data = "..---" If In_char = "3" Then CW_data = "...--" If In_char = "4" Then CW_data = "....-" If In_char = "5" Then CW_data = "....." If In_char = "6" Then CW_data = "-...." If In_char = "7" Then CW_data = "--..." If In_char = "8" Then CW_data = "---.." If In_char = "9" Then CW_data = "----." If In_char = "/" Then CW_data = "-..-." For Cwcodelen = 1 To Len(CW_data) If Mid(CW_data , Cwcodelen , 1) = "." Then Sound Portc.4 , 100 , 100 If Mid(CW_data , Cwcodelen , 1) = "-" Then Sound Portc.4 , 300 , 100 If Mid(CW_data , Cwcodelen , 1) = " " Then Waitms 80 Waitms 30 Next Waitms 200 Next End Sub End |