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 CCS Technical Support

Example: EX_EXPIO.c

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



Joined: 24 Apr 2014
Posts: 141

View user's profile Send private message

Example: EX_EXPIO.c
PostPosted: Thu Nov 06, 2025 2:50 pm     Reply with quote

Hi All,

I’m looking at example program ‘EX_EXPIO.c’ as the basis for a project. I need to read the data from up to 48 serially connected 74LS165 devices. The example program is clear to me for reading only one ‘165, but for multiple devices, it’s not so clear. Is the best way to change ‘NUMBER_OF_74165’ in 74165.c to 48? If so, in ‘EX_EXPIO.c’, how are the individual bytes referenced?

Jack
PrinceNai



Joined: 31 Oct 2016
Posts: 555
Location: Montenegro

View user's profile Send private message

PostPosted: Fri Nov 07, 2025 1:10 am     Reply with quote

For my way of thinking the easiest way would be to declare an 8bit buffer NUMBER_OF_DEVICES big. Each byte of that buffer exactly represents one of the 74165's. Then I'd clock in 8 bits to same variable and move it to the buffer. Increment buffer position. Repeat NUMBER_OF_DEVICES times. That way accessing values later gets simpler. But of course it depends on what you are actually reading. Maybe bit 125 makes more sense to you than Buffer[15] bit 3.
Ttelmah



Joined: 11 Mar 2010
Posts: 19970

View user's profile Send private message

PostPosted: Fri Nov 07, 2025 8:27 am     Reply with quote

No, you would change the number to 6. Each chip gives 8 pins. That is why
it is set to '1' for the 8 pin example.
The variable ei, passed to the read_expanded_inputs function will have to
become an array of 6 bytes, instead of a single integer. so instead of:
Code:

   BYTE data;
   while (TRUE) {
      read_expanded_inputs (&data);

//You will want:
   BYTE data[6];
   while (TRUE) {
      read_expanded_inputs (data); //since the name of an array is it's address


The array then contains all 48 bits in the 6 bytes.
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