Showing posts with label Serial In Paralel Out. Show all posts
Showing posts with label Serial In Paralel Out. Show all posts

Wednesday, June 10, 2009

SERIAL IN PARALEL OUT 74HC595









IC 74HC595 is a serial in parallel out that similar with 74HC164. The output will change state as data shifted in. This integrated Circuit has four control line as follow :
a. Serial input
b. Latch - shift register contents to latches
c. Clock – shift data MS bit first
d. Clear – clears shift register
Data is shifted in most significant bit first.







;=======74HC595.ASM=================================4/25/97==
list p=16f84a
__config h'3ff1'
radix hex
;------------------------------------------------------------
; cpu equates (memory map)
porta equ 0x05
status equ 0x03
sendreg equ 0x0c
count equ 0x0d
trisa equ 0x85
;------------------------------------------------------------
; bit equates
rp0 equ 5
;------------------------------------------------------------
org 0x000
;
start bsf status,rp0 ;switch to bank 1
movlw b'00000000' ;outputs
movwf trisa
bcf status,rp0 ;switch back to bank 0
movlw 0x04 ;0000 0100
movwf porta ;control word
bcf porta,2 ;clear shift register
bsf porta,2
movlw 0x80 ;first number to be sent
call ser_out ;to serial out subroutine
movlw 0x0f ;second number to be sent
call ser_out ;to serial out subroutine
bsf porta,3 ;register contents to latches
bcf porta,3
circle goto circle ;done
;------------------------------------------------------------
ser_out movwf sendreg ;save copy of number
movlw 0x08 ;init 8 counter
movwf count
testbit bcf porta,0 ;default
btfsc sendreg,7 ;test number bit 7
bsf porta,0 ;bit is set
shift bsf porta,1 ;shift register
bcf porta,1
rotlft rlf sendreg,f ;shift number left
decfsz count,f ;decrement bit counter
goto testbit ;next bit
return ;done
;------------------------------------------------------------
end
;------------------------------------------------------------
;at device program time, select:
; code protection off
; watchdog timer disabled (default is enabled)
; standard crystal XT (using 4 MHz osc for test)
; power-up timer on
;============================================================

source : Pic’n up the pace

Download PDF