05.08.2014 Views

1 C Programming for Embedded Systems. Data RAM Pointer Types ...

1 C Programming for Embedded Systems. Data RAM Pointer Types ...

1 C Programming for Embedded Systems. Data RAM Pointer Types ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

P. Klimo Sep 2010<br />

CODE<br />

/* File: 7SegDisplay_1D.c<br />

Description:<br />

Displays a digit on single 7-segment display. Segments connected to PORTD ( segment A to RD0, segment B to<br />

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);<br />

unsigned short SendCode(unsigned short num);<br />

unsigned short count;<br />

// Delay routine<br />

// Convert binary to seven segment code<br />

// Display value<br />

void main()<br />

{ // Initialize Ports<br />

PORTA = 0;<br />

TRISA = 0xfd;<br />

PORTD = 0;<br />

TRISD = 0;<br />

// Configure bit 1 of Port A as output<br />

// by clearing bit 1 in the TRISA register<br />

// Configure all bits of Port D as outputs<br />

// by clearing the TRISD register<br />

do { // Proceed incrementing the displayed digit from 0 to 9<br />

<strong>for</strong> (count = 0; count

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!