mcp3202 spi haberleşme sorunu

Başlatan bener, 02 Mart 2025, 16:13:40

bener

merhaba arkadaşlar spi haberleşme daha önce hiç yapmadım. uğraştım, forumuda araştırdım ama bir türlü başaramadım. hiç bir bilgi alamadım nerede hata yapıyorum yardımcı olabilirmisiniz şimdiden teşekkür ederim


Device = 18F4520
Xtal 4
Config_Start
  OSC = rc    ;External RC oscillator, CLKO function on RA6
  FCMEN = OFF    ;Fail-Safe Clock Monitor disabled
  IESO = OFF    ;Oscillator Switchover mode disabled
  PWRT = OFF    ;PWRT disabled
  BOREN = SBORDIS    ;Brown-out Reset enabled in hardware only (SBOREN is disabled)
'  BORV = 3    ;Minimum setting
  WDT = On    ;WDT enabled
'  WDTPS = 32768    ;1:32768
'  CCP2MX = PORTC    ;CCP2 input/output is multiplexed with RC1
'  PBADEN = ON    ;PORTB<4:0> pins are configured as analog input channels on Reset
  LPT1OSC = OFF    ;Timer1 configured for higher power operation
  MCLRE = On    ;MCLR pin enabled; RE3 input pin disabled
  STVREN = On    ;Stack full/underflow will cause Reset
  LVP = On    ;Single-Supply ICSP enabled
  XINST = OFF    ;Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
  Debug = OFF    ;Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
  Cp0 = OFF    ;Block 0 (000800-001FFFh) not code-protected
  CP1 = OFF    ;Block 1 (002000-003FFFh) not code-protected
  CP2 = OFF    ;Block 2 (004000-005FFFh) not code-protected
  CP3 = OFF    ;Block 3 (006000-007FFFh) not code-protected
  CPB = OFF    ;Boot block (000000-0007FFh) not code-protected
  CPD = OFF    ;Data EEPROM not code-protected
  WRT0 = OFF    ;Block 0 (000800-001FFFh) not write-protected
  WRT1 = OFF    ;Block 1 (002000-003FFFh) not write-protected
  WRT2 = OFF    ;Block 2 (004000-005FFFh) not write-protected
  WRT3 = OFF    ;Block 3 (006000-007FFFh) not write-protected
  WRTC = OFF    ;Configuration registers (300000-3000FFh) not write-protected
  WRTB = OFF    ;Boot block (000000-0007FFh) not write-protected
  WRTD = OFF    ;Data EEPROM not write-protected
  EBTR0 = OFF    ;Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
  EBTR1 = OFF    ;Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
  EBTR2 = OFF    ;Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
  EBTR3 = OFF    ;Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
  EBTRB = OFF    ;Boot block (000000-0007FFh) not protected from table reads executed in other blocks
Config_End
;-------------------------------------------------------------------------------
        ;----lcd tanımlama-----
Declare LCD_DTPin PORTD.0
Declare LCD_ENPin PORTD.5
Declare LCD_RSPin PORTD.4
Declare LCD_Interface 4
Declare LCD_Lines 4
Declare All_Digital=true
       
  SSPSTAT = %10111111      ; transition idle->active
  SSPCON1 =%00100000      ;  Idle low, SPI Master, clk = Fosc/4
       
        ;------giriş çıkış ayarları------
TRISA =0
TRISB=0
TRISC=%00010000
TRISD=0
;------- değişken atamaları-----
Dim adc As Word
Cls
  Symbol CLK = PORTC.3
Symbol DTA = PORTC.4
       
    BASLA:
  PORTB.0=0
    adc = SHIn DTA, CLK, MsbPre, 10
  PORTB.0=1
    Print At 1,1,"adc:" ,Dec adc
   
      DelayMS 100
  GoTo BASLA
 



 


bener

günaydın arkadaşlar  mcp3202 hangi kanalı okuyacağımı belirtmediğim için bilgi alamadığımı tespit ettim



BASLA:
  PORTB.0=0


SHout  DTA, CLK,0, %1111 veya %1011,4  ;yapmamız gerekli
adc = SHIn DTA, CLK, MsbPre, 10
  PORTB.0=1

parametre

Alıntı yapılan: bener - 04 Mart 2025, 08:53:08günaydın arkadaşlar  mcp3202 hangi kanalı okuyacağımı belirtmediğim için bilgi alamadığımı tespit ettim



BASLA:
  PORTB.0=0


SHout  DTA, CLK,0, %1111 veya %1011,4  ;yapmamız gerekli
adc = SHIn DTA, CLK, MsbPre, 10
  PORTB.0=1


Cozumu arkadaslarınızla paylaşarak bilmeyen arkadaslarınıza ışık oldugunuz için onlar adına tesekkur ederım