Hello my friends
I am using PIC16F84 at 14.005 MHz with ceramic osilator. My problem
is with
HI7191 serial ADC...
Please help with the read & write rutines below...
Merhaba Ozgur Bey,
Nazik mektubunuz beni çok sevindirdi. Demekki Türkiyede de PIC
calisan
insanlar varmis.
Ben PIC16F84 kullanıyorum. HI7191 Harrisin seri ADC si kristalim
14.005 MHz.
3 bacakli seramik.
Ozgur Orman wrote:
> Selam
> Isterseniz yazisabiliriz,
turkce karakterlere dikkat.
> Kimimiz hala
pine kullaniyoruz.
>
Ozgur D. Orman
...
r2 equ
0x26 ;microwire
registers
r3 equ
0x27 ;
"
...
#define adcSCLK PORTB,6 ;; microwire
!!!
#define adcSDIO PORTB,5 ;; adc Serialdata
i/o
#define adcSDO PORTB,3 ;; adc Serialdata
out
#define adcCS PORTB,7 ;; adc
Chip Select
; ornegin 0xc6 hex sayisini ADC ye ADCYAZ rutini ile göndermek istiyorum.
; e.g.: If I want to send 0xc6 hex number from register r3 to HI7191
via ADCYAZ rutine, I write
movlw
0xc6
movwf
r3
call
ADCYAZ
...
main
movlw
0x22
movwf
r3
call
ADCYAZ
movlw
0x0a ;----------------------
movwf
dec_0
movf
dec_0,w
movwf
digit_0
call
print
movlw
.3
call
bekle
call
ADCOKU
movf
r3, W
movwf hbyte
movlw
0x0b ;----------------------
movwf
dec_0
movf
dec_0,w
movwf
digit_0
call
print
movlw
.3
call
bekle
call
ADCOKU
movf
r3, W
movwf lbyte
call
adc_hexyaz
movlw
.3
call
bekle
goto
main
...
;..........................
;adc HI7191 okuma dongusu, sonuc r3 yazmacinda------------------
;adc HI7191 read routine; result is in r3-------------------------
ADCOKU
;CLRWDT
;STOP interrupt
CLRF
F
BSF
adcSDO
BSF
adcSCLK
BCF
adcCS ;/CS L enable:
;start
movlw 0x0
MOVF
r3, F
movlw 0x8
MOVF
r2, F ;bit
counter for serial
;
LOOP2
;CALL
PULSE.........................................
bcf
adcSCLK
CALL
DELAY ;10 ms.
CALL
DELAY ;10 ms.----------------------------------
btfss adcSDIO
goto
sifirla
bsf
STATUS,C
goto
loo3
sifirla
bcf
STATUS,C
loo3
bsf
adcSCLK
CALL
DELAY ;10 ms.
CALL
DELAY ;10 ms.
MOVF
r3, W ;result
to Acc
RLF
W, W
MOVWF r3
;result to R3
decfsz r2, F
goto
LOOP2
BSF
adcSCLK
BSF
adcCS
;SETB
EA
return
;adc HI7191 yazma dongusu, gelen deger r3 yazmacinda------------------
;adc HI7191 read rutine, returned result is in r3 register
ADCYAZ
;CLRWDT
;STOP interrupt
CLRF F
BSF
adcSCLK
BCF
adcCS ;/CS L enable:
;start
movlw 0x0
MOVF
r2, F ;bit
counter for serial
LOOP2y
btfss r3,
r2 ;ilk once bit0
gonderilir...
goto
sifirlay ;first bit0 send...
bsf
adcSDIO
goto
loo3y
sifirlay
bcf
adcSDIO
loo3y
CALL
PULSE
incf
r2, F
if( r2< 8)
goto
LOOP2y
endif
BSF
adcSCLK
BSF
adcCS
return
PULSE
bcf
adcSCLK
CALL
DELAY ;10 ms.
CALL
DELAY ;10 ms.
bsf
adcSCLK
return
;DELAY, IS A APPROX. WAIT FOR 20.4mSECS, FOR A SYSTEM USING A 2
Mhz CRYSTAL
CLOCK.
DELAY
MOVLW .20
;20 milisaniye icin
MOVWF don
DLY1
CLRF
don1
DECFSZ don, F
GOTO
DLY2
RETLW 0
DLY2
DECFSZ don1, F
;INNER LOOP = 1.02 MSEC.
GOTO
DLY2
; /
GOTO
DLY1
return
delay_e movlw .10
movwf don
top nop
decfsz don,F
goto
top
return
bekle MOVWF don2
BEKLE2 MOVLW 0x50
MOVWF don1
BEKLE1 MOVLW 0xff
MOVWF don
WAIT DECFSZ don
GOTO
WAIT
DECFSZ don1
GOTO
BEKLE1
DECFSZ don2
GOTO
BEKLE2
RETURN
END
;but this program does not work.
;----------------------------------------EOM-----------------------------------