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.

74HC175, parallel to serial data conversion

Status
Not open for further replies.

eaplrdd

Newbie level 3
Newbie level 3
Joined
Mar 6, 2018
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
44
Hi dear friends,
Thanks for providing the opportunity to interact with you experts!
Here I want to perform parallel to serial data conversion. Therefore I am using 74HC165, 8-bit parallel-in/serial-out shift register.
I need C code to read & store the fault status into Variable( say unsigned char). I tried below C code but its not working.
Basically I have an 8 Window Annunciator product where I want to read the Eight different Fault status. These faults can be either Logic 0 or Logic 1. Now these Eight status shall be collected into a Variable(datatype: unsigned char, as value 0b00000000/ 0b11111111 is possible)
Hardware logic is illustrated as shown in fig(A):
D0 to D7 are eight fault status which can be either Logic 0 or Logic 1.
C Code to read & store the status is as follows:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
void CHK_FAULT_INPUT(void)
{
    unsigned char a=0, Val=0;
 
    PL_ENABLE   = 1;
    SERIAL_CLK  = 0;
    CHIP_ENABLE = 1;    
 
 
        PL_ENABLE   = 0;        // PL
        asm("nop");     
        asm("nop");
        CHIP_ENABLE = 0;        // CE
        asm("nop");     
        asm("nop");
        
        SERIAL_CLK  = 0;        // CP
        asm("nop");     
        asm("nop");
        SERIAL_CLK  = 1;
        asm("nop");     
        asm("nop");
                                // FAULT_PAT: Q7
 
        if((FAULT_PAT & 0b00000001) == 1) 
            FAULT_InP1 = 0b00000001;
 
        else FAULT_InP1 = 0b00000000;
        asm("nop"); 
 
        SERIAL_CLK  = 0;
        asm("nop");     
        asm("nop");
        SERIAL_CLK  = 1;
        asm("nop");     
        asm("nop");
 
        if((FAULT_PAT & 0b00000010) == 1) 
            FAULT_InP2 = 0b00000010;
 
        else FAULT_InP2 = 0b00000000;
        asm("nop"); 
 
        SERIAL_CLK  = 0;
        asm("nop");     
        asm("nop");
        SERIAL_CLK  = 1;
        asm("nop");     
        asm("nop");
 
        if((FAULT_PAT & 0b00000100) == 1) 
            FAULT_InP3 = 0b00000100;
 
        else FAULT_InP3 = 0b00000000;
        asm("nop"); 
 
        SERIAL_CLK  = 0;
        asm("nop");     
        asm("nop");
        SERIAL_CLK  = 1;
        asm("nop");     
        asm("nop");
 
        if((FAULT_PAT & 0b00001000) == 1) 
            FAULT_InP4 = 0b00001000;
 
        else FAULT_InP4 = 0b00000000;
        asm("nop"); 
 
        SERIAL_CLK  = 0;
        asm("nop");     
        asm("nop");
        SERIAL_CLK  = 1;
        asm("nop");     
        asm("nop");
 
        if((FAULT_PAT & 0b00010000) == 1) 
            FAULT_InP5 = 0b00010000;
 
        else FAULT_InP5 = 0b00000000;
        asm("nop"); 
 
        SERIAL_CLK  = 0;
        asm("nop");     
        asm("nop");
        SERIAL_CLK  = 1;
        asm("nop");     
        asm("nop");
 
        if((FAULT_PAT & 0b00100000) == 1) 
            FAULT_InP6 = 0b00100000;
 
        else FAULT_InP6 = 0b00000000;
        asm("nop"); 
 
        SERIAL_CLK  = 0;
        asm("nop");     
        asm("nop");
        SERIAL_CLK  = 1;
        asm("nop");     
        asm("nop");
 
        if((FAULT_PAT & 0b01000000) == 1) 
            FAULT_InP7 = 0b01000000;
 
        else FAULT_InP7 = 0b00000000;
        asm("nop"); 
 
        SERIAL_CLK  = 0;
        asm("nop");     
        asm("nop");
        SERIAL_CLK  = 1;
        asm("nop");     
        asm("nop");
        if((FAULT_PAT & 0b10000000) == 1) 
            FAULT_InP8 = 0b10000000;
 
        else FAULT_InP8 = 0b00000000;
        asm("nop"); 
 
        FAULT_InP = FAULT_InP1 + FAULT_InP2 + FAULT_InP3 + 
                                  FAULT_InP4 + FAULT_InP5 + FAULT_InP6 + 
                                  FAULT_InP7 + FAULT_InP8;
 
        SERIAL_CLK  = 0;
        CHIP_ENABLE = 1;
        PL_ENABLE   = 1;
}




So kindly suggest the correct C code to read & store the fault status into Variable.
Thanks!
Regards,
Santosh Bhat
Sr. Engg, Bangalore
 

Attachments

  • Forum Query.jpg
    Forum Query.jpg
    358.9 KB · Views: 135
Last edited by a moderator:

Just for clarification - are you referring to the 74HC175 as in the title or the 74HC165 as in the text?

Brian.
 

Hi,

aren´t 24,800 google results for "HC165 C code" enough?

there are a lot of discussion, code, circuits... what else do you need?

****
Your given circuit is useless, because it doesn´t show the microcontroller connections.
Your given code is not complete.
What does the simulation say? Do the waveforms meet the specifications of the datasheet?

Klaus
 

Yes sir, my apology!

Its 74HC165

Regards,
Santosh
 

I am using PIC16F1938 microcontroller in which PL, CE, CP & Q7 outputs of 74HC165 are given as I/P to microcontroller. So microcontroller Port pins are configured as INPUT and other functions of the port( ANSEL, O/P, LATCH etc. are disabled)
As I mentioned, I need to read 8 different Fault status and store it into any variable/register. So micocontroller i/p pin details were not shown.

I am trying my best to understand the 74HC165 logic and doing google search as well!
I am testing it with hardware, there is no compilation error as code is building! But when I am debugging it then the expected responses are not coming, as PL bit is abruptly becoming high etc.
 

Hi,

You need to read the HC165 datasheet.

PL, CE, CP & Q7 outputs of 74HC165
What datasheet do you refer to? Your pin naming is different to the TI datasheet.

You talk about 4 outputs, but a HC165 only has 2 outputs. --> read datasheet.

Microcontroller output --> HC165 input.
The microcontroller software needs to control / write the outputs to generate the signal for the HC165 inputs.
But this all has been discussed very often and very detailed.

All you need to know is given in the datasheet.
* generate the HC165 input signals
* and read in the HC165 output signals
Follow the waveform and the timing informations given in the datasheet.

Klaus
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top