حالا جدا از اینها اینطور که دارم محاسبه می کنم حافظه اتمگا 128 کم میاد !
4017 رو هم اضافه کردم و برنامه شد این :
کد php:
$regfile = "m128def.dat" : $crystal = 8000000 : $baud = 1200
Print "WWW.IRANLED.COM"
Dim F As Word , F_old As Word , B As Byte
F_old = 1
'-------------------------------------------------------------------------------
Do
F_old = F : F = 0
Gosub Test_4001
Gosub Test_4011
Gosub Test_4017
Gosub Test_4081
If F <> F_old And F = 0 Then : Print "PLEASE INSERT IC"
Elseif F <> F_old And F <> 0 Then : Print F
End If
Loop
'-------------------------------------------------------------------------------
Test_4001:
Ddra = 255 : Ddrc = 255 : Porta = 0 : Portc = 0 : Waitus 10
Ddra = &B01110011 : Ddrc = &B01100111 : Waitus 10
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
If Pina.2 = 0 Or Pina.3 = 0 Or Pinc.3 = 0 Or Pinc.4 = 0 Then Return
Porta = &B00100001 : Portc = &B01000011 : Waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00010010 : Portc = &B00100101 : Waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00110011 : Portc = &B01100111 : Waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
F = 4001 : Waitms 500
Return
'-------------------------------------------------------------------------------
Test_4011:
Ddra = 255 : Ddrc = 255 : Porta = 0 : Portc = 0 : Waitus 10
Ddra = &B01110011 : Ddrc = &B01100111 : Waitus 10
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
If Pina.2 = 0 Or Pina.3 = 0 Or Pinc.3 = 0 Or Pinc.4 = 0 Then Return
Porta = &B00100001 : Portc = &B01000011 : Waitus 10
If Pina.2 = 0 Or Pina.3 = 0 Or Pinc.3 = 0 Or Pinc.4 = 0 Then Return
Porta = &B00010010 : Portc = &B00100101 : Waitus 10
If Pina.2 = 0 Or Pina.3 = 0 Or Pinc.3 = 0 Or Pinc.4 = 0 Then Return
Porta = &B00110011 : Portc = &B01100111 : Waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
F = 4011 : Waitms 500
Return
'-------------------------------------------------------------------------------
Test_4017:
Ddra = 255 : Ddrc = 255 : Porta = 0 : Portc = 0 : Waitus 10
Ddra = &B10000000 : Ddrc = &B00000111 : Waitus 10
Porta = &B00000000 : Portc = &B00000001 : Waitus 10 '0
If Pina.2 = 0 Or Pina.1 = 1 Or Pina.3 = 1 Or Pina.6 = 1 Or Pinc.6 = 1 Or Pina.0 = 1 _
Or Pina.4 = 1 Or Pina.5 = 1 Or Pinc.7 = 1 Or Pinc.5 = 1 Or Pinc.4 = 0 Then Return
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
Porta = &B00000000 : Portc = &B00000101 : Waitus 10 '1
If Pina.2 = 1 Or Pina.1 = 0 Or Pina.3 = 1 Or Pina.6 = 1 Or Pinc.6 = 1 Or Pina.0 = 1 _
Or Pina.4 = 1 Or Pina.5 = 1 Or Pinc.7 = 1 Or Pinc.5 = 1 Or Pinc.4 = 0 Then Return
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
Porta = &B00000000 : Portc = &B00000101 : Waitus 10 '2
If Pina.2 = 1 Or Pina.1 = 1 Or Pina.3 = 0 Or Pina.6 = 1 Or Pinc.6 = 1 Or Pina.0 = 1 _
Or Pina.4 = 1 Or Pina.5 = 1 Or Pinc.7 = 1 Or Pinc.5 = 1 Or Pinc.4 = 0 Then Return
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
Porta = &B00000000 : Portc = &B00000101 : Waitus 10 '3
If Pina.2 = 1 Or Pina.1 = 1 Or Pina.3 = 1 Or Pina.6 = 0 Or Pinc.6 = 1 Or Pina.0 = 1 _
Or Pina.4 = 1 Or Pina.5 = 1 Or Pinc.7 = 1 Or Pinc.5 = 1 Or Pinc.4 = 0 Then Return
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
Porta = &B00000000 : Portc = &B00000101 : Waitus 10 '4
If Pina.2 = 1 Or Pina.1 = 1 Or Pina.3 = 1 Or Pina.6 = 1 Or Pinc.6 = 0 Or Pina.0 = 1 _
Or Pina.4 = 1 Or Pina.5 = 1 Or Pinc.7 = 1 Or Pinc.5 = 1 Or Pinc.4 = 0 Then Return
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
Porta = &B00000000 : Portc = &B00000101 : Waitus 10 '5
If Pina.2 = 1 Or Pina.1 = 1 Or Pina.3 = 1 Or Pina.6 = 1 Or Pinc.6 = 1 Or Pina.0 = 0 _
Or Pina.4 = 1 Or Pina.5 = 1 Or Pinc.7 = 1 Or Pinc.5 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
Porta = &B00000000 : Portc = &B00000101 : Waitus 10 '6
If Pina.2 = 1 Or Pina.1 = 1 Or Pina.3 = 1 Or Pina.6 = 1 Or Pinc.6 = 1 Or Pina.0 = 1 _
Or Pina.4 = 0 Or Pina.5 = 1 Or Pinc.7 = 1 Or Pinc.5 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
Porta = &B00000000 : Portc = &B00000101 : Waitus 10 '7
If Pina.2 = 1 Or Pina.1 = 1 Or Pina.3 = 1 Or Pina.6 = 1 Or Pinc.6 = 1 Or Pina.0 = 1 _
Or Pina.4 = 1 Or Pina.5 = 0 Or Pinc.7 = 1 Or Pinc.5 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
Porta = &B00000000 : Portc = &B00000101 : Waitus 10 '8
If Pina.2 = 1 Or Pina.1 = 1 Or Pina.3 = 1 Or Pina.6 = 1 Or Pinc.6 = 1 Or Pina.0 = 1 _
Or Pina.4 = 1 Or Pina.5 = 1 Or Pinc.7 = 0 Or Pinc.5 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
Porta = &B00000000 : Portc = &B00000101 : Waitus 10 '9
If Pina.2 = 1 Or Pina.1 = 1 Or Pina.3 = 1 Or Pina.6 = 1 Or Pinc.6 = 1 Or Pina.0 = 1 _
Or Pina.4 = 1 Or Pina.5 = 1 Or Pinc.7 = 1 Or Pinc.5 = 0 Or Pinc.4 = 1 Then Return
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
Porta = &B00000000 : Portc = &B00000101 : Waitus 10 '0
If Pina.2 = 0 Or Pina.1 = 1 Or Pina.3 = 1 Or Pina.6 = 1 Or Pinc.6 = 1 Or Pina.0 = 1 _
Or Pina.4 = 1 Or Pina.5 = 1 Or Pinc.7 = 1 Or Pinc.5 = 1 Or Pinc.4 = 0 Then Return
F = 4017 : Waitms 500
Return
'-------------------------------------------------------------------------------
Test_4081:
Ddra = 255 : Ddrc = 255 : Porta = 0 : Portc = 0 : Waitus 10
Ddra = &B01110011 : Ddrc = &B01100111 : Waitus 10
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00100001 : Portc = &B01000011 : Waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00010010 : Portc = &B00100101 : Waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00110011 : Portc = &B01100111 : Waitus 10
If Pina.2 = 0 Or Pina.3 = 0 Or Pinc.3 = 0 Or Pinc.4 = 0 Then Return
F = 4081 : Waitms 500
Return
حجم برنامه 7094 بایت شد ! ( 5 درصد مگا128 )
چهار تا آی سی رو می تونه تست کنه اونم با 5 درصد حافظه !
حالا اگه صدتا ای سی براش تعریف کنیم که حافظه کلا پر شده !
در ضمن این فقط تشخیص ای سی هستش و عکس هایی که قراره نشون بده مونده !!! ( حجم اونها که خیلی بیشتره )
اومدم یه خورده الگوریتم تست 4017 رو بهینه کردم و نتیجه این شد :
کد php:
$regfile = "m128def.dat" : $crystal = 8000000 : $baud = 1200
Print "WWW.IRANLED.COM"
Dim F As Word , F_old As Word , B As Byte , M As Word , N As Word
F_old = 1
'-------------------------------------------------------------------------------
Do
F_old = F : F = 0
Gosub Test_4001
Gosub Test_4011
Gosub Test_4017
Gosub Test_4081
If F <> F_old And F = 0 Then : Print "PLEASE INSERT IC"
Elseif F <> F_old And F <> 0 Then : Print F : Waitms 500
End If
Loop
'-------------------------------------------------------------------------------
Test_4001:
Ddra = 255 : Ddrc = 255 : Porta = 0 : Portc = 0 : Waitus 10
Ddra = &B01110011 : Ddrc = &B01100111 : waitus 10
Porta = &B00000000 : Portc = &B00000001 : waitus 10
If Pina.2 = 0 Or Pina.3 = 0 Or Pinc.3 = 0 Or Pinc.4 = 0 Then Return
Porta = &B00100001 : Portc = &B01000011 : waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00010010 : Portc = &B00100101 : waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00110011 : Portc = &B01100111 : waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
F = 4001
Return
'-------------------------------------------------------------------------------
Test_4011:
Ddra = 255 : Ddrc = 255 : Porta = 0 : Portc = 0 : waitus 10
Ddra = &B01110011 : Ddrc = &B01100111 : waitus 10
Porta = &B00000000 : Portc = &B00000001 : waitus 10
If Pina.2 = 0 Or Pina.3 = 0 Or Pinc.3 = 0 Or Pinc.4 = 0 Then Return
Porta = &B00100001 : Portc = &B01000011 : waitus 10
If Pina.2 = 0 Or Pina.3 = 0 Or Pinc.3 = 0 Or Pinc.4 = 0 Then Return
Porta = &B00010010 : Portc = &B00100101 : waitus 10
If Pina.2 = 0 Or Pina.3 = 0 Or Pinc.3 = 0 Or Pinc.4 = 0 Then Return
Porta = &B00110011 : Portc = &B01100111 : waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
F = 4011
Return
'-------------------------------------------------------------------------------
Test_4017:
Ddra = 255 : Ddrc = 255 : Porta = 0 : Portc = 0 : waitus 10
Ddra = &B10000000 : Ddrc = &B00000111 : waitus 10
Porta = &B00000000 : Portc = &B00000001 : Waitus 10
N = 1
For B = 0 To 9
M = 0
If Pina.2 = 1 Then Set M.0
If Pina.1 = 1 Then Set M.1
If Pina.3 = 1 Then Set M.2
If Pina.6 = 1 Then Set M.3
If Pinc.6 = 1 Then Set M.4
If Pina.0 = 1 Then Set M.5
If Pina.4 = 1 Then Set M.6
If Pina.5 = 1 Then Set M.7
If Pinc.7 = 1 Then Set M.8
If Pinc.5 = 1 Then Set M.9
If M <> N Then Return
If B < 5 And Pinc.4 = 0 then return
If B > 4 And Pinc.4 = 1 Then Return
N = N * 2
Porta = &B00000000 : Portc = &B00000001 : waitus 10
Porta = &B00000000 : Portc = &B00000101 : Waitus 10
Next
F = 4017
Return
'-------------------------------------------------------------------------------
Test_4081:
Ddra = 255 : Ddrc = 255 : Porta = 0 : Portc = 0 : waitus 10
Ddra = &B01110011 : Ddrc = &B01100111 : waitus 10
Porta = &B00000000 : Portc = &B00000001 : waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00100001 : Portc = &B01000011 : waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00010010 : Portc = &B00100101 : waitus 10
If Pina.2 = 1 Or Pina.3 = 1 Or Pinc.3 = 1 Or Pinc.4 = 1 Then Return
Porta = &B00110011 : Portc = &B01100111 : waitus 10
If Pina.2 = 0 Or Pina.3 = 0 Or Pinc.3 = 0 Or Pinc.4 = 0 Then Return
F = 4081
Return
حجم برنامه شد 3610 بایت که البته 2 درصد فضای کل اتمگا 128 هستش !!!
در کل بازم فکر می کنم حافظه کم بیاریم !! ( ال سی دی گرافیکی و نمایش عکس رو بذاریم کنار )
به این فکر کنم بخوایم 200 تا ای سی بهش معرفی کنیم ( مثلا 100 تا cmos و 100 تا ttl )
مخصوصا که بعضی آی سی ها روال سختی داره و تستش راحت نیست و حجم زیادی از برنامه رو میگره !!
مثل تست 4031
خیلی از ای سی های مثل 4046 رو هم فکر نمی کنم بتونیم تستش کنیم !!! ( شما vco رو چجوری تست می کنی )
بریم سراغ Atmega256 ????؟؟؟؟
کسی پیشنهادی ایده ای چیزی نداره !!