cancel
Showing results for 
Search instead for 
Did you mean: 

How to store or process 74HC165 bits through SPI

Duy Khang Banh
Associate II
Posted on December 25, 2017 at 14:08

The original post was too long to process during our migration. Please click on the attachment to read the original post.
2 REPLIES 2
Duy Khang Banh
Associate II
Posted on December 26, 2017 at 13:51

I use an STM32F103C8 development board and has onboard xtal, voltage regulator and works on a pc usb output voltage, I've managed to program the 74hc595 with this board. However, programming the counterpart parallel in, serial out (HC165) is quite hard for me. Could you or anyone tell me how I can read the bit from QH from the register?

I've tried another code from a chinese source:

//

--------------------------------------------------------------------------

//

æ�¥æº�:           

https://community.st.com/external-link.jspa?url=http%3A%2F%2Fhi.baidu.com%2Fmculove%2Fhome

//

程åº�å��称:        ç�?¨74HC165读8个按é�?®çŠ¶æ€�

//

晶振:            11.0592MHz;

//

MCUåž‹å�·:        STC89C52RC;

//

ç�?µè·¯æ�¿åž‹å�·:    EBV-MV(51实验æ�¿);

//

--------------------------------------------------------------------------   

//

--------------------------------------------------------------------------

//

硬件连接:

//

EBVn-[VCC]    ->    MVn-[--VCC--]

//

EBVn-[GND]    ->    MVn-[

//

GND

//

]

//

MVn-{EX3}-[Y0]    ->    MVn-{EX2}-[L1]

//

MVn-{EX3}-[Y1]    ->    MVn-{EX2}-[L2]

//

MVn-{EX3}-[Y2]    ->    MVn-{EX2}-[L3]

//

MVn-{EX3}-[Y3]    ->    MVn-{EX2}-[L4]

//

MVn-{EX3}-[Y4]    ->    MVn-{EX2}-[L5]

//

MVn-{EX3}-[Y5]    ->    MVn-{EX2}-[L6]

//

MVn-{EX3}-[Y6]    ->    MVn-{EX2}-[L7]

//

MVn-{EX3}-[Y7]    ->    MVn-{EX2}-[L8]

//

                     ->    MVn-{EX2}-(VCC)

//

                      ->    MVn-{EX3}-(VCC)

//

EBVn-[P10]        ->    MVn-{EX3}-[A]

//

EBVn-[P11]        ->    MVn-{EX3}-[B]

//

EBVn-[P12]        ->    MVn-{EX3}-[C]

//

EBVn-[P13]        ->    MVn-{EX3}-[G1]

//

--------------------------------------------------------------------------   

//

--------------------------------------------------------------------------

//

实验结果:

//

控制74HC138的[A,B,C,G1]端�,使[Y0,Y1..Y7]输出预期的值,LED实现了�水�显示

//

--------------------------------------------------------------------------  

//

------------------------------------------------------

//

头文件;

#include <AT89X52.H>

#define

HC165_nPL   P3_5

#define

HC165_CK    P3_6

#define

HC165_OUT    P3_7

//

------------------------------------------------------

void

delay(

void

) {     unsigned

char

i,j;    

for

(i =

250

;i >

0

;i--

)    

for

(j =

200

;j >

0

;j--

); }  unsigned

char

HC165(

void

) {     unsigned

char

i;     unsigned

char

Temp;     HC165_CK

=

1

;     HC165_nPL

=

0

;       

//

HC165读按é�?®

    HC165_nPL =

1

;       

//

æš‚å�œHC165读按é�?®

    Temp =

0

;    

if

(HC165_OUT ==

1

) Temp |=

0x01

;    

for

(i =

0

;i <

7

;i++

)     {             HC165_CK

=

0

;           HC165_CK

=

1

;           Temp

<<=

1

;        

if

(HC165_OUT ==

1

)          {             Temp

|=

0x01

;         }     }     HC165_CK

=

0

;    

return

(Temp); }   

//

------------------------------------------------------

//

程�入�;

void

main(

void

) {    

while

(

1

)     {       P1

=

HC165();       delay();     } }

However the while function 'P1 = HC165();' can't be accepted since I use GPIO with help of the STMCubeMX. Instead of that, I write ' HAL_GPIO_WritePin(GPIOB, HC165(), GPIO_PIN_SET);'. However, after uploading the program there is no output. I use GPIOB, GPIO_PIN_0 till GPIO_PIN_7. I have a HIGH signal at QA so shouldn't it be alteast 1 led turned on? 

Andrew Neil
Evangelist III
Posted on January 02, 2018 at 18:37

Duplicate:

https://community.st.com/0D50X00009XkWsVSAV