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.

[SOLVED] Questions bout shiftregisters (74HC575, 74HC597)

Status
Not open for further replies.
Re: Questions About some shiftregisters

actually what I said above about using i>0 is wrong, you can use i>=1

Code:
For loop
-------------------------------------------------------------
Is used to execute a statement or statement block a specified number of times.
	for (expr1; expt2; expr3) { statement1; statement2; ... }
	for (expr1; expt2; expr3)  statement;
expr1 will be executed only one time at the entry of the for loop (assignment statement).
expr2 is a conditional control statement used to determine when to stay in the for loop.
expr3 is executed at the bottom of the statement and then expr2 is evaluated.


---------- Post added at 18:14 ---------- Previous post was at 18:01 ----------

this is embarrassing :oops: , i>=1 is not correct too.. it will never execute the loop with 0
you can use i !=255

Code C - [expand]
1
2
char i;
for(i=7; i !=255; i--)



or you can make i a signed variable and use i>=0

Code C - [expand]
1
2
signed char i
for(i=7; i>=0; i--)

 
Last edited:
Re: Questions About some shiftregisters

this is embarrassing , i>=1 is not correct too.. it will never execute the loop with 0
you can use i !=255
char i;
for(i=7; i !=255; i--)

or you can make i a signed variable and use i>=0
signed char i
for(i=7; i>=0; i--)


hehe :)

anyways I learn a log today from you

1. the debugging tool
2. char i;
for(i=7; i !=255; i--)

and

signed char i
for(i=7; i>=0; i--)

3. I learned how to debug my code :)

back to topic.. it's getting late here. tomorrow I will try daisy chain method.
 

Re: Questions About some shiftregisters

Hi

I connected two output shiftregister(the same chip last night)
firs chip serial out is connected to 2nd chip serial in

and I clock out the data 16 times but when I latch after the 16th the data will only appear in the 2nd chip..


im doing like this except the capacitor..
**broken link removed**

---------- Post added at 12:59 ---------- Previous post was at 12:56 ----------

when i send 16bits data

send_data(0x3333);

the ouput 0x33 will only appear in the 2nd CHIP and not the 1st chip.
 

Re: Questions About some shiftregisters

it works fine for me when i test it in proteus using the LOGICSTATE

Snap1.gif


Alex
 

Re: Questions About some shiftregisters

ok will try again manually ..

---------- Post added at 13:18 ---------- Previous post was at 13:09 ----------

what I've done is while DS =1 in the first chip I clock out 16 times and toogle the latch pin but it does not transfer to 2nd chip..

---------- Post added at 13:21 ---------- Previous post was at 13:18 ----------

okay it's now working..

---------- Post added at 13:23 ---------- Previous post was at 13:21 ----------

the MR and The OE in my circuit is not hardwired but I give them constant 1 and 0.. why it does not work when I dont hardwire it? basically it's the same
 

Re: Questions About some shiftregisters

the MR and The OE in my circuit is not hardwired but I give them constant 1 and 0.. why it does not work when I dont hardwire it? basically it's the same

are you sure that the output is correct (to MR and OE) and not changing at any point, use the digital graph and check
 
Re: Questions About some shiftregisters

the MR and The OE in my circuit is not hardwired but I give them constant 1 and 0.. why it does not work when I dont hardwire it? basically it's the same

yes.. im sure..it is the same code I use yesterday .. by the way it is now working I dont know what happen maybe it's protues glitch.. hehe

let me ask something because I think I dont understand how this two chips work.. maybe Im expecting something.



with the setup based on the schematic posted above and assume the code is working

if I send send_data(0x3333); a 16 bits data so I would apear in the output of the first chip as 0x33 and the second chip as 0x33?

or it will appear first in the first chip as 0x33 and then next to the 2nd chip as 0x33?

does the value 0x33 does not stay in the both chip?
 

Re: Questions About some shiftregisters

the value 0x33 will appear to both chips when you toggle STCP.
While you are shifting bits nothing is shown in the outputs except from Q7' which then transfers the data to the serial input of the second chip.
so after you send the ninth bit in the input of the first chip the Q7' will output the first bit that was entered so it will insert that to the second chip input, Q7' works all the time it just has the input value of 9 clocks ago it is not like Q0-Q7 that need the STCP to show the output.
 
Re: Questions About some shiftregisters

okay thanks so much I got it working.. the instruction given to me is wrong.. :)

I figured it out. the clock pin is also use in the input shift registers that is causing trouble....

---------- Post added at 14:01 ---------- Previous post was at 13:46 ----------




i tried this input send_data(0x8833); but only the 0x33 displayed in both chip..
 

Re: Questions About some shiftregisters

there is either something wrong in your circuit or your code, can you attach your code and schematic
 
Re: Questions About some shiftregisters

now it's okay it's all about the for loop again.. :)

i change again the loop like yesterday but this time it is declared as signed char .. :)



void send_data(unsigned int data)
{
signed char i;

for(i=15; i>=0; i--)
{

if(((data >> i) & 0x01) == 0)
SPI_SO = 0;
else
SPI_SO = 1;
clock_data();

}
latch_output(); //release to parallel output pins
}
 

Re: Questions About some shiftregisters

you mean the 1 and the 0x01? yes it's the same.. I changed it now..

by the way what is the difference if we say 0x01 and 1? aside from being decimal and hex type....
is it less memory consumption if we say 0x01?..
 

Re: Questions About some shiftregisters

there is no difference , you can also say 0b00000001

I didn't mean to change the 0x01 with 1 , I meant to replace

Code:
if(((data >> i) & 0x01) == 0)
  SPI_SO = 0;
else
  SPI_SO = 1;
clock_data();

with
Code:
SPI_SO = ((data >> i) & 0x01)

the second part is ANDed with 1 so it can either give 0 or 1 and you can assign it directly to the output
 
Re: Questions About some shiftregisters

not working to me

SPI_SO = ((data >> i) & 0x01) == 0;
clock_data();


the output is not correct if I do like that and remove the if else
 

Re: Questions About some shiftregisters

your code SPI_SO = ((data >> i) & 0x01) == 0;
is not what I have suggested SPI_SO = ((data >> i) & 0x01);
 
Re: Questions About some shiftregisters

your code SPI_SO = ((data >> i) & 0x01) == 0;
is not what I have suggested SPI_SO = ((data >> i) & 0x01);

sorry it's now working.. my mistake... hehe

I like very much your suggestions..... I learned again today..
 

Re: Questions About some shiftregisters

sir tired with this great tutorials but not working
my code is follows
#include <REGX51.H>
unsigned char gk,gireesh = 0xAA;
unsigned int i;


void main()
{

P0 = 0x00;
P2 = 0x00;


while(1)
{
P0_0 = 0;
P0_1 = 0;

for(i=0; i<8; i++)
{

if(((gireesh << i) & 0x80) == 0)
P0_2 = 0;
else
P0_2 = 1;

P0_0 =1;
P0_0 =0;

}
P0_1 = 1;
P0_1 = 0;


for(i=0; i<9; i++)
{ P0_1 = 0;
P2 = (1<<i);



} } }
 

Re: Questions About some shiftregisters

Hi alexan

I want to point out one thing that first of all it is char and not unsigned char so it must read the negative value as it is defined as :

char i;

and not unsigned char i;


and also one thing I want to know is that suppose for a second that it is not going to be negative number and yes you are right that after decreasing the value below 0 the value becomes 255 in case of unsigned char but as rosel has initialized the variable i in the for loop to 7 so it must be something like this right:


after 0 it becomes 255 on further decreament and than again 7 as it is initialized to 7 and than 6,5,4.........0 and than again 255,7....


like this am I right
 

You are referring to this

Code:
unsigned char i;
for(i=7; i>=0; i--)

The initialization is only going to be executed once when you enter the for loop so the values will be 7,6,5,4,3,2,1,0,255,254,253...


Code C - [expand]
1
2
3
4
5
6
for (expr1; expt2; expr3) { statement1; statement2; ... }
for (expr1; expt2; expr3)  statement;
 
//expr1 will be executed only one time at the entry of the for loop (assignment statement).
//expr2 is a conditional control statement used to determine when to stay in the for loop.
//expr3 is executed at the bottom of the statement and then expr2 is evaluated.



Alex
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top