OT: zaujimava schema - problem...

Jirka zaloha@volny.cz
Pátek Listopad 26 15:25:21 CET 2004

Daniel Valuch napsal(a):

> kamarat mi akurat napisal:
> "Pocuvaj skusal som to postavit a zakazdym, ked som to zapol mi to 
> vyhodilo istic, netusis v com moze byt chyba ???"
> nejake napady kde moze byt problem?

Myslim, ze 47. ci 39. radek nejsoui zcela v poradku....

$MOD831                                  ;Use 8052 predefined Symbols


                                                   ; BEGINNING OF CODE
ORG 0000H


ORG 0060H                    ; Start code at address above interrupts			

MAIN:                          ; Main program

         MOV     T3CON,#85h
         MOV     T3FD,#08h
         MOV     SCON,#52h

         CPL      LED           ; CPL LED with each transmission
         MOV      DPTR, #TITLE
         CALL     SENDSTRING    ; write title block on screen

         MOV      R0, #00H    ; Start transmissions from 0
         MOV      R1, #08H    ; Start a new line after 8 transmissions

LOOP1:                        ; Every eight transmissions start on a
                               ; new line
         MOV      A, #10       ; Transmit a linefeed
         CALL     SENDCHAR
         MOV      A, #13       ; Transmit a carriage return
         CALL     SENDCHAR

         MOV      R1, #08H

         MOV      A, #20H      ; Transmit a SPACE (=ASCII 20) between
                               ; transmissions on same line
         CALL     SENDCHAR

         MOV      A, R0        ; Transmit R0 = present data
         CALL     SENDVAL
         INC      R0           ; increment data

         CJNE     A, #7FH, CONT ; check if data =7F, if no continue
         JMP      WAIT5S        ; if = 7F wait 5s and repeat

CONT:   DEC      R1            ; decrement R1....
         MOV      A, R1
         CJNE     A, #00H, LOOP2 ; and check if new line is required
                                 ; jump to loop 2 for a space
         JMP      LOOP1          ; jump to loop 1 for a new line

WAIT5S: MOV      A, #50         ; wait 5s
         CALL     DELAY
         JMP      START        ; start transmissions again

                                                          ; SENDSTRING

SENDSTRING:     ; sends ASCII string to UART starting at location
                 ; DPTR and ending with a null (0) value

         PUSH    ACC
         PUSH    B
         CLR     A
         MOV     B,A
IO0010: MOV     A,B
         INC     B
         MOVC    A,@A+DPTR
         JZ      IO0020
         CALL    SENDCHAR
         JMP     IO0010
IO0020: POP     B
         POP     ACC


                                                            ; SENDCHAR

SENDCHAR:       ; sends ASCII value contained in A to UART

         JNB     TI,$            ; wait til present char gone
         CLR     TI              ; must clear TI
         MOV     SBUF,A


                                                             ; SENDVAL

SENDVAL:        ; converts the hex value of A into two ASCII chars,
		; and then spits these two characters up the UART.
                 ; does not change the value of A.

         PUSH    ACC
         SWAP    A
         CALL    HEX2ASCII
         CALL    SENDCHAR        ; send high nibble
         POP     ACC
         PUSH    ACC
         CALL    HEX2ASCII
         CALL    SENDCHAR        ; send low nibble
         POP     ACC


                                                           ; HEX2ASCII

HEX2ASCII:      ; converts A into the hex character representing the
                 ; value of A's least significant nibble

         ANL     A,#00Fh
         CJNE    A,#00Ah,$+3
         JC      IO0030
         ADD     A,#007h
IO0030: ADD     A,#'0'


                                                               ; DELAY
DELAY:					; Delays by 100ms * A
					; 100mSec based on 11.0592MHZ
					; Core Clock
		MOV	R5,A		; Acc holds delay variable
  DLY0:		MOV	R6,#200		; Set up delay loop0
  DLY1:		MOV	R7,#229		; Set up delay loop1
		DJNZ	R7,$		; Dec R2 until R2 is zero
		DJNZ	R6,DLY1         ; Dec R1 & Jump DLY1 until R1 is 0
		DJNZ	R5,DLY0		; Dec R0 & Jump DLY0 until R0 is 0
		RET			; Return from subroutine

TITLE:    DB 10,10,13,'____________________________________',10,13
           DB 'Analog Devices MicroConverter ADuC831',10,13
           DB '         UART Demo Routine',10,13
           DB '  Transmission of Data from 0 to 7F',10,13,0



Další informace o konferenci Hw-list