USART kesmesi

Başlatan ibarrada, 09 Aralık 2016, 21:05:42

ibarrada

Herkese merhabalar ben 18f4520 ile usart kesmesini kullanmak istiyorum. bu kesme nextion markalı dokunmatik bir panelden gelecektir. benim sıkıntım programda case döngüsü kullandığım zaman interrupt tuşa 30 yada 40 defa bastığımda devreye girmesi

Device= 18F4520
DEFINE RESET_ORG 0H
Include "modedefs.bas"   'Seri iletişim için gerekli
Declare Xtal=16   'Kristal hızı

Adin_Res 8 ' Set the resolution to 8
Adin_Tad FRC ' Choose the RC osc for ADC samples
Adin_Stime 100        ' Allow 100us for charge time


Hserial_Baud =9600
Hserial_RCSTA =%10010000
Hserial_TXSTA =%00100100
Hserial_Clear =On

ADCON1=%00001110  'ADC yapılandırması
'      76543210
TRISA=%00000001   'A0 analog giriş Diğerleri Digital
TRISB=%00000000   '
TRISD=%00000000
TRISC=%10000000   '
TRISE=%00000000   ' Çift yönlü Slave portta Read, Write porte.0,porte.1   yap


Symbol GIE  =INTCON.7   'genel interruptlar  aciyor
Symbol PEIE =INTCON.6   'Cevresel kesmeleri  aciyor
Symbol RCIE =PIE1.5     'USART kesmesini aciyor
Symbol RCIF =PIR1.5     'USART Receive interrupt flag bit
GIE=0     'Butun kesmeler devrede     
RCIE=1    'USART kesmesi devrede
PEIE=1    'Cevresel kesmeler devrede
GIE=1     'Butun kesmeler devrede


''''''''''''''''''''''''''''''''''''''''''' TANIMLAMALAR ''''''''''''''''''''''''''''''''''''''
Symbol Power=PORTC.0
Power=0
Symbol HATA=PORTC.4
HATA=0

Symbol Role1 = PORTA.1 ' ısıtma resistans
Symbol Role2 = PORTA.2 ' ısıtma pompa
Symbol Role3 = PORTA.3 ' fan
Symbol Role4 = PORTA.4 ' sulama pompa
Symbol Role5 = PORTA.5 ' boş
Symbol Role6 = PORTE.0 ' ışıklandırma   
Symbol Role7 = PORTE.1 ' yeşil çalışma ledi
Symbol Role8 = PORTE.2 ' kırmızı hata ledi
Dim Role9 As Byte

Symbol A=PORTD.2
Symbol B=PORTD.3
Symbol C=PORTD.1
Symbol D=PORTD.0

Dim Manuel As Byte


Dim X As Word
Dim Y As Word
Dim ZZ As Byte
Dim V As Byte
Dim T As Byte
Dim H As Byte
Dim PP As Byte
Dim SS As Byte
Dim CC As Byte
Y=0
X=0
V=0
T=0
H=0
PP=0
SS=0
CC=0

Dim Sayac1 As Word
Sayac1=0
       
Dim Secs As Byte
Dim Mins As Byte
Dim Hrs As Byte
Dim Day As Byte
Dim Date As Byte
Dim Month As Byte
Dim Year As Byte
Dim Week As Byte
     
Dim SANIYE As Byte
Dim DAKIKA As Byte
Dim SAAT As Byte   
Dim GUNADI As Byte 
Dim GUN As Byte     
Dim AY As Byte     
Dim YIL As Byte

Dim Man1 As Byte
Dim Man2 As Byte
Dim Man3 As Byte
Dim Man4 As Byte
Dim Man5 As Byte
Man1=0
Man2=0
Man3=0
Man4=0
Man5=0
Dim CatiKilit As Byte
CatiKilit=0

Dim FanKilit As Byte
FanKilit=0

Dim SaatKilit As Word
Dim SaatKiyas1 As Word
Dim SaatKiyas2 As Word
Dim SaatKiyas3 As Word


Dim Servo_Position As Word
Dim Servo_Position1 As Word
Dim Servo_Position2 As Word

Dim Sayac As Word
Dim Guncel As Word 'Parametre güncelllenme sayacı
Guncel=500

Servo_Position = 2800
Servo_Position1 = 2700
Servo_Position2 = 800 

Servo PORTC.3, Servo_Position1
Servo PORTC.5, Servo_Position2

Role1 = 0
Role2 = 0
Role3 = 0
Role4 = 0
Role5 = 0
Role6 = 0
Role7 = 0
Power = 0
Role8 = 0
Role9 = 0
Manuel = 0




''''''''''''''''''''''''''''''''''''''''''PROGRAM BAŞLANGICI'''''''''''''''''''''''''''''''''''


DelayMS 1000 '1sn gecikme
Power = 1
Role7 = 1
DelayMS 1000 '1sn gecikme
Power = 0
Role7 = 0
DelayMS 1000 '1sn gecikme
Power = 1
Role7 = 1


Symbol SDA_Pin =PORTB.3 'DS1307 SDA pin
Symbol SCL_Pin =PORTB.2 'DS1307 SCL pin


''' Cihaz ilk enerjilendiğinde DS1307 için başlama değerleri

I2COUT SDA_Pin, SCL_Pin, $D0 , $00 , [ 0 ]   ' Clock Halt (CH) Ataması (Saatin çalışması için gerekli)
DelayMS 100

I2COUT SDA_Pin, SCL_Pin, $D0 , $07 , [ $90 ] '' $07 ye 90H yazacaksın.SQW/OUT =1Hz'de çalışacaktır, şart değil
DelayMS 100

Secs = $0
Mins = $0
Hrs = $0
Day = $0
Week = $0
Month = $0
Year = $0

''''' Başlangıç değerleri
SANIYE = $45     ' sn 45 den başlayacak
DAKIKA = $59     ' dk 59
SAAT = $23       ' saat 23
GUNADI = $06     ' 6 = CUMA
GUN = $28        ' ayın kaçıncı günü 28
AY = $02         ' hangi ay şubat
YIL = $08        ' hangi yıl 2009



Dim S1 As Byte
Dim S2 As Byte
Dim D1 As Byte
Dim D2 As Byte 
Dim SA1 As Byte 
Dim SA2 As Byte
Dim G1 As Byte
Dim G2 As Byte 
Dim A1 As Byte
Dim A2 As Byte 
Dim Y1 As Byte
Dim Y2 As Byte


All_Digital = True

On_Interrupt GoTo Kes

GoTo Main

Disable
Kes:      'USART DONANIM SERI haberleşme interupt'ı(donanım kesmesi)  Nextion için
Context Save
HSerIn 100, CIK, [ZZ, V, T, H, PP, SS, CC]
If ZZ=101 And V=1 And T=3 And H=0 And PP=255 And SS=255 And CC=255 Then
Manuel=1  'manuel giriş butonu   manuel sayfasına giriyor ve case rutinini başlatıyor
EndIf


If ZZ=101 And V=3 And T=4 And H=1 And PP=255 And SS=255 And CC=255 Then
Man1=1'GoSub Maind1 'işiklandırma manuel butonu
EndIf

If ZZ=101 And V=3 And T=5 And H=1 And PP=255 And SS=255 And CC=255 Then
Man2=1'GoSub Maind2  'fan butonu
EndIf

If ZZ=101 And V=3 And T=6 And H=1 And PP=255 And SS=255 And CC=255 Then
Man3=1'GoSub Maind3  'çatı butonu
EndIf

If ZZ=101 And V=3 And T=7 And H=1 And PP=255 And SS=255 And CC=255 Then
Man4=1'GoSub Maind4  'sulama butonu
EndIf


If ZZ=101 And V=3 And T=8 And H=1 And PP=255 And SS=255 And CC=255 Then
Man5=1'GoSub Maind5  'ısıtma butonu
EndIf



CIK:
Context Restore
RCIF=0   ' USART Kesme bayragi sifirlandi (RCIF)
Enable
Resume


Main:

Sayac1=Sayac1 + 1

If Manuel=1 Then
Select Case Sayac1

Case  Guncel *2
If Man1=1 Then
GoSub Maind1
Man1=0
EndIf

Case  Guncel *4
If Man2=1 Then
GoSub Maind2
Man2=0
EndIf

Case  Guncel *6
If Man3=1 Then
GoSub Maind3
Man3=0
EndIf

Case  Guncel *8
If Man4=1 Then
GoSub Maind4
Man4=0
EndIf

Case  Guncel *10
If Man5=1 Then
GoSub Maind5
Man5=0
EndIf


Case Guncel *12
GoSub Saatbas


Sayac1=0
End Select

EndIf 'manuel seçimin endifi

GoTo Main

Saatbas:
'''' Değerleri okumak için de alttaki komut
ds1307_oku:
    I2Cin SDA_Pin, SCL_Pin, $D0 , $00, [ SANIYE, DAKIKA, SAAT, GUNADI, GUN, AY, YIL ]
   
'''' Okunan değerleri ekrana vermeden önce BCD dönüşümünü yap
hane_coz:
    S1 = SANIYE // 16   ' saniye/16 böl ve kalanı S1 e yerleştir.
    S2 = SANIYE - S1
    S2 = S2 // 15
    S2= (S2 * 10) + S1
   
    D1 = DAKIKA // 16
    D2 = DAKIKA - D1
    D2 = D2 // 15
   
    D2= (D2 * 10) + D1
   
    SA1 = SAAT // 16
    SA2 = SAAT - SA1
    SA2 = SA2 // 15
    SA2= (SA2 * 10) + SA1
   
    G1 = GUN // 16
    G2 = GUN - G1
    G2 = G2 // 15
    G2= (G2 * 10) + G1
   
    A1 = AY // 16
    A2 = AY - A1
    A2 = A2 // 15                                     
    A2= (A2 * 10) + A1
     
    Y1 = YIL // 16
    Y2 = YIL - Y1
    Y2 = Y2 // 15
    Y2= (Y2 * 10) + Y1


HSerOut  [0xff, 0xff, 0xff,"page0.n0.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page0.n1.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page0.n2.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page0.n3.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page0.n4.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page0.n5.val=",Dec Y2]

HSerOut  [0xff, 0xff, 0xff,"page1.n0.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page1.n1.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page1.n2.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page1.n3.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page1.n4.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page1.n5.val=",Dec Y2]

HSerOut  [0xff, 0xff, 0xff,"page2.n4.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page2.n5.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page2.n6.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page2.n7.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page2.n8.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page2.n9.val=",Dec Y2]

HSerOut  [0xff, 0xff, 0xff,"page3.n0.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page3.n1.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page3.n2.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page3.n3.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page3.n4.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page3.n5.val=",Dec Y2]

HSerOut  [0xff, 0xff, 0xff,"page4.n10.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page4.n11.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page4.n12.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page4.n13.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page4.n14.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page4.n15.val=",Dec Y2]

HSerOut  [0xff, 0xff, 0xff,"page5.n0.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page5.n1.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page5.n2.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page5.n3.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page5.n4.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page5.n5.val=",Dec Y2]
Return



'ışıklandırma

Maind1:
If Role6=1 Then
Role6=0
GoTo Atla20
EndIf

If Role6=0 Then
Role6=1
Atla20:
EndIf
Return

'fan         '(fan önündeki servoda devreye girmesi lazım)
Maind2:

If Role3=1 Then
Role3=0
'fan servolarını kapa
Repeat
Servo PORTC.1, Servo_Position
DelayMS 5
Inc Servo_Position
Until Servo_Position = 2800
FanKilit=0
GoTo Atla21
EndIf

If Role3=0 Then
Role3=1
'fan servolarını aç
Repeat
Servo PORTC.1, Servo_Position
DelayMS 5
Dec Servo_Position
Until Servo_Position = 1250
FanKilit=1
EndIf
Atla21:
Return

Maind3:
If Role9=0 Then
Role9=1
'çatı açma servosu
Repeat
Servo PORTC.3, Servo_Position1
Servo PORTC.5, Servo_Position2
DelayMS 12
Dec Servo_Position1
Inc Servo_Position2 
Until Servo_Position1 = 1770
' Until Servo_Position2 = 1500
CatiKilit=1
GoTo Atla22
EndIf

If Role9=1 Then
Role9=0
'çatı kapama servosu
Repeat
Servo PORTC.3, Servo_Position1
Servo PORTC.5, Servo_Position2
DelayMS 12
Inc Servo_Position1
Dec Servo_Position2
Until Servo_Position1 = 2700
'Until Servo_Position2 = 640
CatiKilit=0
EndIf
Atla22:
Return
'sulama       


Maind4:
If Role4=1 Then
Role4=0
GoTo Atla23
EndIf

If Role4=0 Then
Role4=1
EndIf
Atla23:
Return


'ısıtma       

Maind5:
If Role1=1 And Role2=1 Then
Role1=0
Role2=0
GoTo Atla24
EndIf

If Role1=0 And Role2=0 Then
Role1=1
Role2=1
EndIf
Atla24:
Return

burada manuel butonuna bastığım zaman interrupt bir seferde alıyor ve manuel sayfasına giriş yapmış oluyorum. interrupt aldığını case te bulunan saatbas tan anlıyorum ve ekrana tarih saat basmaya başlıyor. Ama manuel sayfasında röle ve benzeri şeyleri çektireceğim zaman 30 40 defa ard arda bastığım zaman ancak röle açılıyor case döngüsü ile bir çakışma olabilir mi?ben biraz case döngüsünden şüpheleniyorum. 4 mhz kristal kullanıyorum ve PLL ile 16 mhz yapıyorum. bu işi bir seferde yapabilirmiyim yada benim bilmediğim bir şeyimi atlıyorum bilemedim.

ete

USART kesme bayrağı olan RCIF biti direk ulaşılabilir bir bit değildir. Yani RCIF=0 diyerek sen bu biti sıfırlayamazsın.
Sıfırlamak için TEMP=RCREG diyerek Receiver registerinin içini başka bir değişkene vererek boşaltman gerekir. Bu işlem RCIF bitini arka planda otomatik sıfırlar.
Sen ise kesme kısmında direk RCIF=1 diyerek bayrağı sıfırlamaya çalışmışsın. Bu durumda bayrak sıfırlanmayacağı için sistem kesmeden kurtulamayacak demektir. Sorun bu olabilir. Burada TEMP yerine her hangi bir değişken adı da kullanabilirsin. Bir dene istersen.

Ete

ibarrada

ete hocam dediğinizi yaptım sıkıntı aynı şekilde devam ediyor
Device= 18F4520
DEFINE RESET_ORG 0H
Include "modedefs.bas"   'Seri iletişim için gerekli
Declare Xtal=16   'Kristal hızı

Adin_Res 8 ' Set the resolution to 8
Adin_Tad FRC ' Choose the RC osc for ADC samples
Adin_Stime 100        ' Allow 100us for charge time


Hserial_Baud =9600
Hserial_RCSTA =%10010000
Hserial_TXSTA =%00100100
Hserial_Clear =On

ADCON1=%00001110  'ADC yapılandırması
'      76543210
TRISA=%00000001   'A0 analog giriş Diğerleri Digital
TRISB=%00000000   '
TRISD=%00000000
TRISC=%10000000   '
TRISE=%00000000   ' Çift yönlü Slave portta Read, Write porte.0,porte.1   yap


Symbol GIE  =INTCON.7   'genel interruptlar  aciyor
Symbol PEIE =INTCON.6   'Cevresel kesmeleri  aciyor
Symbol RCIE =PIE1.5     'USART kesmesini aciyor
Symbol RCIF =PIR1.5     'USART Receive interrupt flag bit
GIE=0     'Butun kesmeler devrede     
RCIE=1    'USART kesmesi devrede
PEIE=1    'Cevresel kesmeler devrede
GIE=1     'Butun kesmeler devrede


''''''''''''''''''''''''''''''''''''''''''' TANIMLAMALAR ''''''''''''''''''''''''''''''''''''''
Symbol Power=PORTC.0
Power=0
Symbol HATA=PORTC.4
HATA=0

Symbol Role1 = PORTA.1 ' ısıtma resistans
Symbol Role2 = PORTA.2 ' ısıtma pompa
Symbol Role3 = PORTA.3 ' fan
Symbol Role4 = PORTA.4 ' sulama pompa
Symbol Role5 = PORTA.5 ' boş
Symbol Role6 = PORTE.0 ' ışıklandırma   
Symbol Role7 = PORTE.1 ' yeşil çalışma ledi
Symbol Role8 = PORTE.2 ' kırmızı hata ledi
Dim Role9 As Byte

Symbol A=PORTD.2
Symbol B=PORTD.3
Symbol C=PORTD.1
Symbol D=PORTD.0

Dim Manuel As Byte

Dim TEMP As Word
Dim X As Word
Dim Y As Word
Dim ZZ As Byte
Dim V As Byte
Dim T As Byte
Dim H As Byte
Dim PP As Byte
Dim SS As Byte
Dim CC As Byte
Y=0
X=0
V=0
T=0
H=0
PP=0
SS=0
CC=0

Dim Sayac1 As Word
Sayac1=0
       
Dim Secs As Byte
Dim Mins As Byte
Dim Hrs As Byte
Dim Day As Byte
Dim Date As Byte
Dim Month As Byte
Dim Year As Byte
Dim Week As Byte
     
Dim SANIYE As Byte
Dim DAKIKA As Byte
Dim SAAT As Byte   
Dim GUNADI As Byte 
Dim GUN As Byte     
Dim AY As Byte     
Dim YIL As Byte

Dim Man1 As Byte
Dim Man2 As Byte
Dim Man3 As Byte
Dim Man4 As Byte
Dim Man5 As Byte
Man1=0
Man2=0
Man3=0
Man4=0
Man5=0
Dim CatiKilit As Byte
CatiKilit=0

Dim FanKilit As Byte
FanKilit=0

Dim SaatKilit As Word
Dim SaatKiyas1 As Word
Dim SaatKiyas2 As Word
Dim SaatKiyas3 As Word


Dim Servo_Position As Word
Dim Servo_Position1 As Word
Dim Servo_Position2 As Word

Dim Sayac As Word
Dim Guncel As Word 'Parametre güncelllenme sayacı
Guncel=500

Servo_Position = 2800
Servo_Position1 = 2700
Servo_Position2 = 800 

Servo PORTC.3, Servo_Position1
Servo PORTC.5, Servo_Position2

Role1 = 0
Role2 = 0
Role3 = 0
Role4 = 0
Role5 = 0
Role6 = 0
Role7 = 0
Power = 0
Role8 = 0
Role9 = 0
Manuel = 0




''''''''''''''''''''''''''''''''''''''''''PROGRAM BAŞLANGICI'''''''''''''''''''''''''''''''''''


DelayMS 1000 '1sn gecikme
Power = 1
Role7 = 1
DelayMS 1000 '1sn gecikme
Power = 0
Role7 = 0
DelayMS 1000 '1sn gecikme
Power = 1
Role7 = 1


Symbol SDA_Pin =PORTB.3 'DS1307 SDA pin
Symbol SCL_Pin =PORTB.2 'DS1307 SCL pin


''' Cihaz ilk enerjilendiğinde DS1307 için başlama değerleri

I2COUT SDA_Pin, SCL_Pin, $D0 , $00 , [ 0 ]   ' Clock Halt (CH) Ataması (Saatin çalışması için gerekli)
DelayMS 100

I2COUT SDA_Pin, SCL_Pin, $D0 , $07 , [ $90 ] '' $07 ye 90H yazacaksın.SQW/OUT =1Hz'de çalışacaktır, şart değil
DelayMS 100

Secs = $0
Mins = $0
Hrs = $0
Day = $0
Week = $0
Month = $0
Year = $0

''''' Başlangıç değerleri
SANIYE = $45     ' sn 45 den başlayacak
DAKIKA = $59     ' dk 59
SAAT = $23       ' saat 23
GUNADI = $06     ' 6 = CUMA
GUN = $28        ' ayın kaçıncı günü 28
AY = $02         ' hangi ay şubat
YIL = $08        ' hangi yıl 2009



Dim S1 As Byte
Dim S2 As Byte
Dim D1 As Byte
Dim D2 As Byte 
Dim SA1 As Byte 
Dim SA2 As Byte
Dim G1 As Byte
Dim G2 As Byte 
Dim A1 As Byte
Dim A2 As Byte 
Dim Y1 As Byte
Dim Y2 As Byte


All_Digital = True

On_Interrupt GoTo Kes

GoTo Main

Disable
Kes:      'USART DONANIM SERI haberleşme interupt'ı(donanım kesmesi)  Nextion için
Context Save
HSerIn 100, CIK, [ZZ, V, T, H, PP, SS, CC]
If ZZ=101 And V=1 And T=3 And H=0 And PP=255 And SS=255 And CC=255 Then
Manuel=1  'manuel giriş butonu   manuel sayfasına giriyor ve case rutinini başlatıyor
EndIf


If ZZ=101 And V=3 And T=4 And H=1 And PP=255 And SS=255 And CC=255 Then
Man1=1'GoSub Maind1 'işiklandırma manuel butonu
EndIf

If ZZ=101 And V=3 And T=5 And H=1 And PP=255 And SS=255 And CC=255 Then
Man2=1'GoSub Maind2  'fan butonu
EndIf

If ZZ=101 And V=3 And T=6 And H=1 And PP=255 And SS=255 And CC=255 Then
Man3=1'GoSub Maind3  'çatı butonu
EndIf

If ZZ=101 And V=3 And T=7 And H=1 And PP=255 And SS=255 And CC=255 Then
Man4=1'GoSub Maind4  'sulama butonu
EndIf


If ZZ=101 And V=3 And T=8 And H=1 And PP=255 And SS=255 And CC=255 Then
Man5=1'GoSub Maind5  'ısıtma butonu
EndIf



CIK:
Context Restore
TEMP=RCREG
'RCIF=0   ' USART Kesme bayragi sifirlandi (RCIF)
Enable
Resume


Main:

Sayac1=Sayac1 + 1

If Manuel=1 Then
Select Case Sayac1

Case  Guncel *2
If Man1=1 Then
GoSub Maind1
Man1=0
EndIf

Case  Guncel *4
If Man2=1 Then
GoSub Maind2
Man2=0
EndIf

Case  Guncel *6
If Man3=1 Then
GoSub Maind3
Man3=0
EndIf

Case  Guncel *8
If Man4=1 Then
GoSub Maind4
Man4=0
EndIf

Case  Guncel *10
If Man5=1 Then
GoSub Maind5
Man5=0
EndIf


Case Guncel *12
GoSub Saatbas


Sayac1=0
End Select

EndIf 'manuel seçimin endifi

GoTo Main

Saatbas:
'''' Değerleri okumak için de alttaki komut
ds1307_oku:
    I2Cin SDA_Pin, SCL_Pin, $D0 , $00, [ SANIYE, DAKIKA, SAAT, GUNADI, GUN, AY, YIL ]
   
'''' Okunan değerleri ekrana vermeden önce BCD dönüşümünü yap
hane_coz:
    S1 = SANIYE // 16   ' saniye/16 böl ve kalanı S1 e yerleştir.
    S2 = SANIYE - S1
    S2 = S2 // 15
    S2= (S2 * 10) + S1
   
    D1 = DAKIKA // 16
    D2 = DAKIKA - D1
    D2 = D2 // 15
   
    D2= (D2 * 10) + D1
   
    SA1 = SAAT // 16
    SA2 = SAAT - SA1
    SA2 = SA2 // 15
    SA2= (SA2 * 10) + SA1
   
    G1 = GUN // 16
    G2 = GUN - G1
    G2 = G2 // 15
    G2= (G2 * 10) + G1
   
    A1 = AY // 16
    A2 = AY - A1
    A2 = A2 // 15                                     
    A2= (A2 * 10) + A1
     
    Y1 = YIL // 16
    Y2 = YIL - Y1
    Y2 = Y2 // 15
    Y2= (Y2 * 10) + Y1


HSerOut  [0xff, 0xff, 0xff,"page0.n0.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page0.n1.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page0.n2.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page0.n3.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page0.n4.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page0.n5.val=",Dec Y2]

HSerOut  [0xff, 0xff, 0xff,"page1.n0.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page1.n1.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page1.n2.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page1.n3.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page1.n4.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page1.n5.val=",Dec Y2]

HSerOut  [0xff, 0xff, 0xff,"page2.n4.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page2.n5.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page2.n6.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page2.n7.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page2.n8.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page2.n9.val=",Dec Y2]

HSerOut  [0xff, 0xff, 0xff,"page3.n0.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page3.n1.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page3.n2.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page3.n3.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page3.n4.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page3.n5.val=",Dec Y2]

HSerOut  [0xff, 0xff, 0xff,"page4.n10.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page4.n11.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page4.n12.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page4.n13.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page4.n14.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page4.n15.val=",Dec Y2]

HSerOut  [0xff, 0xff, 0xff,"page5.n0.val=",Dec SA2]
HSerOut  [0xff, 0xff, 0xff,"page5.n1.val=",Dec D2]
HSerOut  [0xff, 0xff, 0xff,"page5.n2.val=",Dec S2]
HSerOut  [0xff, 0xff, 0xff,"page5.n3.val=",Dec G2]
HSerOut  [0xff, 0xff, 0xff,"page5.n4.val=",Dec A2]
HSerOut  [0xff, 0xff, 0xff,"page5.n5.val=",Dec Y2]
Return



'ışıklandırma

Maind1:
If Role6=1 Then
Role6=0
GoTo Atla20
EndIf

If Role6=0 Then
Role6=1
Atla20:
EndIf
Return

'fan         '(fan önündeki servoda devreye girmesi lazım)
Maind2:

If Role3=1 Then
Role3=0
'fan servolarını kapa
Repeat
Servo PORTC.1, Servo_Position
DelayMS 5
Inc Servo_Position
Until Servo_Position = 2800
FanKilit=0
GoTo Atla21
EndIf

If Role3=0 Then
Role3=1
'fan servolarını aç
Repeat
Servo PORTC.1, Servo_Position
DelayMS 5
Dec Servo_Position
Until Servo_Position = 1250
FanKilit=1
EndIf
Atla21:
Return

Maind3:
If Role9=0 Then
Role9=1
'çatı açma servosu
Repeat
Servo PORTC.3, Servo_Position1
Servo PORTC.5, Servo_Position2
DelayMS 12
Dec Servo_Position1
Inc Servo_Position2 
Until Servo_Position1 = 1770
' Until Servo_Position2 = 1500
CatiKilit=1
GoTo Atla22
EndIf

If Role9=1 Then
Role9=0
'çatı kapama servosu
Repeat
Servo PORTC.3, Servo_Position1
Servo PORTC.5, Servo_Position2
DelayMS 12
Inc Servo_Position1
Dec Servo_Position2
Until Servo_Position1 = 2700
'Until Servo_Position2 = 640
CatiKilit=0
EndIf
Atla22:
Return
'sulama       


Maind4:
If Role4=1 Then
Role4=0
GoTo Atla23
EndIf

If Role4=0 Then
Role4=1
EndIf
Atla23:
Return


'ısıtma       

Maind5:
If Role1=1 And Role2=1 Then
Role1=0
Role2=0
GoTo Atla24
EndIf

If Role1=0 And Role2=0 Then
Role1=1
Role2=1
EndIf
Atla24:
Return

ibarrada

Röleleri direk interrupt içinden aç kapa yaparsam sistem sorunsuz çalışıyor ama bu case ile örnekteki gibi kullanırsam case döngüsü sistemin kesmesini engelliyor

ibarrada

interrupt algılamama sebebi ekrana bastığım saat olduğu ortaya çıktı hserout miktarı biraz fazla ve kesme olayını domine etmiş durumda döngüde saatbas olayını inaktif edince problem düzeldi. ama ekrana saaat basmak ve bu olayların kesmeyi bu kadar etkileyeceğini aklımdan geçmezdi

ete

#5
Etkilemesi normal çünki orada çok fazla hserout komutu var. Üstelik her birinin başına preambıl olduğunu düşündüğüm bilgi yerleştirmişsin ki buda yanlış. Gerçi 3 adet $FF bilgisi Uyandırma olmaktan çok uzak. Ne amaçla onları oraya yerleştirdin bilemiyorum ama bana lüzumsuz gibi geliyorlar. Acaba seri LCD mi kullanıyorsunda bu dataları yolluyorsun ve onunda belirli bir formatımı var?
Cevap evet ise yinede gönderi adedini teke düşürmeni öneririm. Gerek yok okadar fazla adette yollamaya.

Cevap hayır ise en baştan 3 byyte $00, 3 byte $AA, 3byte $FF yolla ardından ana bilgileri sırası ile yolla olsun bitsin.

Ete


ibarrada

#6
Cevabım evet bir seferde sistem algılıyor. Piyasada bulunan nextion marka dokunmatik ekran kullanıyorum. Bu ekranda 4 çıkış var +5V TX RX ve GND bu ekranla haberleşmek için herşeyi denedim pic tx ve rx bacağıyla bağladığımda direkt olarak bu şekilde iletişim kurabildim $FF olarak 3 adet göndermezsem sistem yine algılamadı tuş basımında interruptta olan şekilde 7 adet veriyi bir seferde okuyarak sağlıyorum. Ekran formatını bu şekilde çözdüm. Saat te ekrana hserout olayını baya abartığımı farkkettim.

Powered by EzPortal