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

about 74LS165 CONNECTION QUESTION.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
whung.john
Guest







about 74LS165 CONNECTION QUESTION.
PostPosted: Wed Jan 03, 2007 12:10 pm     Reply with quote

HI!
have body can solve my question! and teach me .
Today,I want to pratice a ccs program include demo progra.
The program is about 75LS165 protice.
but i had readed .but i dont ready understand describe contents.
the program have describe fllows as;

THE DESCRIBE 1 -->> EXP_IN_ENABLE PIN_B3
THE DESCRIBE 2 -->> EXP_IN_CLOCK PIN_B4
THE DESCRIBE 3 -->> EXP_IN_DI PIN_B5
but i dont understand to connection pin address.
should it connected to my chip(pin16c877 & 74ls165)
I find the 74ls165 datasheets.the datasheets have report pin address.
but i dont understand (shift/load pin) address must connected to where ,how can i learn to connected pic16f877 pin address . is demo program pin_b3 or pinB4 or pin_b5?
the same question .chip 74ls165 (clock)pin address is pin_b3 or pinB4 or pin_b5?
next question. chip 74ls165 (output)pin address is pin_b3 or pinB4 or pin_b5?

i protrice demo program follow as :
*************************************************************
///////////////////////////////////////////////////////////////////////////
//// Library for a 74165 Expanded Input Chip ////
//// ////
//// Any number of these chips may be connected in series to get ////
//// 8 additional inputs per chip. The cost is 3 I/O pins for ////
//// any number of chips. ////
//// ////
//// read_expanded_inputs(ei); Reads the array ei from the chips ////
//// ////
///////////////////////////////////////////////////////////////////////////
//// (C) Copyright 1996,2003 Custom Computer Services ////
//// This source code may only be used by licensed users of the CCS C ////
//// compiler. This source code may only be distributed to other ////
//// licensed users of the CCS C compiler. No other use, reproduction ////
//// or distribution is permitted without written permission. ////
//// Derivative programs created using this software in object code ////
//// form are not restricted in any way. ////
///////////////////////////////////////////////////////////////////////////

#IFNDEF EXP_IN_ENABLE

#define EXP_IN_ENABLE PIN_B3
#define EXP_IN_CLOCK PIN_B4
#define EXP_IN_DI PIN_B5
#define NUMBER_OF_74165 1

#ENDIF


void read_expanded_inputs(BYTE *ei) {
BYTE i;

output_high(EXP_IN_CLOCK);
output_low(EXP_IN_ENABLE); // Latch all inputs
output_high(EXP_IN_ENABLE);

for(i=1;i<=NUMBER_OF_74165*8;++i) { // Clock in bits to the ei structure
shift_left(ei,NUMBER_OF_74165,input(EXP_IN_DI));
output_low(EXP_IN_CLOCK);
output_high(EXP_IN_CLOCK);
}
output_low(EXP_IN_ENABLE);
}

*********************************************************
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 03, 2007 2:25 pm     Reply with quote

I have added an explanation of the connections between the PIC pins
and the 74165 pins in the comments below:
Code:

#define EXP_IN_ENABLE   PIN_B3   // Connect to SH/LD pin
#define EXP_IN_CLOCK    PIN_B4   // Connect to CLK pin
#define EXP_IN_DI       PIN_B5   // Connect to SER pin


The CLKINH pin should be connected to ground. This will enable
the clock on the 74165.
whung.john
Guest







still had question
PostPosted: Fri Jan 05, 2007 1:02 pm     Reply with quote

pcm programmer:
i readed u added an explanation .but i try finish still have question .
please see my edit my test program.because i find .lcd panel
still display inbox=72,and count value is right.
i read u explanation.and connected .
#define EXP_IN_ENABLE PIN_B3 // Connect to SH/LD pin
#define EXP_IN_CLOCK PIN_B4 // Connect to CLK pin
#define EXP_IN_DI PIN_B5 // Connect to SER pin

my program dont doing right,and get a button pull information.
still display display inbox=72,and count value is right.
so,i find ccs demo program
i find different with u explanation. can u tell me who is right?
follow as:
////////////////////////////////////////////////////////////////////////
//// EX_EXPIO.C ////
//// ////
//// This program shows how to use the 74165.C and 74595.C ////
//// libraries for extended input and output. ////
//// ////
//// When button 1 is pushed, LED 1 will toggle green. Button ////
//// 2 will toggle LED 2. However, when both buttons are pushed, ////
//// LED 3 will toggle green. ////
//// ////
//// Configure the CCS prototype card as follows: ////
//// 74165 pin Protoboard ////
//// 11 40 Button 1 ////
//// 12 41 Button 2 ////
//// 13 27 gnd ////
//// 14 27 gnd ////
//// 15 27 gnd ////
//// 3 27 gnd ////
//// 4 27 gnd ////
//// 5 27 gnd ////
//// 6 27 gnd ////
//// 8 27 gnd ////
//// 16 28 +5V ////
//// 9 52 B5 ////
//// 1 50 B3 ////
//// 2 51 B4 ////



send my program.
follow as
#include <16F877.h>
#use delay(clock=10000000)
#fuses NOWDT,HS
#include <LCD>
#include <74165.c>
void main()
{
int i;
BYTE da;
lcd_init();
while(1)
{
for (i=1;i<100;i++)
{
lcd_gotoxy(1,1);printf(lcd_putc,"inbox=%4u",read_expanded_inputs(da));
lcd_gotoxy(1,2);printf(lcd_putc,"count=%d",i);
delay_ms(100);
}
i=0;
}

}



can u help me again?please thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 05, 2007 1:26 pm     Reply with quote

Add the fuse settings shown below in bold:
Quote:
#include <16F877.h>
#use delay(clock=10000000)
#fuses NOWDT, HS, NOLVP, BROWNOUT, PUT



Also, I noticed that you have changed the EX_EXPIO.C program.
The program you posted is not the same as the CCS code.

The CCS program looks like this:
Code:
void main()
{
 BYTE data;
   do {
       read_expanded_inputs (&data);

Notice that they pass the address of the 'data' variable
by putting a '&' symbol in front of it.

Here is your code:
Code:
lcd_gotoxy(1,1);printf(lcd_putc,"inbox=%4u",read_expanded_inputs(da));

You have left off the '&' symbol in front of the 'da' variable.

Also, you are using the read_expanded_inputs() function as if it
returns a value. But it doesn't return anything. The return value
is declared as 'void' in the function definition in 74165.c, as follows:
Code:
void read_expanded_inputs(BYTE *ei)

The only way the function can pass a value back is by putting it in
the 'da' variable. (Shown as 'ei' in the declaration shown above).
So you need to call the function and then display the contents of
the 'da' variable. Example:
Code:

lcd_gotoxy(1,1);
read_expanded_inputs(&da);
printf(lcd_putc,"inbox=%4u", da);
whung.john
Guest







have fun get right value
PostPosted: Sat Jan 06, 2007 10:51 am     Reply with quote

hi PCM programmer:
i readed u suggest contents.
in my target lcd panel ,ready touch button 1~8.i can
get right .display value 254,253,251......
but i still have a idea. if my thinks use spi function,
how can i connected to 74165 chip pin address.
can u teach me pin address.and how connected to pic16f877.
thanks u .


PCM programmer wrote:
Add the fuse settings shown below in bold:
Quote:
#include <16F877.h>
#use delay(clock=10000000)
#fuses NOWDT, HS, NOLVP, BROWNOUT, PUT



Also, I noticed that you have changed the EX_EXPIO.C program.
The program you posted is not the same as the CCS code.

The CCS program looks like this:
Code:
void main()
{
 BYTE data;
   do {
       read_expanded_inputs (&data);

Notice that they pass the address of the 'data' variable
by putting a '&' symbol in front of it.

Here is your code:
Code:
lcd_gotoxy(1,1);printf(lcd_putc,"inbox=%4u",read_expanded_inputs(da));

You have left off the '&' symbol in front of the 'da' variable.

Also, you are using the read_expanded_inputs() function as if it
returns a value. But it doesn't return anything. The return value
is declared as 'void' in the function definition in 74165.c, as follows:
Code:
void read_expanded_inputs(BYTE *ei)

The only way the function can pass a value back is by putting it in
the 'da' variable. (Shown as 'ei' in the declaration shown above).
So you need to call the function and then display the contents of
the 'da' variable. Example:
Code:

lcd_gotoxy(1,1);
read_expanded_inputs(&da);
printf(lcd_putc,"inbox=%4u", da);
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jan 06, 2007 1:39 pm     Reply with quote

The CCS driver is now working for you.

But you want me to write you a new version of the driver,
that uses hardware SPI instead of "bit banging".

I think you should write the new driver.

Read the articles in the forum on how to write an SPI driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=28767
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