سلام
میخاستم راهنمایی کنید 2 تا برنامه یکیش atmega16 یکیشم attiny26 با کدویژن که پروگرم میکنی
6 تا ارور و 5تا وارنینگ تو اولی و 1ارور و1 وارنینگ تو دومی میده میشه کمک کنید اینهارو برطرف کنیم.
خواهشن سریع تا یک هفته دیگه باید پروژه تحویل بدم(فرستنده وگیرنده مادون قرمز 13کانال)
$regfile = "m16def.dat"
$crystal = 12000000
$baud = 2400
Config Lcdpin = Pin , Db4 = Pinc.0 , Db5 = Pinc.1 , Db6 = _
Pinc.2 , Db7 = Pinc.3 , Rs = Pinc.4 , E = Pinc.5
Config Lcd = 16 * 1
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = _
Clear Down , Prescale = 1
Config Timer0 = Timer , Prescale = 1024
Config Porta = Output
Config Portd = Output
Declare Sub Volume
Declare Sub Device
Dim Rec_b As Byte
Dim C As Byte
Dim Num As Byte
Dim D As Byte
Dim D1 As Byte
Dim B1 As Bit
Dim B2 As Byte
Dim Code As Integer
Dim Chanal As Integer
Dim Vol As Byte
Dim Pow As Bit
Dim Up_down As Bit
Enable Interrupts
Enable Ovf0
On Ovf0 T0_int
Enable Urxc
On Urxc Intlab
Cls
Lcd "start>"
Lowerline
D = 0
Code = 0
Chanal = Code
Vol = 10
Pow = 0
Porta.1 = Not Pow
Porta = &H0F
Pwm1a = Vol * 10
Start Timer1
'***********
Do
If Pow = 0 Then
Reset Porta.2
Waitms 300
Set Porta.2
Waitms 1000
End If
Loop
End
'===========
Intlab:
B1 = 0
D1 = 3
B2 = 0
Timer0 = &H00
Start Timer0
'==============
Rec_b = Inkey()
If Rec_b = C Then B1 = 1
C = Rec_b
Num = Rec_b
If Num = 10 Then Num = 0
'==============
Select Case Num
Case 11:
If Pow = 1 Then
Up_down = 0
Call Volume
End If
Case 12:
If Pow = 1 Then
Up_down = 1
Call Volume
End If
Case 13:
If B1 = 0 Then
Toggle Pow
Porta.1 = Not Pow
If Pow = 1 Then
Cls
Lcd "Ch>>" ; Chanal
Lowerline
D = 0
Code = 0
Else
Cls
Lcd "Standby"
Lowerline
End If
End If
Case Else:
If Pow = 1 Then
If B1 = 0 Then
If Num < 10 Then
If D < 3 Then
Incr D
If D = 1 Then
Cls
Lcd "Ch>>" ; Chanal
End If
Code = Code * 10
Code = Code + Num
Lowerline
Lcd Code
If D = 3 Then
Cls
Chanal = Code
Lcd "Ch>>" ; Chanal
Call Device
Lowerline
D = 0
Code = 0
End If
End If
End If
End If
End If
End Select
If Pow = 1 Then Toggle Porta.0
Return
'***************
T0_int:
Decr D1
If D1 = 0 Then
Select Case B2
Case 0:
Stop Timer0
Reset Porta.2
Waitms 5
Set Porta.2
If D < 3 Then
If D > 0 Then
D1 = 30
B2 = 2
Timer0 = &H00
Start Timer0
End If
End If
Case 1:
Cls
Lcd "Ch>>" ; Chanal
Lowerline
Stop Timer0
Case 2:
Cls
Chanal = Code
Lcd "Ch>>" ; Chanal
Lowerline
D = 0
Code = 0
Stop Timer0
End Select
C = 0
End If
Set Porta.0
Return
'*****************
Sub Volume:
D = 0
Code = 0
D1 = 80
B2 = 1
Timer0 = &H00
Start Timer0
If B1 = 0 Then
Cls
Lcd "Volume:"
End If
If Up_down = 1 Then
If Vol < 100 Then
Incr Vol
End If
Else
If Vol > 0 Then
Decr Vol
End If
End If
Lowerline
Lcd " "
Lowerline
Lcd Vol
Pwm1a = 10 * Vol
End Sub
'====================
Sub Device:
If Chanal = 123 Then
Toggle Porta.7
End If
End Sub
...
$regfile = "Attiny26.dat"
$crystal = 8000000
Config Porta = Input
Config Portb = Input
Open "COMb.4:2400,8,n,1,inverted" For Output As #2
Config Int0 = Low Level
Enable Interrupts
Enable Int0
On Int0 Ex0_int
Dim B As Bit
Dim C As Bit
Dim A1 As Byte
Dim A2 As Byte
'==============
Do
Powerdown
Loop
End
'**************
Ex0_int:
C = 1
B = 0
A1 = Pina
A2 = Pinb
A2 = A2 And &B00101111
If A2 = &H00 Then
B = 1
Select Case A1
Case 1:
Printbin #2 , 7
Case 2:
Printbin #2 , 4
Case 4:
Printbin #2 , 1
Case 8:
Printbin #2 , 10
Case 16:
Printbin #2 , 2
Case 32:
Printbin #2 , 3
Case 64:
Printbin #2 , 12
C = 0
Case 128:
Printbin #2 , 9
Case Else
B = 0
End Select
End If
'----------------
If A1 = &H00 Then
B = 1
Select Case A2
Case 1:
Printbin #2 , 13
Case 2:
Printbin #2 , 11
C = 0
Case 4:
Printbin #2 , 8
Case 8:
Printbin #2 , 5
Case 32:
Printbin #2 , 6
Case Else
B = 0
End Select
End If
If B = 1 Then Waitms 40
If C = 0 Then Waitms 40
Return
:cry2:
میخاستم راهنمایی کنید 2 تا برنامه یکیش atmega16 یکیشم attiny26 با کدویژن که پروگرم میکنی
6 تا ارور و 5تا وارنینگ تو اولی و 1ارور و1 وارنینگ تو دومی میده میشه کمک کنید اینهارو برطرف کنیم.
خواهشن سریع تا یک هفته دیگه باید پروژه تحویل بدم(فرستنده وگیرنده مادون قرمز 13کانال)
$regfile = "m16def.dat"
$crystal = 12000000
$baud = 2400
Config Lcdpin = Pin , Db4 = Pinc.0 , Db5 = Pinc.1 , Db6 = _
Pinc.2 , Db7 = Pinc.3 , Rs = Pinc.4 , E = Pinc.5
Config Lcd = 16 * 1
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = _
Clear Down , Prescale = 1
Config Timer0 = Timer , Prescale = 1024
Config Porta = Output
Config Portd = Output
Declare Sub Volume
Declare Sub Device
Dim Rec_b As Byte
Dim C As Byte
Dim Num As Byte
Dim D As Byte
Dim D1 As Byte
Dim B1 As Bit
Dim B2 As Byte
Dim Code As Integer
Dim Chanal As Integer
Dim Vol As Byte
Dim Pow As Bit
Dim Up_down As Bit
Enable Interrupts
Enable Ovf0
On Ovf0 T0_int
Enable Urxc
On Urxc Intlab
Cls
Lcd "start>"
Lowerline
D = 0
Code = 0
Chanal = Code
Vol = 10
Pow = 0
Porta.1 = Not Pow
Porta = &H0F
Pwm1a = Vol * 10
Start Timer1
'***********
Do
If Pow = 0 Then
Reset Porta.2
Waitms 300
Set Porta.2
Waitms 1000
End If
Loop
End
'===========
Intlab:
B1 = 0
D1 = 3
B2 = 0
Timer0 = &H00
Start Timer0
'==============
Rec_b = Inkey()
If Rec_b = C Then B1 = 1
C = Rec_b
Num = Rec_b
If Num = 10 Then Num = 0
'==============
Select Case Num
Case 11:
If Pow = 1 Then
Up_down = 0
Call Volume
End If
Case 12:
If Pow = 1 Then
Up_down = 1
Call Volume
End If
Case 13:
If B1 = 0 Then
Toggle Pow
Porta.1 = Not Pow
If Pow = 1 Then
Cls
Lcd "Ch>>" ; Chanal
Lowerline
D = 0
Code = 0
Else
Cls
Lcd "Standby"
Lowerline
End If
End If
Case Else:
If Pow = 1 Then
If B1 = 0 Then
If Num < 10 Then
If D < 3 Then
Incr D
If D = 1 Then
Cls
Lcd "Ch>>" ; Chanal
End If
Code = Code * 10
Code = Code + Num
Lowerline
Lcd Code
If D = 3 Then
Cls
Chanal = Code
Lcd "Ch>>" ; Chanal
Call Device
Lowerline
D = 0
Code = 0
End If
End If
End If
End If
End If
End Select
If Pow = 1 Then Toggle Porta.0
Return
'***************
T0_int:
Decr D1
If D1 = 0 Then
Select Case B2
Case 0:
Stop Timer0
Reset Porta.2
Waitms 5
Set Porta.2
If D < 3 Then
If D > 0 Then
D1 = 30
B2 = 2
Timer0 = &H00
Start Timer0
End If
End If
Case 1:
Cls
Lcd "Ch>>" ; Chanal
Lowerline
Stop Timer0
Case 2:
Cls
Chanal = Code
Lcd "Ch>>" ; Chanal
Lowerline
D = 0
Code = 0
Stop Timer0
End Select
C = 0
End If
Set Porta.0
Return
'*****************
Sub Volume:
D = 0
Code = 0
D1 = 80
B2 = 1
Timer0 = &H00
Start Timer0
If B1 = 0 Then
Cls
Lcd "Volume:"
End If
If Up_down = 1 Then
If Vol < 100 Then
Incr Vol
End If
Else
If Vol > 0 Then
Decr Vol
End If
End If
Lowerline
Lcd " "
Lowerline
Lcd Vol
Pwm1a = 10 * Vol
End Sub
'====================
Sub Device:
If Chanal = 123 Then
Toggle Porta.7
End If
End Sub
...
$regfile = "Attiny26.dat"
$crystal = 8000000
Config Porta = Input
Config Portb = Input
Open "COMb.4:2400,8,n,1,inverted" For Output As #2
Config Int0 = Low Level
Enable Interrupts
Enable Int0
On Int0 Ex0_int
Dim B As Bit
Dim C As Bit
Dim A1 As Byte
Dim A2 As Byte
'==============
Do
Powerdown
Loop
End
'**************
Ex0_int:
C = 1
B = 0
A1 = Pina
A2 = Pinb
A2 = A2 And &B00101111
If A2 = &H00 Then
B = 1
Select Case A1
Case 1:
Printbin #2 , 7
Case 2:
Printbin #2 , 4
Case 4:
Printbin #2 , 1
Case 8:
Printbin #2 , 10
Case 16:
Printbin #2 , 2
Case 32:
Printbin #2 , 3
Case 64:
Printbin #2 , 12
C = 0
Case 128:
Printbin #2 , 9
Case Else
B = 0
End Select
End If
'----------------
If A1 = &H00 Then
B = 1
Select Case A2
Case 1:
Printbin #2 , 13
Case 2:
Printbin #2 , 11
C = 0
Case 4:
Printbin #2 , 8
Case 8:
Printbin #2 , 5
Case 32:
Printbin #2 , 6
Case Else
B = 0
End Select
End If
If B = 1 Then Waitms 40
If C = 0 Then Waitms 40
Return
:cry2:
دیدگاه