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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/03/11 12:42
Modified:
  08/03/11 13:26

Read: times


 
#183173 - only 3 'U's are commingout of 100
Responding to: ???'s previous message
i made the code as modular as i could...
i have given 100 in R0 in order to send 100 U's but i am only getting a total of 4 characters, 3 U's and a character corresponding to 0ffh
and if i replace U by any other character nothing is coming in the terminal even 0AAh is also not coming

// bit banging to transmit at 1200 baud rate
// crystal freq is 11.0592MHz
DAT equ R2

		
	org 00h
	jmp main
; timer 0 interrupts here
	org 0Bh
T0int:	rrc A
	mov P3^1,C
	inc R1
	reti
; main routine
	org 100h
main:	setb P3^1
	mov IE,#82h		; timer 0 interrupt enable
	mov TH0,#0E8h 	  	; timer 0 mode 2 is enabled here
	mov TL0,#0E8h		; at 1200 baud rate
	mov TMOD,#02h		;

	mov R0,#100		; transmit a character 100 times
	mov DAT,#'U'		
repeat:	call byte_out				
	djnz R0,repeat
		
over:	jmp over

; routine to send out a byte
byte_out:
	setb TR0		; start timer
	mov A,#0x00	 	; send start bit
	mov R1,#00
wait1: 	cjne R1,#01,wait1	; wait till 1 bit is sent

	mov R1,#0			
	mov A,DAT		; send the character
wait2: 	cjne R1,#8,wait2	; wait till 8 bits is sent

	mov A,#0x01		; send stop bit
	mov R1,#00
wait3: 	cjne R1,#01,wait3	; wait till 1 bit is sent
	clr TR0
	ret
end
 



List of 30 messages in thread
TopicAuthorDate
bit banging program touble            01/01/70 00:00      
   why?            01/01/70 00:00      
      i need a second serial port            01/01/70 00:00      
         something like this , without any warranty :            01/01/70 00:00      
         a good start would be ...            01/01/70 00:00      
            only 3 'U's are commingout of 100            01/01/70 00:00      
               Separate the characters and look with scope            01/01/70 00:00      
                  finally it worked            01/01/70 00:00      
                     uart receiver in software            01/01/70 00:00      
   No I/O or No Timing            01/01/70 00:00      
      "No I/O or No Timing"            01/01/70 00:00      
   Someday you will learn...            01/01/70 00:00      
      this isnt the actual code            01/01/70 00:00      
         Well then another lesson to learn...            01/01/70 00:00      
   Assembler Manual will help you            01/01/70 00:00      
      assembler manual?            01/01/70 00:00      
   Data is 8 Bit??            01/01/70 00:00      
   Bit width timing and timer TH0,TL0 Values            01/01/70 00:00      
      checked values for TH0 and TL0            01/01/70 00:00      
         keil baud rate Calculator not for bit bang            01/01/70 00:00      
   LSB first            01/01/70 00:00      
   now reception....            01/01/70 00:00      
      1) din = din >> 1            01/01/70 00:00      
         working at 1200 baud            01/01/70 00:00      
            delayRS()            01/01/70 00:00      
               why do i have to sample stop bit            01/01/70 00:00      
                  Need not, but should            01/01/70 00:00      
                  because            01/01/70 00:00      
                     Much to a real UART            01/01/70 00:00      
                  1.5 bit delay            01/01/70 00:00      

Back to Subject List