Zrojak v C do Atmela pre prijem DO
xx
mrx111
Středa Březen 17 14:25:55 CET 2004
-----Original Message-----
From: Stanislav VARGA <pajdo@stava.sk>
To: hw-news@list.gin.cz <hw-news@list.gin.cz>
Date: 17. dubna 2002 9:56
Subject: Zrojak v C do Atmela pre prijem DO
>Ja by som chcel nejaky zdrojak na prijem DO do Atmela, ale zatial som to
>nejako nenasiel, je niekto ochotny mi toto poskytnut??????
>Najlepsie v C-ku.
>
>
>----- Original Message -----
>From: Michal MEDEK <Michal.MEDEK@worldonline.cz>
>To: <hw-news@list.gin.cz>
>Sent: Tuesday, April 16, 2002 9:13 PM
>Subject: Rizeni motoru ~230V/50Hz.
>
>
>Zdravim!
>
>Prosim, muzete me nekdo nasmerovat na nejaky odkaz na %subj%. Potreboval
>bych ridit motor cca 500W jednoc?p?m. Tak, kdyby byl nejaky zdrojak, byl
>bych moc rad. Hlavne ten uC nesmi pouzivat napr. vnitrni PWM.
>
>Moc dekuji Michal MEDEK
Je to cele v ASM, ale umi to prijimat najednou RECS-80, SONY, a RC5. Doufam,
ze me za ten kus prilozeneho source nikdo nesezere, je to odladene pro
11,0592xtal.
v badr je adresa vnitrni pameti, kam se ukladaji prijata data, irwait je na
to, aby se cekalo na konec vysilani po prvnim uspesnem prijeti. Nevim,
jestli to pomuze, snad se v tom da trochu vyznat.
Michal
PUSH PSW
PUSH ACC
PUSH B
SETB RS0
MOV A, irwait
JZ ii88
MOV irwait, #20
JMP ir_end
ii88:
CLR ftt
MOV tshort, #0
MOV R3, #0
MOV R0, #badr
MOV R7, #16
ii1:
MOV @R0, #0
INC R0
DJNZ R7, ii1
SETB first
JNB P3.2, $ ; ignore first pulse
MOV A, #255
tm1:
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
JNB P3.2, tm2
DJNZ ACC, tm1
JMP ir_end
tm2:
; start mereni pulsu
MOV R4, #0
tm33:
MOV A, #255
tm3:
NOP
NOP
NOP
JB P3.2, tm4
DJNZ ACC, tm3
JMP ir_end
tm4:
MOV R5, A
INC R3
JB first, tm44
CLR C
MOV A, R5
SUBB A, R6
JNC tm441
CLR C
MOV A, R6
SUBB A, R5
tm441:
ADD A, #230 ; max. tolerance odchylky
JC dodetect
MOV A, #255
SUBB A, R5
JNB ftt, tm48
ADD A, tshort
CLR ACC.0
RR A
tm48:
MOV tshort, A
SETB ftt
tm44:
CLR first
MOV A, #255
tm5:
NOP
NOP
NOP
JNB P3.2, tm6
DJNZ ACC, tm5
JMP ir_end
tm6:
INC R3
MOV R6, A
CLR C
MOV A, R5
SUBB A, R6
JNC tm451
CLR C
MOV A, R6
SUBB A, R5
tm451:
ADD A, #230 ; max. tolerance odchylky
JC dodetect
MOV A, #255
SUBB A, R5
ADD A, tshort
CLR ACC.0
RR A
MOV tshort, A
INC R4
JMP tm33
dosony1:
JMP dosony
dodetect:
CLR C
MOV A, R5
SUBB A, R6
JC dosony1
MOV B, A
SUBB A, R6
JNC drc1
CLR C
MOV A, R6
SUBB A, B
drc1:
ADD A, #210
JNC norc5
MOV bpos, #0 ; start prijmu RC5
CLR rcok
MOV A, #255
SUBB A, tshort
MOV tshort, A
CLR first
drc2:
CALL rcwait
JNB gpulse, drc3
CPL first
drc3:
CPL first
JB first, drc55
INC bpos
JB fbit, drc55
CALL setbit
drc55:
CALL rcwait
JNB gpulse, drc4
CPL first
drc4:
CPL first
JB first, drc5
INC bpos
JB fbit, drc5
CALL setbit
drc5:
JNB rcok, drc2
JMP re_end
norc5:
; prijem RECS-80
MOV bpos, R3
INC bpos
CALL setbit
re0:
JB P3.2, re1
MOV A, #255
re2:
NOP
NOP
NOP
JB P3.2, re45
DJNZ ACC, re2
JMP re_end
re1:
MOV A, #255
re3:
NOP
NOP
NOP
JNB P3.2, re4
DJNZ ACC, re3
JMP re_end
re45:
INC bpos
re4:
CLR C
MOV B, A
SUBB A, R5
JNC re5
MOV A, R5
SUBB A, B
re5:
ADD A, #230
JNC re6
CALL setbit
JMP re0
re6:
JMP re0
re_end:
CLR C
MOV A, bpos
ANL A, #248
RR A
RR A
RR A
MOV lgcode, A
MOV A, bpos
ANL A, #7
JZ rd15
INC lgcode
rd15:
MOV irwait, #20
SETB rcok
ir_end:
POP B
POP ACC
POP PSW
RETI
dosony:
MOV bpos, R4
INC bpos
CALL setbit
INC bpos
sn0:
JB P3.2, sn1
MOV A, #255
sn2:
NOP
NOP
NOP
JB P3.2, sn4
DJNZ ACC, sn2
JMP sn_end
sn1:
MOV A, #255
sn3:
NOP
NOP
NOP
JNB P3.2, sn45
DJNZ ACC, sn3
JMP sn_end
sn45:
INC bpos
JMP sn0
sn4:
CLR C
MOV B, A
SUBB A, R5
JNC sn5
MOV A, R5
SUBB A, B
sn5:
ADD A, #230
JNC sn0
CALL setbit
JMP sn0
sn_end:
JMP re_end
setbit:
PUSH B
MOV A, bpos
ANL A, #56 ; max 8 byte pro jeden command
RR A
RR A
RR A
ADD A, #badr
MOV R0, A
MOV A, bpos
MOV B, #128
ANL A, #7
JZ sb1
sb0:
XCH A, B
RR A
XCH A, B
DJNZ ACC, sb0
sb1:
MOV A, B
ORL A, @R0
MOV @R0, A
POP B
RET
rcwait:
SETB gpulse
MOV A, #255
MOV C, P3.2
MOV fbit, C
JB P3.2, rw2
rw1:
NOP
NOP
NOP
JB P3.2, rw4
DJNZ ACC, rw1
SETB rcok
RET
rw2:
NOP
NOP
NOP
JNB P3.2, rw4
DJNZ ACC, rw2
SETB rcok
RET
rw4:
CLR C
MOV B, A
SUBB A, tshort
JNC rw5
MOV A, tshort
CLR C
SUBB A, B
rw5:
ADD A, #220
JC rw6
CLR gpulse
rw6:
CLR C
RET
Další informace o konferenci Hw-list