'Merhaba arkadaşlar. Bugün araştırıp sonuca ulaştığım mcp41010 entegresi ile 16f877a proton kodları ve isis şemasını sunmak 'istiyorum.. 'Umarım işinize yarar ..
'****************************************************************
'* Name : mcp41010.BAS *
'* Author : [ergunbt] *
'* Notice : Copyright (c) 2015 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 22.08.2015 *
'* Version : 1.0 *
'* Notes : mcp41010 dijital pot uygalaması *
'* : *
'****************************************************************
Device=16F877A
XTAL = 4
TRISA=%111111
ALL_DIGITAL = True
Symbol YUKARI= PORTA.0
Symbol ASAGI= PORTA.1
Symbol MODE= PORTA.2
Symbol CS10 = PORTB.3 ' CHIP SEÇ her entegrenin cs pinlerini bağla
Symbol CS20 = PORTB.4 ' CHIP SEÇ
Symbol CS30 = PORTB.5 ' CHIP SEÇ
Symbol CS40 = PORTB.6 ' CHIP SEÇ
Output CS10 ' CS10 ÇIKISINI AYARLA
Output CS20 ' CS20 ÇIKISINI AYARLA
Output CS30 ' CS30 ÇIKISINI AYARLA
Output CS40 ' CS40 ÇIKISINI AYARLA
Symbol SCK = PORTC.3 ' CLOCK PINI 41010 entegrelerine paralel
Symbol SI = PORTC.4 ' DATA IN PINI 41010 entegrelerine paralel
Symbol SO = PORTC.5 ' DATA OUT PINI
Dim VAR1 As Byte
Dim VAR2 As Byte
Dim VAR3 As Byte
Dim VAR4 As Byte
Dim MOD As Byte
MOD=0
LOOP:
If MODE=0 Then
While MODE=0 :Wend
MOD=MOD+1
If MOD=4 Then MOD=0
EndIf
If MOD=0 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
VAR1=VAR1+10
If VAR1>255 Then VAR1=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
VAR1=VAR1-10
If VAR1<5 Then VAR1=0
EndIf
EndIf
If MOD=1 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
VAR2=VAR2+10
If VAR2>255 Then VAR2=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
VAR2=VAR2-10
If VAR2<5 Then VAR2=0
EndIf
EndIf
If MOD=2 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
VAR3=VAR3+10
If VAR3>255 Then VAR3=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
VAR3=VAR3-10
If VAR3<5 Then VAR3=0
EndIf
EndIf
If MOD=3 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
VAR4=VAR4+10
If VAR4>255 Then VAR4=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
VAR4=VAR4-10
If VAR4<5 Then VAR4=0
EndIf
EndIf
GoSub POT_YAZ ' DİJİTAL PORTA YAZ
GoTo LOOP
'================================================= ========
POT_YAZ:
CS10=0 ' AKTIF
CS20=0 ' AKTIF
CS30=0 ' AKTIF
CS40=0 ' AKTIF
SHOut SI, SCK, msbfirst, [$11,VAR1]
CS10=1
CS10=0
CS10=1
SHOut SI, SCK, msbfirst, [$11,VAR2]
CS20=1
CS20=0
CS20=1
SHOut SI, SCK, msbfirst, [$11,VAR3]
CS30=1
CS30=0
CS30=1
SHOut SI, SCK, msbfirst, [$11,VAR4]
CS40=1
CS40=0
CS40=1
Return
End
'****************************************************************
'* Name : mcp41010.BAS *
'* Author : [ergunbt] *
'* Notice : Copyright (c) 2015 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 22.08.2015 *
'* Version : 1.0 *
'* Notes : mcp41010 dijital pot uygalaması *
'* : *
'****************************************************************
Device=16F877A
XTAL = 4
TRISA=%111111
ALL_DIGITAL = True
Symbol YUKARI= PORTA.0
Symbol ASAGI= PORTA.1
Symbol MODE= PORTA.2
Symbol CS10 = PORTB.3 ' CHIP SEÇ her entegrenin cs pinlerini bağla
Symbol CS20 = PORTB.4 ' CHIP SEÇ
Symbol CS30 = PORTB.5 ' CHIP SEÇ
Symbol CS40 = PORTB.6 ' CHIP SEÇ
Output CS10 ' CS10 ÇIKISINI AYARLA
Output CS20 ' CS20 ÇIKISINI AYARLA
Output CS30 ' CS30 ÇIKISINI AYARLA
Output CS40 ' CS40 ÇIKISINI AYARLA
Symbol SCK = PORTC.3 ' CLOCK PINI 41010 entegrelerine paralel
Symbol SI = PORTC.4 ' DATA IN PINI 41010 entegrelerine paralel
Symbol SO = PORTC.5 ' DATA OUT PINI
Dim VAR1 As Byte
Dim VAR2 As Byte
Dim VAR3 As Byte
Dim VAR4 As Byte
Dim MOD As Byte
MOD=0
LOOP:
If MODE=0 Then
While MODE=0 :Wend
MOD=MOD+1
If MOD=4 Then MOD=0
EndIf
If MOD=0 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
VAR1=VAR1+10
If VAR1>255 Then VAR1=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
VAR1=VAR1-10
If VAR1<5 Then VAR1=0
EndIf
EndIf
If MOD=1 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
VAR2=VAR2+10
If VAR2>255 Then VAR2=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
VAR2=VAR2-10
If VAR2<5 Then VAR2=0
EndIf
EndIf
If MOD=2 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
VAR3=VAR3+10
If VAR3>255 Then VAR3=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
VAR3=VAR3-10
If VAR3<5 Then VAR3=0
EndIf
EndIf
If MOD=3 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
VAR4=VAR4+10
If VAR4>255 Then VAR4=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
VAR4=VAR4-10
If VAR4<5 Then VAR4=0
EndIf
EndIf
GoSub POT_YAZ ' DİJİTAL PORTA YAZ
GoTo LOOP
'================================================= ========
POT_YAZ:
CS10=0 ' AKTIF
CS20=0 ' AKTIF
CS30=0 ' AKTIF
CS40=0 ' AKTIF
SHOut SI, SCK, msbfirst, [$11,VAR1]
CS10=1
CS10=0
CS10=1
SHOut SI, SCK, msbfirst, [$11,VAR2]
CS20=1
CS20=0
CS20=1
SHOut SI, SCK, msbfirst, [$11,VAR3]
CS30=1
CS30=0
CS30=1
SHOut SI, SCK, msbfirst, [$11,VAR4]
CS40=1
CS40=0
CS40=1
Return
End