A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
Hi-Tech init of PORTD on 16F877 - KM6VV - Jun 13 22:30:00 2005
Hi to the list!
I'm having problems getting an LED display (4 digits) to work with a 20 Mhz
16F877A. New (to me) compiler, PIC C, 7.83 OLD compiler was CCS.
The Display is common cathode, digits are selected with a ULN2003 driver from
RB7, RB6, RC7, RC5 pins (which appear to work), and the segments are driven
through 220 ohm resistors from PORTD. Source code (company's old ASM) I have
for the board works! So it's not the hardware.
I determined and verified the segment and digit lines from both the hardware and
the .ASM code for the board.
I have a buzzer also driven by a ULN2003 on RC6, and it works!
I don't see any activity on segment (PORTD) lines. I have the following init code:
/* clear the ports */
PORTA = PORTB = PORTC = PORTD = PORTE = 0;
/* setup ports to be outputs where needed */
#define DIGIT_0 RB7 /* LED D1 pin 12 MSD */
#define DIGIT_1 RB6 /* LED D2 pin 9 */
#define DIGIT_2 RC7 /* LED D3 pin 8 */
#define DIGIT_3 RC4 /* LED D4 pin 6 LSD */
#define LED_SEGMENT_PORT PORTD /* Sprinte III LED segment A-H port */
TRISA = 0B11111111; /* high impedance */
TRISB = 0B00111111; /* RB6 RB7 digit select bits */
TRISC = 0B00101101; /* RC4 RC7 digit select bits, RC6 buzzer */
TRISD = 0B00000000; /* LED segment latch, all out */
TRISE = 0B11111111; /* high impedance */
DIGIT_0 = DIGIT_OFF;/* all lcd digits off (2003 invert, active low) */
DIGIT_1 = DIGIT_OFF;
DIGIT_2 = DIGIT_OFF;
DIGIT_3 = DIGIT_OFF;
The timers are off. The following loop turns the buzzer on and off, but no LED
display activity.
This loop should turn a segment on and off with the buzzer.
LED_SEGMENT_PORT = 0x55; /* TEST out to segment port */
DIGIT_3 = DIGIT_ON; /* C4 */
for( ; ; )
{
DIGIT_3 = DIGIT_ON; /* B7 */
BUZZER = DIGIT_ON; /* C4 */
for( i = 0; i < 50000 ;i++ ) /* test delay of about 2 sec */
for( j = 0; j < 2; j++)
{}
DIGIT_3 = DIGIT_OFF;
BUZZER = DIGIT_OFF;
for( i = 0; i < 50000 ;i++ )
for( j = 0; j < 2; j++)
{}
}
OK, 55h isn't a real digit to display (should make all seg lines alternatly turn
on and off), but for example, these would be:
#define ZERO 0B00111111
#define ONE 0B00000110
#define TWO 0B01011011
Any Ideas?
Alan KM6VV

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
RE: Hi-Tech init of PORTD on 16F877 - Alan Marconett - Jun 21 13:27:00 2005
Hi again to the list.
It only took a week+ to get this posted! I've gotten it all figured out.
The answer was a bit in the PORTE configuration, WE DON'T want SLAVE PORTS!
Alan KM6VV
> -----Original Message-----
> From: piclist@picl... [mailto:piclist@picl...] On Behalf
> Of KM6VV
> Sent: Monday, June 13, 2005 7:30 PM
> To: PIC list
> Subject: [piclist] Hi-Tech init of PORTD on 16F877
>
> Hi to the list!
>
> I'm having problems getting an LED display (4 digits) to work with a 20
> Mhz 16F877A. New (to me) compiler, PIC C, 7.83 OLD compiler was CCS.
>
> The Display is common cathode, digits are selected with a ULN2003 driver
> from RB7, RB6, RC7, RC5 pins (which appear to work), and the segments are
> driven through 220 ohm resistors from PORTD. Source code (company's old
> ASM) I have for the board works! So it's not the hardware.
>
> I determined and verified the segment and digit lines from both the
> hardware and the .ASM code for the board.
>
> I have a buzzer also driven by a ULN2003 on RC6, and it works!
>
> I don't see any activity on segment (PORTD) lines. I have the following
> init code:
>
> <SNIP>
>
> Any Ideas?
>
> Alan KM6VV

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )