x_Stickler_x
Joined: 27 Mar 2008 Posts: 3
|
Having a problem with PIC18F4520 7-segment display |
Posted: Tue Sep 09, 2008 4:02 pm |
|
|
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;
}
} |
|
|