Re: Pleaze.

J

joedarton

Guest
Volám sa Joe, Student vo Vietname.
Prosím, pomôžte mi!

Mám záverečnej skúšky v univerzite.Téma "Programovanie ISP 89S51 pomocou 89c51".Je rád "89Sxx In-obvodov Serial Programmer".
Mám promblem s "Serial Programovanie Načasovanie".
Som kódovanie niektorých funkcií.Ale nevyzerá funkcie `t práce.
Potom, čo som volať funkciu "Programming_Enable" výstupné dáta Podľa = 0.(Nie = 01101001B)
Pleaze Pomôžte mi opraviť niektoré problémy.
Ďakujeme, že ste veľmi veľmi veľmi veľmi .....moc.
Pin connet:
Master At89c51 otrokář AT89s51
P1.0 RST
P1.1 SCK
P1.2 miso
P1.3 mosi
Moja Kód:
"*****************************"
"Funtion napiš Jeden Byte Chcete 89s52"
"*****************************"
WRITE_BYTE:
JB ACC.0, LABEL0
CLR P1.3
LJMP LA0
LABEL0: osev P1.3
LA0: NOP
Osev P1.1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
NOP
JB ACC.1, Label1
CLR P1.3
LJMP LA1
Label1: osev P1.3
LA1: NOP
Osev P1.1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
NOP
JB ACC.2, Label2
CLR P1.3
LJMP LA2
Label2: osev P1.3
LA2: NOP
Osev P1.1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
NOP
JB ACC.3, LABEL3
CLR P1.3
LJMP LA3
LABEL3: osev P1.3
LA3: NOP
Osev P1.1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
NOP
JB ACC.4, LABEL4
CLR P1.3
LJMP LA4
LABEL4: osev P1.3
LA4: NOP
Osev P1.1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
NOP
JB ACC.5, LABEL5
CLR P1.3
LJMP LA5
LABEL5: osev P1.3
LA5: NOP
Osev P1.1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
NOP
JB ACC.6, LABEL6
CLR P1.3
LJMP LA6
LABEL6: osev P1.3
LA6: NOP
Osev P1.1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
NOP
JB ACC.7, LABEL7
CLR P1.3
LJMP La7
LABEL7: osev P1.3
La7: NOP
Osev P1.1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
NOP
RET
************************************************** ******

"***************************************"
"Funtion napiš 4 Byte pre AT89s51"
"Vstup: R0: začať riešiť pamäte pomocou ukladanie dát"
"***************************************"
WRITE_4_BYTE:
MOV R1, # 4
LAP_WRITE_4_BYTE:
MOV A, @ R0
INC R0
LCALL WRITE_BYTE
DJNZ R1, LAP_WRITE_4_BYTE
RET
************************************************** *
"***************************************"
"Funtion Programovanie Enable"
"DATA: MOV 20H, # 10101100B"
"MOV 21h, # 01010011B"
"MOV 22h, # 0"
"MOV 23h, # 0"
"Vstup: R0: začať riešiť pomocou pamäťovej úložiska dát (# 20H)"
"Výstup: ACC = 01101001B"
"***************************************"

PROGRAMING_ENABLE:
Osev P1.0
NOP
NOP
NOP
NOP
NOP
NOP
MOV R0, # 20H
LCALL WRITE_4_BYTE
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READP0
Osev ACC.0
LJMP RAP0
READP0: CLR ACC.0
RAP0: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READP1
Osev ACC.1
LJMP RAP1
READP1: CLR ACC.1
RAP1: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READP2
Osev ACC.2
LJMP RAP2
READP2: CLR ACC.2
RAP2: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READP3
Osev ACC.3
LJMP RAP3
READP3: CLR ACC.3
RAP3: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READP4
Osev ACC.4
LJMP RAP4
READP4: CLR ACC.4
RAP4: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READP5
Osev ACC.5
LJMP RAP5
READP5: CLR ACC.5
RAP5: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READP6
Osev ACC.6
LJMP RAP6
READP6: CLR ACC.6
RAP6: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READP7
Osev ACC.7
LJMP RAP7
READP7: CLR ACC.7
RAP7: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
RET
************************************************** ********
"***************************************"
"Funtion Zmazať data"
"DATA: MOV 24H, # 10101100B"
"MOV 25h, # 10000000B"
"MOV 26h, # 0"
"MOV 27H, # 0"
"Vstup: R0: začať riešiť pomocou pamäťovej úložiska dát (# 24H)"
"***************************************"

ERASE_DATA:
MOV R0, # 24H
LCALL WRITE_4_BYTE
MOV R3, # 10
LAP_ERASE_DATA0:
MOV R4, # 250
LAP_ERASE_DATA1:
MOV R5, # 200
DJNZ R5, $
DJNZ R4, LAP_ERASE_DATA1
DJNZ R3, LAP_ERASE_DATA0
RET
************************************************** ******
"***************************************"
"Funtion Programovanie Enable"
"DATA: MOV 28h, # 00100000B"
"MOV 29h,"
"MOV 2AH, # 0"
"MOV 2BH, # 0"
"Vstup: R0: začať riešiť pomocou pamäťovej úložiska dát (# 28h)"
"Výstup: ACC: data readed"
"***************************************"
READ_BYTE:
MOV R0, # 28h
LCALL WRITE_4_BYTE
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READ0
Osev ACC.0
LJMP RA0
READ0: CLR ACC.0
RA0: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READ1
Osev ACC.1
LJMP RA1
READ1: CLR ACC.1
RA1: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READ2
Osev ACC.2
LJMP RA2
READ2: CLR ACC.2
RA2: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READ3
Osev ACC.3
LJMP RA3
READ3: CLR ACC.3
RA3: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READ4
Osev ACC.4
LJMP RA4
READ4: CLR ACC.4
RA4: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READ5
Osev ACC.5
LJMP RA5
READ5: CLR ACC.5
RA5: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READ6
Osev ACC.6
LJMP RA6
READ6: CLR ACC.6
RA6: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
NOP
NOP
NOP
Osev P1.1
NOP
NOP
JB P1.2, READ7
Osev ACC.7
LJMP RA7
READ7: CLR ACC.7
RA7: NOP
NOP
NOP
NOP
NOP
NOP
CLR P1.1
RET
*************************************************

Pridané po 11 minútach:Váš email: Joedarton (at) gmail.com

 
Zkus tohle:
Kód:

RST bit P1.0

SCK bit P1.1

Miso bit P1.2

Mosi bit P1.3

"*****************************"

"Funkcia napiš Jeden Byte Chcete 89s52"

"*****************************"

WriteByte:

CLR SCK

MOV R7, # 8

ShiftLeft:

RLC A

MOV mosi, C

NOP

NOP

Osev SCK

;

PUSH A

MOV A, B

MOV C, miso

RLC A

MOV B, A

A POP

CLR SCK

;

DJNZ R7, ShiftLeft

MOV A, B

RET**************************************************"***************************************"

"Funtion napiš 4 Byte pre AT89s51"

"Vstup: R0: začať riešiť pamäte pomocou ukladanie dát"

"***************************************"

WRITE_4_BYTE:

MOV R1, # 4

WriteLoop:

CLR A

MOVC A, @ A DPTR

INC DPTR

LCALL WriteByte

DJNZ R1, WriteLoop

RET"***************************************"

"Povoliť Funtion Programovanie

"Výstup: ACC = 01101001B

"***************************************"

EnableCode:

NR 0ACH, 53H, 0,0

PROGRAMING_ENABLE:

Osev RST

MOV DPTR, # EnableCode

LCALL WRITE_4_BYTE

CLR RST

RET
 
Ďakujeme, že ste mi pomohli.
im snaží sa svojím kódom ..ale
doesnt práce.
i volania funkcie Enable_program ale výstup = 0 (nie je 01101001)
Hlavné:
MOV P2, # 0
MOV Scone, # 52H
MOV TMOD, # 21h
MOV TH1, # -3
MOV TL1, TH1
Osev TR1
MOV A, # 66
LCALL SEND_PC
LCALL SPI_INIT
LCALL WRITEBYTE
MOV R0, # 0FFH
LCALL OMEŠKANIA
LCALL READBYTE
MOV A, # 67
LCALL SEND_PC
CLR P1.0

SJMP $

*****************************************
RITEBYTE:
PUSH ACC
MOV A, # 40H; WRITE SPI BYTE 1
LCALL WRITE_BYTE
MOV A, # 00h; WRITE SPI BYTE 2
LCALL WRITE_BYTE
MOV A, # 11H; WRITE SPI BYTE 3
LCALL WRITE_BYTE
MOV A, # 65H; WRITE SPI BYTE 4
LCALL WRITE_BYTE
POP ACC
MOV R0, # 0FFH
LCALL OMEŠKANIA
RET
**********************************************
READBYTE:
MOV A, # 20H; WRITE SPI BYTE 1
LCALL WRITE_BYTE
MOV A, # 00h; WRITE SPI BYTE 2
LCALL WRITE_BYTE
MOV A, # 11H; WRITE SPI BYTE 3
LCALL WRITE_BYTE
MOV A, # 00h; WRITE SPI BYTE 4
LCALL WRITE_BYTE
LCALL READ_BYTE
LCALL SEND_PC
RET
************************************************
SPI_INIT:
CLR P1.1
CLR P1.0
MOV R0, # 0FFH
LCALL OMEŠKANIA
Osev P1.0
MOV R0, # 0FFH
LCALL OMEŠKANIA
PUSH ACC
MOV A, # 0ACH; WRITE SPI BYTE 1
LCALL WRITE_BYTE
MOV A, # 053H; WRITE SPI BYTE 2
LCALL WRITE_BYTE
MOV A, # 00h; WRITE SPI BYTE 3
LCALL WRITE_BYTE
MOV A, # 00h; WRITE SPI BYTE 4
LCALL WRITE_BYTE
POP ACC
MOV R0, # 10H
LCALL OMEŠKANIA
RET
*******************************************
SPI_ERASE:
PUSH ACC
MOV A, # 0ACH; WRITE SPI BYTE 1
LCALL WRITE_BYTE
MOV A, # 80h; WRITE SPI BYTE 2
LCALL WRITE_BYTE
MOV A, # 00h; WRITE SPI BYTE 3
LCALL WRITE_BYTE
MOV A, # 00h; WRITE SPI BYTE 4
LCALL WRITE_BYTE
POP ACC
LLL:
MOV R7, # 20
MOV R0, # 0FFH
LCALL OMEŠKANIA
DJNZ R7, LLL
RET
***********************************
READ_BYTE:
MOV A, # 0
WRITE_BYTE:
MOV R0, # 8
RW0:
RLC A
MOV P1.3, C
NOP
NOP
Osev P1.1
PUSH ACC
MOV A, B
RLC A
MOV C, P1.2
MOV B, A
POP ACC
CLR P1.1
NOP
NOP
RW3:
DJNZ R0, RW0
MOV A, B
RET
******************************************
Oneskorenie:
MOV R0, # 0FFH
DJNZ R0, $
DJNZ R7,
meškanieRETPridané po 2 minútach:im testovanie functon písať a čítať funkcie ..jeho nefunguje taky.
Ďakujeme, že ste mi pomohli.

 
Test prvá, po tomto teste ostatné funkcie
Kód:

RST bit P1.0

SCK bit P1.1

Miso bit P1.2

Mosi bit P1.3Hlavné:

MOV P2, # 0

MOV Scone, # 52H

MOV TMOD, # 20h

MOV TH1, # -3

Osev TR1

MOV A, # 'B'

ACALL SEND_PC

ACALL SPI_INIT

ACALL Out2Hex; echo viesť k PC

MOV A, # 'C'

ACALL SEND_PC

CLR RSTSJMP $; Tlač ako 2 Hex char

Out2Hex:

PUSH A

SWAP A

ACALL OutHex

A POP

; Tlač ako 1 Hex char

OutHex:

ANL A, # 00Fh

ADD A, # 030h

CJNE A, # 03Ah, test

Test:

JC SEND_PC

ADD A, # 7, 'A' ..
'F'

SEND_PC:

MOV SBUF, A

JNB TI, $

CLR TI

RET*****************************************SPI_INIT:

CLR SCK

Osev RST

MOV A, # 0ACH; WRITE SPI BYTE 1

ACALL WRITE_BYTE

MOV A, # 053H; WRITE SPI BYTE 2

ACALL WRITE_BYTE

MOV A, # 00h; WRITE SPI BYTE 3

ACALL WRITE_BYTE

MOV A, # 00h; WRITE SPI BYTE 4

WRITE_BYTE:

MOV R0, # 8

RW0:

RLC A

MOV mosi, C

NOP

NOP

Osev SCK

PUSH ACC

MOV A, B

MOV C, miso, nemení poradie

RLC A; tejto linky 2

MOV B, A

POP ACC

CLR SCK

DJNZ R0, RW0

MOV A, B

RET
 
uistite sa, že váš prerušenie ukončené.
ak máte nastavený časovač a váš kód začína od adresy 0x0000, čo je vektor prerušenia adresa

 
Děkuji Budhu.
I writed SPI_INIT ako píšete.I práce veľmi dobré.
potom, čo som kódovanie WriteByte a ReadByte ako:
KHOA:
MOV P2, # 0
MOV Scone, # 52H
MOV TMOD, # 21h
MOV TH1, # -3
MOV TL1, TH1
Osev TR1
MOV ADDH, # 0
MOV ADDL, # 0

MOV A, # 'A'
ACALL SEND_PC
ACALL SPI_INIT
ACALL OUT2HEX; echo viesť k PC
ACALL SPI_ERASE

MOV R1, # 'Z'
ACALL WRITEBYTE; to nefunguje
ACALL READBYTE; to nefunguje výstup FF
ACALL SEND_PC
MOV A, # 'R'
ACALL SEND_PC
CLR P1.0
SJMP $

WRITEBYTE:
MOV A, # 40H; WRITE SPI BYTE 1
ACALL WRITE_BYTE
MOV A, ADDH; WRITE SPI BYTE 2
ACALL WRITE_BYTE
MOV A, ADDL; WRITE SPI BYTE 3
ACALL WRITE_BYTE
MOV A, @ R1; WRITE SPI BYTE 4
ACALL WRITE_BYTE

MOV R7, # 0FFH
ACALL OMEŠKANIA
RET

READBYTE:
MOV A, # 20H; WRITE SPI BYTE 1
ACALL WRITE_BYTE
MOV A, ADDL; WRITE SPI BYTE 2
ACALL WRITE_BYTE
MOV A, ADDL; WRITE SPI BYTE 3
ACALL WRITE_BYTE
ACALL READ_BYTE
MOV @ R1, A
RET

to nebude fungovať.Nemôžem opraviť chybu.prosím vás pomôžte mi ..Mockrát děkuji
JoePridané po 1 minúta:Váš email: joedarton (at) gmail.com

 
Ospravedlňujeme sa, prosím, zašlite svoj kompletný kód ako prílohu.

 
môj kódPridané po 4 minútach:i dont priložiť súbor.prosím dajte mi váš e-mail ..!

 

Welcome to EDABoard.com

Sponsor

Back
Top