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

7-segment using PIC

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







7-segment using PIC
PostPosted: Fri Apr 11, 2008 11:11 am     Reply with quote

hi...
I have to run a 7-segment 2 digit output ( 40, 50 and 80) using a pic. I'm using 16f877a with CCS as a compiler. The problem is, when I constructing a circuit using a programmed build, there is no output at all at the display. can anyone here help me to review and correct my work? I'm really appreciate your helps...here is my coding and i am sorry because it quite long due to my limited knowledge with source code.
Code:

#include <16F84A.h>
#fuses HS, NOWDT,NOPROTECT,NOLVP,NODEBUG,NOPUT,NOBROWNOUT
#use delay(clock=4000000)
#use fast_io(A)
#use fast_io(B)
#use fast_io(D)

//set i/o pins
#define MY_TRISA (0x07)
#define MY_TRISB (0x00)
#define MY_TRISD (0x00)

//set input pin

#define FOURTY_DEGREE PIN_A0 //in
#define FIFTY_DEGREE  PIN_A1 // in
#define EIGHTY_DEGREE PIN_A2 //in

// set output pin

#define TEMP_DEGREE_OUT1 PIN_B7 //out
#define TEMP_DEGREE_OUT2 PIN_B6 //out
#define TEMP_DEGREE_OUT3 PIN_B5 //out
#define TEMP_DEGREE_OUT4 PIN_B4 //out
#define TEMP_DEGREE_OUT5 PIN_B3 //out
#define TEMP_DEGREE_OUT6 PIN_B2 //out
#define TEMP_DEGREE_OUT7 PIN_B1 //out

#define ZERO_NUMBER_OUT1 PIN_B0 //out
#define ZERO_NUMBER_OUT2 PIN_D7 //out
#define ZERO_NUMBER_OUT3 PIN_D6 //out
#define ZERO_NUMBER_OUT4 PIN_D5 //out
#define ZERO_NUMBER_OUT5 PIN_D4 //out
#define ZERO_NUMBER_OUT6 PIN_D3 //out
#define ZERO_NUMBER_OUT7 PIN_D2 //out

void main()
{

while(1)

{

set_tris_a(MY_TRISA);
set_tris_b(MY_TRISB);
set_tris_d(MY_TRISD);



// initially no LEDs should be on

output_low (TEMP_DEGREE_OUT1);
output_low (TEMP_DEGREE_OUT2);
output_low (TEMP_DEGREE_OUT3);
output_low (TEMP_DEGREE_OUT4);
output_low (TEMP_DEGREE_OUT5);
output_low (TEMP_DEGREE_OUT6);
output_low (TEMP_DEGREE_OUT7);
output_low (ZERO_NUMBER_OUT1);
output_low (ZERO_NUMBER_OUT2);
output_low (ZERO_NUMBER_OUT3);
output_low (ZERO_NUMBER_OUT4);
output_low (ZERO_NUMBER_OUT5);
output_low (ZERO_NUMBER_OUT6);
output_low (ZERO_NUMBER_OUT7);

// Read data from switch
while (1)
{

if  (FOURTY_DEGREE==1)
{
output_low  (TEMP_DEGREE_OUT1);
output_high (TEMP_DEGREE_OUT2);
output_high (TEMP_DEGREE_OUT3);
output_low  (TEMP_DEGREE_OUT4);
output_low  (TEMP_DEGREE_OUT5);
output_high (TEMP_DEGREE_OUT6);
output_high (TEMP_DEGREE_OUT7);
output_high (ZERO_NUMBER_OUT1);
output_high (ZERO_NUMBER_OUT2);
output_high (ZERO_NUMBER_OUT3);
output_high (ZERO_NUMBER_OUT4);
output_high (ZERO_NUMBER_OUT5);
output_high (ZERO_NUMBER_OUT6);
output_low  (ZERO_NUMBER_OUT7);
}
else if (FIFTY_DEGREE==1)
{
output_high (TEMP_DEGREE_OUT1);
output_low  (TEMP_DEGREE_OUT2);
output_high (TEMP_DEGREE_OUT3);
output_high (TEMP_DEGREE_OUT4);
output_low  (TEMP_DEGREE_OUT5);
output_high (TEMP_DEGREE_OUT6);
output_high (TEMP_DEGREE_OUT7);
output_high (ZERO_NUMBER_OUT2);
output_high (ZERO_NUMBER_OUT3);
output_high (ZERO_NUMBER_OUT4);
output_high (ZERO_NUMBER_OUT5);
output_high (ZERO_NUMBER_OUT6);
output_low  (ZERO_NUMBER_OUT7);
}
else if (EIGHTY_DEGREE==1)
{
output_high (TEMP_DEGREE_OUT1);
output_high (TEMP_DEGREE_OUT2);
output_high (TEMP_DEGREE_OUT3);
output_high (TEMP_DEGREE_OUT4);
output_high (TEMP_DEGREE_OUT5);
output_high (TEMP_DEGREE_OUT6);
output_high (TEMP_DEGREE_OUT7);
output_high (ZERO_NUMBER_OUT2);
output_high (ZERO_NUMBER_OUT3);
output_high (ZERO_NUMBER_OUT4);
output_high (ZERO_NUMBER_OUT5);
output_high (ZERO_NUMBER_OUT6);
output_low (ZERO_NUMBER_OUT7);
}
}
}
}
princesshoney156
Guest







correction in a source code
PostPosted: Fri Apr 11, 2008 11:16 am     Reply with quote

from the previous codes, there is a correction for initialzing a pic. Actually it is #include <16f877A> and not #include <16f84A>..but it is not a problem for my 7-segment as i programmed it using 16f877a.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 11, 2008 11:19 am     Reply with quote

Your post appears to be a clone of this post here:
http://www.ccsinfo.com/forum/viewtopic.php?t=34324

Your post:
Quote:

i am sorry because it quite long due to my limited knowledge with source code.

His post:
Quote:

i'm am a new user for the microcontroller and have a very basic knowledge on a souce code.


Please go read that topic, and you will probably be able to
make your code work.
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