Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SPI interfacing problem need help

Status
Not open for further replies.

wrahulr88

Newbie level 1
Joined
Mar 10, 2008
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
hi all,
i tried o/p port expansion using shift register 74HC595.But the code when i simulate it ,is not working.Still i tried it after programing.But it doesnt make ny change.i will give u the code.Please help me.





;program to read port B and send it to the shift register via serial mode data transfer(SPI)
;using shift register 74HC595



#include<p16f877a.inc>

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & _LVP_OFF & _DEBUG_OFF & _CPD_OFF

org 0h
goto main


main
bsf STATUS,RP0
movlw b'11111111' ;portb input
movwf TRISB
clrf TRISC ;portc o/p
movlw b'01000000' ;putting CKE=1
movwf SSPSTAT
bcf STATUS,RP0 ;bank 0
clrf PORTC ;clearing PORTC
clrf PIR1 ;clear interrupt flag
movlw b'00100010'
movwf SSPCON ;enabling SSP
bsf PORTC,1 ;disabling o/p
goto program

program

movlw PORTB ;reading PORTB
movwf SSPBUF
btfss PIR1,SSPIF ;checkin whether SSPIF has been set
goto $-1 ;else go back to previous instruction
bsf PORTC,4 ;latching data out of shift register
nop
bcf PORTC,4
nop
bcf PORTC,1 ;o/p disable
nop
bcf PIR1,SSPIF ;clearing flag
goto program ;continue the process

END
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top