📄 tlc549_p.c
字号:
/* TLC549.C - Real Timer for the Keil Evaluation with 80C51 device*/
/******************************************************************
Revision history:
2005/04/20 Arthur Zhu initial begin
*******************************************************************/
#include <REG51.H>
#include "ex.H"
#define DISP_DLY 4
#define TLC_IDLE 32
#define TLC_DLY 2
unsigned char led_7seg[] = { /* LED 7 segment data */
0x3F, /* 0 */
0x06, /* 1 */
0x5B, /* 2 */
0x4F, /* 3 */
0x66, /* 4 */
0x6D, /* 5 */
0x7D, /* 6 */
0x07, /* 7 */
0x7F, /* 8 */
0x6F, /* 9 */
0x77, /* Aa */
0x7C, /* Bb */
0x39, /* Cc */
0x5E, /* Dd */
0x79, /* Ee */
0x71, /* Ff */
};
/*------------------------ --- Delay_n_us ----- ---------------------*/
void Delay_n_us (unsigned int n_us)
{
while (n_us--);
}
void disp_led (
unsigned char dd,
unsigned char addr1,
unsigned char addr2
)
{
unsigned char temp;
temp = (dd & 0x0F0) >> 4;
P0 = led_7seg[temp];
P2 = addr1;
Delay_n_us (DISP_DLY);
temp = dd & 0x0F;
P0 = led_7seg[temp];
P2 = addr2;
Delay_n_us (DISP_DLY);
}
/*------------------------- TLC549 Read ------------------------*/
int TLC549_RD (unsigned char *rdata) // Use pointer
{
unsigned char i;
unsigned char temp;
temp = TLC549_DOUT;
*rdata = 0x00;
*rdata = *rdata | temp;
for ( i = 0; i < 7; i++ )
{
TLC549_IOCLK = 1;
Delay_n_us (TLC_DLY);
TLC549_IOCLK = 0;
Delay_n_us (TLC_DLY);
temp = TLC549_DOUT;
*rdata <<= 1;
*rdata = *rdata | temp;
}
TLC549_IOCLK = 1;
Delay_n_us (TLC_DLY);
TLC549_IOCLK = 0;
Delay_n_us (TLC_DLY);
}
void main ()
{
unsigned char TLC549_data;
TLC549_CS_ = 0;
TLC549_RD (&TLC549_data); // Sample data
TLC549_CS_ = 1;
Delay_n_us (TLC_IDLE);
TLC549_CS_ = 0;
TLC549_RD (&TLC549_data); // Read data
TLC549_CS_ = 1;
while (1)
disp_led (TLC549_data, 0x08, 0x04);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -