??? 12/28/09 07:40 Modified: 12/28/09 09:57 Read: times |
#171965 - 74HC165 |
Dear friends,
I checked all subjects about 74HC165 but couldn't find a solution to my problem. Could you please tell me what's wrong with this code to read (2x74HC165) parallel inputs serially. Thanks. cseg AT 0000H jmp codstr . . . cseg AT 0050H codstr: ;(program code starts here) . . . setb QH ;(set Port as input) setb CLKINH ;(prevent clock signal's rising edges accidently) . . . mov WAITWF,#32 ;(enough to meet all propagation time) . . . prgstr: ;(main program loop starts here) . . . clr SHLD ;(reset SH/LD input of 74HC165 to get parallel inputs to register) call WFW ;(wait for a while for progopation time) setb SHLD ;(set SH/LD input of 74HC165 to read parallel inputs. this freezes the register) call WFW ; clr CLKINH ;(reset Clock Inhibit input of 74HC165 to enable clock input of 74HC165) call WFW ; mov PLSCNT,#8 ;(rise clock for 8 times) pr1: setb CLK ;(set Clock input of 74HC165, rising edge of clock..) call WFW ; mov C,QH ;(..then read the serial output) rlc A ; clr CLK ; call WFW ; djnz PLSCNT,pr1 ;(8-bit completed?) mov FRST8,A ;(get first 8-bit) mov PLSCNT,#8 ;(same as the first part) pr2: setb CLK ; call WFW ; mov C,QH ; rlc A ; clr CLK ; call WFW ; djnz PLSCNT,pr2 ; mov SCND8,A ;(get second 8-bit) setb CLKINH ;(disable clock input of 74HC165) call WFW ; . . . jmp prgstr ;(end of main loop) . . . WFW: djnz WAITFW,$ ;(simple code to wait for a while) mov WAITWF,#32 ret . . . DSEG AT 30H FRST8: DS 1 SCND8: DS 1 WAITFW: DS 1 PLSCNT: DS 1 . . . QH EQU P3.5 SHLD EQU P3.4 CLK EQU P3.3 CLKINH EQU P1.2 . . . end |