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 |
143 |
olivier.gi |
#include "omsp_system.h"
|
44 |
2 |
olivier.gi |
|
45 |
|
|
typedef unsigned char INT8U;
|
46 |
|
|
typedef unsigned int INT16U;
|
47 |
|
|
|
48 |
|
|
// Four-Digit, Seven-Segment LED Display driver
|
49 |
143 |
olivier.gi |
#define DIGIT0 (*(volatile unsigned char *) 0x0090)
|
50 |
|
|
#define DIGIT1 (*(volatile unsigned char *) 0x0091)
|
51 |
|
|
#define DIGIT2 (*(volatile unsigned char *) 0x0092)
|
52 |
|
|
#define DIGIT3 (*(volatile unsigned char *) 0x0093)
|
53 |
2 |
olivier.gi |
|
54 |
|
|
#define DIGIT_NR 4 /* Total number of seven-segment digits */
|
55 |
|
|
|
56 |
|
|
/*
|
57 |
|
|
*********************************************************************************************************
|
58 |
|
|
* FUNCTION PROTOTYPES
|
59 |
|
|
*********************************************************************************************************
|
60 |
|
|
*/
|
61 |
|
|
|
62 |
|
|
void DispStr(INT8U offset, INT8U *s); //API to display an ASCII string
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
#endif // _7SEG_H
|