Escolar Documentos
Profissional Documentos
Cultura Documentos
PROPOSAL PIC16F876A
SCEMATIC
SOUCRE CODE
/*
'*******************************************************************************
' Project name: PIC16F876A & MAX7219 For 8x8 LED Display
' Description:
'
Trough the current experiment we wish to succed the next task:
'
Display on 8x8 Led matrix, the alphabet. The sequence between letters,
'
will have one second delay.
' Written by:
'
Mark &
'
Aureliu Raducu Macovei, 2011.
' Test configuration:
'
MCU:
PIC16F876A;
'
Test.Board:
WB-106 Breadboard 2420 dots;
'
SW:
MikroC PRO for PIC 2011 (version v4.60);
' Configuration Word:
'
Oscillator:
HS (8Mhz)on pins 9 and 10;
'
Watchdog Timer:
OFF;
'
Power up Timer:
OFF;
'
Browun Out Detect:
ON;
'
Low Voltage Program:
Disabled;
'
Data EE Read Protect:
OFF;
'
Flash Program Write:
Write Protection OFF;
'
Background Debug:
Disabled;
'
Code Protect:
OFF
'*******************************************************************************
*/
// For more space, we don't need byte 0 and byte 7.
// We have stripped them out, if/when we have a need and a bigger PIC,
// then we can put them back if we want.
// Here we define row values for each of the six
// Alphabet, from A through Z.
unsigned const short Alphabet[156]={
0x7f, 0x88,
0xff, 0x91,
0x7e, 0x81,
0xff, 0x81,
0x81, 0xff,
0x81, 0xff,
0x7e, 0x81,
0xff, 0x10,
0x00, 0x81,
0x06, 0x01,
0x81, 0xff,
0x81, 0xff,
0xff, 0x60,
0xff, 0x60,
0x7e, 0x81,
0x81, 0xff,
0x7e, 0x81,
0x88,
0x91,
0x81,
0x81,
0x91,
0x91,
0x81,
0x10,
0xff,
0x81,
0x99,
0x81,
0x18,
0x10,
0x81,
0x89,
0x85,
0x88,
0x91,
0x81,
0x81,
0x91,
0x90,
0x89,
0x10,
0xff,
0xfe,
0x24,
0x01,
0x18,
0x08,
0x81,
0x88,
0x89,
0x88,
0x91,
0x81,
0x81,
0x91,
0x90,
0x89,
0x10,
0x81,
0x80,
0xc3,
0x01,
0x60,
0x06,
0x81,
0x88,
0x87,
0x7f,
0x6e,
0x42,
0x7e,
0x91,
0x80,
0x4e,
0xff,
0x00,
0x00,
0x81,
0x03,
0xff,
0xff,
0x7e,
0x70,
0x7e,
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
0xff,
0x62,
0xc0,
0xfe,
0xfc,
0xff,
0xc3,
0xc0,
0xc3,
};
0x98,
0x91,
0x81,
0x01,
0x02,
0x02,
0x24,
0x20,
0x85,
0x98,
0x91,
0xff,
0x01,
0x01,
0x04,
0x18,
0x1f,
0x89,
0x94,
0x91,
0xff,
0x01,
0x01,
0x04,
0x18,
0x1f,
0x91,
0x93,
0x91,
0x81,
0x01,
0x02,
0x02,
0x24,
0x20,
0xa1,
0x61,
0x4e,
0xc0,
0xfe,
0xfc,
0xff,
0xc3,
0xc0,
0xc3,
//
//
//
//
//
//
//
//
//
R
S
T
U
V
W
X
Y
Z
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
(
)
[
]
{
}
<
>
/
\
0x3c,
0x00,
0x00,
0x00,
0x18,
0x00,
0x18,
0x81,
0x03,
0xc0,
0x00,
0x00,
0x80,
0x24,
0xff,
0x91,
0x99,
0xa4,
0x3f,
0x42,
0x81,
0xff,
0x81,
0xe7,
0x81,
0x24,
0x42,
0x0c,
0x30,
0x00,
0xfd,
0x8d,
0xff,
0x24,
0xff,
0x99,
0x48,
0x20,
0x81,
0x42,
0x81,
0xff,
0x81,
0xe7,
0x42,
0x24,
0x30,
0x0c,
0x00,
0xfd,
0x8d,
0xff,
0x24,
0xff,
0x66,
0x12,
0x20,
// SELECT MAX
Chip_Select = 0;
SPI1_write(0x0B);
SPI1_write(0x07);
Chip_Select = 1;
// SELECT MAX
Chip_Select = 0;
SPI1_write(0x0C);
// SELECT MAX
// Display refresh
// DESELECT MAX
0x00,
0x3c,
0x00,
0x00,
0x00,
0x18,
0x81,
0x18,
0xc0,
0x03,
0x00,
0x00,
0x90,
0x24,
0xff,
0x91,
0x09,
0x25,
0x3e,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x60,
0x42,
0x24,
0x4e,
0x00,
0x42,
0x21,
!
?
*
#
$
&
%
pi
SPI1_write(0x01);
Chip_Select = 1;
Chip_Select = 0;
SPI1_write(0x00);
SPI1_write(0xFF);
Chip_Select = 1;
}
// SELECT MAX
// No test
// DESELECT MAX
Clear_Matrix();
// The next line defines our byte, from which to start the array.
Start_Byte1 = (mysymbols-0) * 6 ;
// We are using only columns from 2 through 7 for displaying the character.
for(Column1=2;Column1<8;Column1++)
{
Write_Byte(Column1, Symbols[Start_Byte1++]);
}
}
// Here we have the main function.
void main()
{
unsigned int x,y;
Chip_Select_Direction = 0;
SPI1_init();
max7219_init1();
// initialize
do
{
// infinite loop.
max7219.
for(y=0;y<=18;y++)
{
Write_Symbol(y);
Delay_ms(1000);
}
}while(1);
// do forever.