Z
z543g
Guest
/ ** IR_LED test za 89c2051 ** /
# define IR_LED P1.0
poniłtava delay_us (int tt)
(
dok (tt -);
)
poniłtava delay_ms (int tt)
(
dok (tt> 0)
(
delay_us (160);
delay_us (160);
tt -;
)
)
poniłtava rc5_send_pulses (void)
(
nepotpisani pougljiti I;
i = 32;
a (i -)
(
IR_LED = 0;
delay_us (7);
IR_LED = 1;
delay_us (19);
)
)
poniłtava rc5_send_0 (void)
(
rc5_send_pulses ();
delay_us (889);
)
poniłtava rc5_send_1 (void)
(
delay_us (889);
rc5_send_pulses ();
)
poniłtava rc5_send (pougljiti adresa, pougljiti naredbu)
(
nepotpisani rc5_code int;
nepotpisani pougljiti I;
rc5_code = 0x07;
rc5_code <<= 5;
rc5_code | = (& 0x1f adresa);
rc5_code <<= 6;
rc5_code | = (naredba & 0x3f);
rc5_code <<= 2;
i = 14;
a (i -) (
if (rc5_code & 0x8000)
rc5_send_1 ();
drugi
rc5_send_0 ();
rc5_code <<= 1;
)
)
poniłtava glavna (void)
(
a (1)
(
rc5_send (5,53);
delay_ms (114);
)
)-------------------------------------------------- -------------------------
/ ** RC5_RECEIVE za 89c2051 ** /
typedef nepotpisan pougljiti Byte;
typedef int nepotpisan WORD;
# define RC5_IN P1.0
poniłtava delay_us (int tt)
(
dok (tt -);
)
poniłtava delay_ms (int tt)
(
dok (tt> 0)
(
delay_us (160);
delay_us (160);
tt -;
)
)
Byte read_SBUF (void)
(
dok (RI == 0) ()
RI = 0;
povratak SBUF;
)
poniłtava write_SBUF (bajt CH)
(
a (TI == 0) ()
TI = 0;
SBUF = ch;
)
poniłtava scu_str (pougljiti s [])
(
Byte I;
i = 0;
a (a ! = '\ 0')
(
write_SBUF (a [i ]);
)
)
poniłtava scu_init (void)
(
SCON = 0x52;
TMOD = TMOD & 0x0f;
TMOD = TMOD | 0x20;
TH1 = 0xfd;
TR1 = 1;
)
int rc5_receive (void)
(
int rc5_code;
nepotpisani pougljiti I;
nepotpisani pougljiti q;
rc5_code = 1;
dok (RC5_IN) i dalje;
delay_us (444);
if (RC5_IN) vrati RC5_ERR;
i = 13;
a (i -)
(
q = 0;
rc5_code <<= 1;
delay_us (889);
if (RC5_IN) q = 2;
delay_us (889);
if (RC5_IN) q ;
preklopnik (q)
(
case 1: rc5_code | = 0; break;
case 2: rc5_code | = 1; break;
defualt: povratak RC5_ERR;
)
)
povratak rc5_code & 0x07ff;
)
poniłtava glavna (void)
(
nepotpisani int i;
scu_init ()
a (1)
(
i = rc5_receive ();
printf ( "% d% d \ n \ r", i>> 6, ja & 0x003f);
)
)
odgovor:
16384 63
0 0
16384 63
16384 63 <- Ne znam o rc5 kodom.molim tko
<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Tužan" border="0" />
.pogreška rc5 source code?<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Tužan" border="0" /><img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Tužan" border="0" />
help me ...help me ...
<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Tužan" border="0" /><img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Tužan" border="0" />
# define IR_LED P1.0
poniłtava delay_us (int tt)
(
dok (tt -);
)
poniłtava delay_ms (int tt)
(
dok (tt> 0)
(
delay_us (160);
delay_us (160);
tt -;
)
)
poniłtava rc5_send_pulses (void)
(
nepotpisani pougljiti I;
i = 32;
a (i -)
(
IR_LED = 0;
delay_us (7);
IR_LED = 1;
delay_us (19);
)
)
poniłtava rc5_send_0 (void)
(
rc5_send_pulses ();
delay_us (889);
)
poniłtava rc5_send_1 (void)
(
delay_us (889);
rc5_send_pulses ();
)
poniłtava rc5_send (pougljiti adresa, pougljiti naredbu)
(
nepotpisani rc5_code int;
nepotpisani pougljiti I;
rc5_code = 0x07;
rc5_code <<= 5;
rc5_code | = (& 0x1f adresa);
rc5_code <<= 6;
rc5_code | = (naredba & 0x3f);
rc5_code <<= 2;
i = 14;
a (i -) (
if (rc5_code & 0x8000)
rc5_send_1 ();
drugi
rc5_send_0 ();
rc5_code <<= 1;
)
)
poniłtava glavna (void)
(
a (1)
(
rc5_send (5,53);
delay_ms (114);
)
)-------------------------------------------------- -------------------------
/ ** RC5_RECEIVE za 89c2051 ** /
typedef nepotpisan pougljiti Byte;
typedef int nepotpisan WORD;
# define RC5_IN P1.0
poniłtava delay_us (int tt)
(
dok (tt -);
)
poniłtava delay_ms (int tt)
(
dok (tt> 0)
(
delay_us (160);
delay_us (160);
tt -;
)
)
Byte read_SBUF (void)
(
dok (RI == 0) ()
RI = 0;
povratak SBUF;
)
poniłtava write_SBUF (bajt CH)
(
a (TI == 0) ()
TI = 0;
SBUF = ch;
)
poniłtava scu_str (pougljiti s [])
(
Byte I;
i = 0;
a (a ! = '\ 0')
(
write_SBUF (a [i ]);
)
)
poniłtava scu_init (void)
(
SCON = 0x52;
TMOD = TMOD & 0x0f;
TMOD = TMOD | 0x20;
TH1 = 0xfd;
TR1 = 1;
)
int rc5_receive (void)
(
int rc5_code;
nepotpisani pougljiti I;
nepotpisani pougljiti q;
rc5_code = 1;
dok (RC5_IN) i dalje;
delay_us (444);
if (RC5_IN) vrati RC5_ERR;
i = 13;
a (i -)
(
q = 0;
rc5_code <<= 1;
delay_us (889);
if (RC5_IN) q = 2;
delay_us (889);
if (RC5_IN) q ;
preklopnik (q)
(
case 1: rc5_code | = 0; break;
case 2: rc5_code | = 1; break;
defualt: povratak RC5_ERR;
)
)
povratak rc5_code & 0x07ff;
)
poniłtava glavna (void)
(
nepotpisani int i;
scu_init ()
a (1)
(
i = rc5_receive ();
printf ( "% d% d \ n \ r", i>> 6, ja & 0x003f);
)
)
odgovor:
16384 63
0 0
16384 63
16384 63 <- Ne znam o rc5 kodom.molim tko
<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Tužan" border="0" />
.pogreška rc5 source code?<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Tužan" border="0" /><img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Tužan" border="0" />
help me ...help me ...
<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Tužan" border="0" /><img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Tužan" border="0" />