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

Having a problem with PIC18F4520 7-segment display

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



Joined: 27 Mar 2008
Posts: 3

View user's profile Send private message

Having a problem with PIC18F4520 7-segment display
PostPosted: Tue Sep 09, 2008 4:02 pm     Reply with quote

Hello people of ccs forum,
I am new to the discussions and would like a problem solved if possible.
I am doing example 18 (ch. 18) of the PIC18F4520 exercise booklet and the middle LED of the 2 digits (g1,g2) is not lighting.
When I do a voltage check on g1 and g2 while the program is running I get a constant 5V.
When I placed a LED in g1,g2 in place of the 7-segment display it does not light either.
The wiring is correct, I have done it and re-done it at least 5 times and I get the same outcome.
I am wondering if the code is wrong in the "byte CONST LED_MAP" or if the hardware is malfunctioning.
If there is anything I am leaving out please reply with what else you would like to know.

Please help for I cannot continue until I solve this problem,
Thanx to all at CCS

-Jeremy

The code is as follows:
(refer to chapter 18 example of the PIC18F4520 exercise booklet)
Code:
#include <18f4520.h>        //first 9 lines are <protoalone.h>
#fuses HS,NOLVP,NOWDT
#use delay (clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#define GREEN_LED PIN_A5
#define YELLOW_LED PIN_B4
#define RED_LED PIN_B5
#define PUSH_BUTTON PIN_A4

#include <protoalone.h>    //Code starts here

byte CONST LED_MAP[10] =
{0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67};

void display_number(int n)
{
   output_b(LED_MAP[n/10]);
   output_low(PIN_C0);
   delay_ms(2);
   output_high(PIN_C0);
   output_b(LED_MAP[n%10]);
   output_low(PIN_C1);
   delay_ms(2);
   output_high(PIN_C1);
}

void main()
{
   int count=1,i;
   
   while(TRUE)
   {
      for(i=0;i<=200;i++)
         display_number(count);
      count = (count==99) ? 1 : count+1;
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 09, 2008 4:10 pm     Reply with quote

Just a comment:

Keep in mind that CCS tech support doesn't normally post in this forum.
They post here maybe once a month. The people on this forum are
CCS compiler users.

Also, probably 99% of us don't have the "exercise book" that you're
talking about.
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