1 Example: Driving Seven Segment Display Schematic Easypic 4 ...
1 Example: Driving Seven Segment Display Schematic Easypic 4 ...
1 Example: Driving Seven Segment Display Schematic Easypic 4 ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Schematic</strong><br />
Task:<br />
<strong>Example</strong>: <strong>Driving</strong> <strong>Seven</strong> <strong>Segment</strong> <strong>Display</strong><br />
EasyPic 4 Board<br />
1<br />
P. Klimo September 2009<br />
Drive a single digit <strong>Seven</strong> <strong>Segment</strong> display, displaying digits between 0 and 9 at 1 second<br />
interval.
Flow Diagram:<br />
2<br />
P. Klimo September 2009
CODE<br />
3<br />
P. Klimo September 2009<br />
/* File: 7Seg<strong>Display</strong>_1D.c<br />
Description:<br />
<strong>Display</strong>s a digit on single 7-segment display. <strong>Segment</strong>s connected to PORTD ( segment A to RD0,<br />
segment B to RD1, etc); Common cathode is connected to the pin RA1 on PORTA. Incremented every 1s.<br />
* Test configuration: MCU: P16F877A Dev.Board: EasyPIC4<br />
Xtal: HS, 8 MHz SW: PICC.0 */<br />
#include /* HI-tech compiler definitions */<br />
/* PIC configuration: HS oscillator, Watch Dog Timer off, Browning Effect off, Low Voltage Mode off */<br />
__CONFIG(HS&WDTDIS&PWRTDIS& BORDIS&LVPDIS ); // HiTec Pragmas<br />
void Delay_ms(int ms); // Delay routine<br />
unsigned short SendCode(unsigned short num); // Convert binary to seven segment code<br />
unsigned short count; // <strong>Display</strong> value<br />
void main()<br />
{ // Initialize Ports<br />
PORTA = 0; // Configure bit 1 of Port A as output<br />
TRISA = 0xfd; // by clearing bit 1 in the TRISA register<br />
PORTD = 0; // Configure all bits of Port D as outputs<br />
TRISD = 0; // by clearing the TRISD register<br />
do { // Proceed incrementing the displayed digit from 0 to 9<br />
for (count = 0; count0){<br />
for (i=0; i< Xtal_Freq; i++){;}<br />
count--;<br />
}