CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Would like help understanding 74595 library

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Nora



Joined: 23 Mar 2008
Posts: 50

View user's profile Send private message

Would like help understanding 74595 library
PostPosted: Sat Mar 26, 2011 3:42 pm     Reply with quote

Hello-
I am using the 74595.c library (successfully with one 74595 module).
I am unclear to how it actually works and was hoping someone here could explain it to me.
Especially this line
Code:
 if((*(eo+(NUMBER_OF_74595-1))&0x80)==0)

I've commented the lines with what I think is happening.
Thanks in advance!
N_N
Code:

void write_expanded_outputs(BYTE* eo) { /*SETS EO TO BE A POINTER TO OBJECTS OF TYPE BYTE*/
  BYTE i;                                                 //int8

  output_low(EXP_OUT_CLOCK);
  output_low(EXP_OUT_ENABLE);

  for(i=1;i<=NUMBER_OF_74595*8;++i) {  // Clock out bits from the eo array
    if((*(eo+(NUMBER_OF_74595-1))&0x80)==0)

/* (*(eo+(NUMBER_OF_74595-1)) IS THE VALUE OF EO + NUM OF 74595-1
IF THE ABOVE IS ANDED WITH 1000 0000 AND IS EQUAL TO 0 (MORE THAN 8 74595), THEN OUTPUT LOW ON THE DATA LINE*/

      output_low(EXP_OUT_DO);
    else
      output_high(EXP_OUT_DO);
   shift_left(eo,NUMBER_OF_74595,0); //ADDRESS, BYTES, VALUE
   output_high(EXP_OUT_CLOCK);
   output_low(EXP_OUT_CLOCK);
  }
  output_high(EXP_OUT_ENABLE);
  output_low(EXP_OUT_ENABLE);

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 26, 2011 5:05 pm     Reply with quote

The code is testing the top bit (bit 7) of the last byte in the array, to see if
the bit is 1 or 0. The top bit of the last byte is the MSB of the whole array.
Bit 0 of the first byte is the LSB of the whole array.

The code tests the MSB, then sets the "DO" pin to be the same value.
Then it shifts the whole array over by 1 bit position. It shifts the array
in the direction of the MSB.
Nora



Joined: 23 Mar 2008
Posts: 50

View user's profile Send private message

PostPosted: Sun Mar 27, 2011 5:02 am     Reply with quote

Thanks PCM!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group