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

Problem with 74595 Code

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



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

Problem with 74595 Code
PostPosted: Sat May 20, 2006 3:51 pm     Reply with quote

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]

Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat May 20, 2006 9:14 pm     Reply with quote

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
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Sun May 21, 2006 7:50 am     Reply with quote

Thanks Humberto I am sorry i didnt know You couldnt Post CCS Code OOPs Surprised
Ttelmah
Guest







PostPosted: Sun May 21, 2006 8:33 am     Reply with quote

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
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun May 21, 2006 8:41 am     Reply with quote

Mine all have the copyright notice so maybe it was edited out before posting?
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sun May 21, 2006 8:52 am     Reply with quote

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
Ttelmah
Guest







PostPosted: Sun May 21, 2006 9:59 am     Reply with quote

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
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