Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/13/02 19:11
Read: times


 
#24443 - RE: Mode 2/3: Multiprocessor Serial (again)
Here is an example for Odd or Even Parity

;
;
;THIS PROGRAM IS FOR BetaLogger 128
;PROTOCOL CONVERSION
;
;Serial data 2400 Baud 8 bit parity odd
;
;PROCESSOR = Intel 87c51
;
;FILE NAME= BetaConverter.asm Creation Date= 2/5/02
;
;AUTHOR: J. Kimbriel
;
;MODIFICATION RECORD:
;
;
;
;
; EQUATE REGISTER BITS TO A LABEL
;
;#include <REG51.H>
;
?STACK SEGMENT IDATA
rseg ?STACK
DS 5
;
;
;=================================
; RAM ALLOCATION
dseg at 30h
;=================================
;
Database: DS 10
;
;=================================
cseg at 0
;=================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; POWER ON STARTUP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
AJMP INIT
;=================================
; cseg at 03H ;externial interupt 0
;=================================
; cseg at 0BH ;timer 0 interupt (TF0)
;=================================
; cseg at 13H ;externial interupt 1
;=================================
; cseg at 1BH ;timer 1 interupt (TF1)
;=================================
; cseg at 23H ;Serial interupt (RI or TI)
;=================================
cseg at 100H
;=================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; INITIALIZE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INIT: MOV IE,#000H ; DISABLE ALL RUPS
MOV SP,#060H ; SET STACK POINTER TO 60H
MOV PSW,#000H ; SET STATUS WORD To 00H
MOV PCON,#000H ; SET POWER CONTROL REG AND SMOD = 0
; MOV SCON,#050H ; SET SERIAL PORT MODE 1 ENABLE 8 bits no parity
mov scon,#030h ; Set serial mode 3 (9 bits 9th bit parity)
; TB8 is parity bit to be xmitted
; RB8 is the received parity bit
MOV TMOD,#020H ; SET TMOD MODE 2 8 BIT AUTO RELOAD
;
; MOV TH1,#0e8H ; SET TIMMER 1 VALUE 1200 BAUD and smod=0
MOV TH1,#0f4H ; SET TIMMER 1 VALUE 2400 BAUD and smod=0
; MOV TH1,#0faH ; SET TIMMER 1 VALUE 4800 BAUD and smod=0
; MOV TH1,#0fdH ; SET TIMMER 1 VALUE 9600 BAUD and smod=0
; MOV TH1,#0fdH ; SET TIMMER 1 VALUE 19200 BAUD and smod=1
;
MOV TL1,#000H ; SET TIMMER 1 VALUE LOW BYTE
MOV TCON,#040H ; SET TIMMER 1
MOV IP,#000H ; SET NO PRIORITY
; MOV P0,#0FFH ; SET PORT 0 TO FLOAT
MOV P1,#0FFH ; SET PORT 1 FOR INPUT
; MOV P2,#0FFH ; SET PORT 2 FOR INPUT
; MOV P3,#0FFH ; SET PORT 3 FOR INPUT
CLR A ; CLEAR DATA STORAGE
MOV R1,#020h ; 1ST LOC. TO CLEAR
MOV R3,#05FH ; # TO CLEAR
CLR0: MOV @R1,A
INC R1
DJNZ R3,CLR0
; CLR RS0 ;SET REGISTER BANK 0
; CLR RS1 ;
USING 0
; SETB ES ;ENABLE SERIAL PORT INTER
; SETB EA
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;Start of main program
;Loop here and wait for message.
;
Idle: clr ri
jnb ri,$ ;wait for char
clr p1.0 ;lite the led
mov a,sbuf ;get char from buffer
anl a,#7fH
cjne a,#48h,Cont ;Is it a H?
mov a,#55h ;Yes make it a U
Cont: call GenOddPar ;set parity bit
clr TI
mov sbuf,a
jnb TI,$ ;transmit it
setb p1.0 ;clear the led
jmp Idle

;
;Compute odd parity
GenOddPar:
mov c,p ;get parity
jc odd ;a reg = odd
clr c ;set even data to odd
odd: cpl c ;clear carry and leave data odd
mov tb8,c ;set parity bit
ret
;
;Compute even parity
GenEvenPar:
mov c,p ;get parity
jnc even ;a reg = even
clr c ;set odd data to even
cpl c ;clear carry and leave data even
even: mov tb8,c ;set parity bit
ret
;
END




List of 26 messages in thread
TopicAuthorDate
Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: easy            01/01/70 00:00      
RE: not easy?            01/01/70 00:00      
RE: not not easy?            01/01/70 00:00      
RE: not not easy?            01/01/70 00:00      
RE: i'll give it a try            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: not not easy?            01/01/70 00:00      
RE: not not easy?            01/01/70 00:00      
RE: Mode 2/3 - Erik            01/01/70 00:00      
RE: not easy?            01/01/70 00:00      
RE: not easy?            01/01/70 00:00      
RE: not easy?            01/01/70 00:00      
RE: not not easy?            01/01/70 00:00      
ClearCommError() Help says: \            01/01/70 00:00      
RE: Buffer->InputSize            01/01/70 00:00      
RE: ClearCommError() Help says:            01/01/70 00:00      
RE: ClearCommError() Help says:            01/01/70 00:00      

Back to Subject List