1 |
2 |
olivier.gi |
/*
|
2 |
|
|
*********************************************************************************************************
|
3 |
|
|
*
|
4 |
|
|
* Multiplexed LED Display Driver
|
5 |
|
|
* Reference: Jean J. Labrosse, Embedded Systems Building Blocks
|
6 |
|
|
*
|
7 |
|
|
* Filename : LED.C
|
8 |
|
|
* Programmer : John Leung (www.TechToys.com.hk)
|
9 |
|
|
* Remarks : Modified for PIC16-LEDSTK1
|
10 |
|
|
* Date : First version 1.0 on 19th Nov 2004
|
11 |
|
|
* Language : CCS C complier for PIC mid-range MCU, PCM version 3.170, under MPLAB IDE 7.01
|
12 |
|
|
* Hardware : PCB 11OCT2004.001, MCU is Microchip's PIC16F877a
|
13 |
|
|
* History : Modified for PIC16-LEDSTK1 dated 12 Jan 2006
|
14 |
|
|
*********************************************************************************************************
|
15 |
|
|
* DESCRIPTION
|
16 |
|
|
*
|
17 |
|
|
* This module provides an interface to a multiplexed "7-segments x N digits" LED matrix.
|
18 |
|
|
*
|
19 |
|
|
* To use this driver:
|
20 |
|
|
*
|
21 |
|
|
* 1) To use this module, the following parameters under define (LED.H):
|
22 |
|
|
*
|
23 |
|
|
* DISP_N_DIG The total number of segments to display, inc. dp status
|
24 |
|
|
* DISP_N_SS The total number of seven-segment digits, e.g "0" "1" "2" is 3-digit
|
25 |
|
|
* DISP_PORT1_DIG The address of the DIGITS output port
|
26 |
|
|
* DISP_PORT_SEG The address of the SEGMENTS output port
|
27 |
|
|
* first_dig_msk The first digit mask for selecting the most significant digit
|
28 |
|
|
*
|
29 |
|
|
* 2) Allocate a hardware timer which will interrupt the CPU at a rate of at least:
|
30 |
|
|
*
|
31 |
|
|
* DISP_N_DIG * 60 (Hz)
|
32 |
|
|
*
|
33 |
|
|
*********************************************************************************************************
|
34 |
|
|
*/
|
35 |
|
|
#ifndef _7SEG_H
|
36 |
|
|
#define _7SEG_H
|
37 |
|
|
|
38 |
|
|
/*
|
39 |
|
|
*********************************************************************************************************
|
40 |
|
|
* CONSTANTS
|
41 |
|
|
*********************************************************************************************************
|
42 |
|
|
*/
|
43 |
|
|
#include <io.h>
|
44 |
|
|
#include <signal.h>
|
45 |
|
|
#include <iomacros.h>
|
46 |
|
|
|
47 |
|
|
typedef unsigned char INT8U;
|
48 |
|
|
typedef unsigned int INT16U;
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
// Four-Digit, Seven-Segment LED Display driver
|
52 |
|
|
#define DIGIT0_ 0x0090
|
53 |
|
|
sfrb (DIGIT0,DIGIT0_);
|
54 |
|
|
#define DIGIT1_ 0x0091
|
55 |
|
|
sfrb (DIGIT1,DIGIT1_);
|
56 |
|
|
#define DIGIT2_ 0x0092
|
57 |
|
|
sfrb (DIGIT2,DIGIT2_);
|
58 |
|
|
#define DIGIT3_ 0x0093
|
59 |
|
|
sfrb (DIGIT3,DIGIT3_);
|
60 |
|
|
|
61 |
|
|
#define DIGIT_NR 4 /* Total number of seven-segment digits */
|
62 |
|
|
|
63 |
|
|
/*
|
64 |
|
|
*********************************************************************************************************
|
65 |
|
|
* FUNCTION PROTOTYPES
|
66 |
|
|
*********************************************************************************************************
|
67 |
|
|
*/
|
68 |
|
|
|
69 |
|
|
void DispStr(INT8U offset, INT8U *s); //API to display an ASCII string
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
#endif // _7SEG_H
|