View previous topic :: View next topic |
Author |
Message |
kizuc
Joined: 25 Aug 2009 Posts: 6
|
Need 7-segment display CCS driver for 18f4550 |
Posted: Wed Nov 25, 2009 7:44 pm |
|
|
Good day,
I am working on a project with PIC18F4550 using 7 segment for my display. I need a CCS driver for this 7 segment display, to include in my code.
I am planning to use either 2 digits or 4 digits display.
Please can anyone help me out?
Thanks |
|
|
mskala
Joined: 06 Mar 2007 Posts: 100 Location: Massachusetts, USA
|
|
Posted: Thu Nov 26, 2009 11:26 pm |
|
|
I have this code for 2-digit which works great and only needs 1 resistor.
See the top comments for exact parts used.
Code: |
/* ========================================================================== */
/* Mark A. Skala */
/* Dual 7-segment driver stuff. */
/* Uses Lumex LDD-E302NI part (Digikey 67-1410-ND) with */
/* TI 8-chan driver TLC5916IPWR (Digikey 296-22711-1-ND) and */
/* Dual P-mosfet Fairchild FDW2508PB (Digikey FDW2508PBCT-ND */
/* All 3.3V logic */
/* ========================================================================== */
#define LED_TABLE_LENGTH 20
#define LED_L 16
#define LED_T 17
#define LED_DASH 18
#define LED_BLANK 19
#define PIN_LED_LEFT_EN PIN_C2 // go to dual fet
#define PIN_LED_RIGHT_EN PIN_C1 // go to dual fet
#define PIN_LED_LE PIN_B3 // go to TI driver
#define PIN_LED_CLK PIN_B5 // go to TI driver
#define PIN_LED_SDI PIN_B4 // go to TI driver
static int8 const led_table[LED_TABLE_LENGTH] =
// ---- seg A
// | | seg F seg B
// | |
// ---- seg G
// | | seg E seg C
// | |
// ---- seg D
//
// bit7 .. bit0 ==>> seg None,G,A,F,D,E,C,B
// TI Driver connections:
// OUT0 -> None
// OUT1 -> Seg G
// OUT2 -> Seg A
// OUT3 -> Seg F
// OUT4 -> Seg D
// OUT5 -> Seg E
// OUT6 -> Seg C
// OUT7 -> Seg B
{
0x3f, // 0
0x03, // 1
0x6d, // 2
0x6b, // 3
0x53, // 4
0x7a, // 5
0x7e, // 6
0x23, // 7
0x7f, // 8
0x7b, // 9
0x77, // A
0x5e, // b
0x3c, // C
0x4f, // d
0x7c, // E
0x74, // F
0x1c, // L
0x5c, // t
0x40, // -
0x00 // blank
};
// globals holding displayed value and ram copy of table (for speed reasons)
int8 left_led_val;
int8 right_led_val;
int8 ram_led_table[LED_TABLE_LENGTH];
#INT_RTCC
void clock_isr() { // the RTCC (timer0) overflows (255->0).
rtcc_toggle=1-rtcc_toggle; // For this program this is apx 8.2ms @ prescale 128
if (rtcc_toggle) {
LED_serial(ram_led_table[left_led_val]);
output_high(PIN_LED_RIGHT_EN);
output_low(PIN_LED_LEFT_EN);
} else {
LED_serial(ram_led_table[right_led_val]);
output_high(PIN_LED_LEFT_EN);
output_low(PIN_LED_RIGHT_EN);
}
}
void main() {
int8 a;
for (a=0;a<LED_TABLE_LENGTH;a++) { // copy led table to RAM
ram_led_table[a]=led_table[a];
}
left_led_val=LED_BLANK; // init or you could have garbage at start
right_led_val=LED_BLANK;
// Note I'm using 16MHz clock
setup_timer_0( RTCC_INTERNAL | RTCC_8_BIT | RTCC_DIV_128);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
// your program here
left_led_val=LED_DASH; // show "-7"
right_led_val=7;
// your program here
}
|
|
|
|
senator
Joined: 31 Jul 2009 Posts: 17
|
|
Posted: Mon Dec 07, 2009 7:27 pm |
|
|
Please Mr Mskala, how can I use your code because I am working on a similar project.
Undefined identifier "rtcc_toggle"and "led_serial" error keeps recurring.
Can you give step by step details on how a newbie can use your program codes.
Thanks |
|
|
anandpv2009
Joined: 26 Jul 2009 Posts: 31
|
|
Posted: Tue Dec 08, 2009 8:38 am |
|
|
what kind of display r u using(common anode or cathode) |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Tue Dec 08, 2009 9:17 am |
|
|
Did you bother to read the part number info he gave and look up the data sheet?
The LDD-E302NI is common anode. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
kizuc
Joined: 25 Aug 2009 Posts: 6
|
"Expecting an identifier" |
Posted: Tue Dec 08, 2009 9:54 am |
|
|
The major problem now is compiling this code successfully with CCS compiler. It keeps bringing up this error ""Expecting an identifier"" for clock_isr.
I am using PIC18F4550.
What might be wrong? Pls help out.
Thanks |
|
|
senator
Joined: 31 Jul 2009 Posts: 17
|
|
Posted: Tue Dec 08, 2009 9:54 am |
|
|
I use a common cathode 7 segment display.
Thanks in advance. |
|
|
anandpv2009
Joined: 26 Jul 2009 Posts: 31
|
|
Posted: Tue Dec 08, 2009 11:33 am |
|
|
dyeatman wrote: | Did you bother to read the part number info he gave and look up the data sheet?
The LDD-E302NI is common anode. |
Quote: | I use a common cathode 7 segment display.
Thanks in advance. |
I think this quotes are enough for dyeatman
My qustion is not to mskala
decode details for common cathode (Decimal values)
0 - 63
1 - 6
2 - 91
3 - 79
4 - 102
5 - 109
6 - 95
7 - 7
8 - 127
9 - 103 |
|
|
mskala
Joined: 06 Mar 2007 Posts: 100 Location: Massachusetts, USA
|
|
Posted: Tue Dec 08, 2009 11:40 am |
|
|
My apologies, I cut out a bit too much.
The variable rtcc_toggle is just a global 1-bit var. Since there are 2
characters in the display, every 8.2ms we have to change which 7-seg
is being driven. At that rate (or faster) it does not flicker.
The driver chip takes the 8 segments to be displayed serially. This is the routine.
Code: | void LED_serial(int8 val) {
int8 i;
for (i=0;i<7;i++) {
output_bit(PIN_LED_SDI,val&1);
val>>=1;
output_high(PIN_LED_CLK);
output_low(PIN_LED_CLK);
}
output_high(PIN_LED_CLK); // last bit is unimportant
output_low(PIN_LED_CLK);
output_high(PIN_LED_LE); // latch
output_low(PIN_LED_LE);
} |
Hope this helps. |
|
|
kizuc
Joined: 25 Aug 2009 Posts: 6
|
Error-Free code |
Posted: Wed Dec 16, 2009 5:20 am |
|
|
Hello mskala,
Thanks for your assistance so far. I want to suggest you the complete code for the 7 segment (an error-free code) display. I am compiling with CCS PCWH 4.032 compiler for PIC.
Thank you once again.
Kingsley |
|
|
|