View previous topic :: View next topic |
Author |
Message |
deltatech
Joined: 22 Apr 2006 Posts: 87
|
Problem with 74595 Code |
Posted: Sat May 20, 2006 3:51 pm |
|
|
Hi I am trying to run EX_EXPIO.C on a CCS Software Board .
I have 2 Questions In the intro of the example it says "when button 1 is pushed, LED 1 will toggle green. Button 2 will toggle LED 2. "
But In the code of 74595 These butons are not defined or mapped to any ports or am I Missing some thing here ? .
The Other is when I run this exapmple with ICD-U40 I get an error mesage "Could not run Programme The TByteStack was empty "
can any one tell me what i am doing wrong
Any Help will be appriciated.
Thanks in advance
EX_EXPIO.C
Code: |
/////////////////////////////////////////////////////////////////////////
//// 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 Button 1 ////
//// 12 Button 2 ////
//// 13 gnd ////
//// 14 gnd ////
//// 15 gnd ////
//// 3 gnd ////
//// 4 gnd ////
//// 5 gnd ////
//// 6 gnd ////
//// 8 gnd ////
//// 16 +5V ////
//// 9 pin B5 ////
//// 1 pin B3 ////
//// 2 pin B4 ////
//// ////
//// 74595 pin Protoboard ////
//// 15 LED 1 ////
//// 1 LED 2 ////
//// 2 LED 3 ////
//// 3 gnd ////
//// 4 gnd ////
//// 5 gnd ////
//// 6 gnd ////
//// 7 gnd ////
//// 8 gnd ////
//// 13 gnd ////
//// 16 +5V ////
//// 10 +5V ////
//// 14 pin B2 ////
//// 11 pin B1 ////
//// 12 pin B0 ////
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#include <74595.c>
#include <74165.c>
[b]void main() {
BYTE data;
do {
read_expanded_inputs (&data);
data |= 0xF8; //Force the unused input bits on
data -= (!(data&0x01)&!(data&0x02))<<2; //Turn on bit 2 it both inputs are
//toggled
write_expanded_outputs (&data);
} while (TRUE);
}[/b]
74595.C
///////////////////////////////////////////////////////////////////////////
//// 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 ////
[b]#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);
}[/b]
|
|
|
![](templates/subSilver/images/spacer.gif) |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sat May 20, 2006 9:14 pm |
|
|
Quote: |
But In the code of 74595 These butons are not defined or mapped to any ports or am I Missing some thing here ? .
|
The buttons and Leds are not defined nor mapped because they are not connected to any pin of the PIC.
The buttons are connected to the inputs A (pin 11) and B (pin 12) of the 74165.
The Leds are connected to the outputs 0 ( pin 15), 1 (pin 1), 2 (pin 2) of the 74595.
PD: It is not allowed to post CCS code without its explicit consent.
Humberto |
|
![](templates/subSilver/images/spacer.gif) |
deltatech
Joined: 22 Apr 2006 Posts: 87
|
|
Posted: Sun May 21, 2006 7:50 am |
|
|
Thanks Humberto I am sorry i didnt know You couldnt Post CCS Code OOPs ![Surprised](images/smiles/icon_surprised.gif) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun May 21, 2006 8:33 am |
|
|
Actually though, worth pointing out that this particular example, is one of the few that _doesn't_ say this.
Most have a very careful copywrite message to this effect.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Sun May 21, 2006 8:41 am |
|
|
Mine all have the copyright notice so maybe it was edited out before posting? |
|
![](templates/subSilver/images/spacer.gif) |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sun May 21, 2006 8:52 am |
|
|
Ttelmah wrote:
Quote: |
Actually though, worth pointing out that this particular example, is one of the few that _doesn't_ say this.
|
Not exactly. All this drivers in all the different versions that I have, keep the CCS copyright warning.
Humberto |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun May 21, 2006 9:59 am |
|
|
The funny thing is that I have a version for this one that doesn't. I looked, just 'out of interest', and unlike the rest of the CCS files, this one lacked their normal header. That was why I commented.
It was one they sent seperately, rather than the normal included versions.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|