0 Anggota dan 1 Pengunjung sedang melihat topik ini.
$regfile = "M8def.dat"$crystal = 8000000$hwstack = 32$swstack = 10$framesize = 40Config Lcd = 16 * 2Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.1 , Rs = Portd.0Config Portb.0 = OutputConfig Portb.1 = OutputConfig Portb.2 = OutputConfig Portb.3 = OutputConfig Portb.4 = OutputConfig Portb.5 = OutputConfig Portc.0 = OutputConfig Portc.1 = OutputConfig Portc.2 = OutputConfig Portc.3 = OutputConfig Portc.4 = OutputConfig Portc.5 = OutputConfig Pinb.6 = InputConfig Pinb.7 = InputConfig Pind.2 = InputConfig Pind.3 = InputDeclare Sub PrintlcdDeclare Sub Setmc145151Const Minfreq = 8750Const Maxfreq = 10800Dim Eeromfreq As Eram WordDim Mainfreq As WordDim Isstereo As BitDim Islock As BitDim Flagset As BitCursor Off NoblinkClsMainfreq = EeromfreqIf Mainfreq < Minfreq Then Mainfreq = MinfreqIf Mainfreq > Maxfreq Then Mainfreq = MaxfreqIsstereo = Not Pind.2Islock = Not Pind.3Locate 1 , 3Lcd "ATmega8 PLL"Locate 2 , 4Lcd "Controller"Waitms 2000ClsCall PrintlcdCall Setmc145151Program: If Pinb.6 = 1 Then Mainfreq = Mainfreq + 5 If Mainfreq > Maxfreq Then Mainfreq = Minfreq End If Call Printlcd Call Setmc145151 End If If Pinb.7 = 1 Then Mainfreq = Mainfreq - 5 If Mainfreq < Minfreq Then Mainfreq = Maxfreq End If Call Printlcd Call Setmc145151 End If If Pind.3 <> Islock Then Islock = Pind.3 If Islock = 1 Then Locate 1 , 11 Lcd " LOCK" Else Locate 1 , 11 Lcd "UNLOCK" End If End If If Pind.2 <> Isstereo Then Isstereo = Pind.2 If Isstereo = 1 Then Locate 1 , 1 Lcd "STEREO" Else Locate 1 , 1 Lcd "MONO " End If End IfGoto ProgramSub Setmc145151Dim Con As ByteDim Root As WordDim Subfreq As WordDim Temroot As WordDim Datapll(12) As Byte Subfreq = Mainfreq / 5 For Con = 0 To 11 Root = 2 ^ Con Temroot = Subfreq And Root If Temroot > 0 Then Datapll(con + 1) = 1 Else Datapll(con + 1) = 0 End If Next Con Portb.0 = Datapll(1) Portb.1 = Datapll(2) Portb.2 = Datapll(3) Portb.3 = Datapll(4) Portb.4 = Datapll(5) Portb.5 = Datapll(6) Portc.0 = Datapll(7) Portc.1 = Datapll(8) Portc.2 = Datapll(9) Portc.3 = Datapll(10) Portc.4 = Datapll(11) Portc.5 = Datapll(12) Eeromfreq = MainfreqEnd SubSub PrintlcdDim Strfreq As String * 5Dim Comfreq As ByteDim Lenfreq As Byte Strfreq = Str(mainfreq) Lenfreq = Len(strfreq) Comfreq = Lenfreq - 2 Locate 2 , 1 If Lenfreq = 4 Then Lcd "FREQ " Locate 2 , 7 Else Lcd "FREQ " Locate 2 , 6 End If Lcd Left(strfreq , Comfreq) + "." + Right(strfreq , 2) Locate 2 , 14 Lcd "MHz" Waitms 500End SubEnd