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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/16/09 18:38
Modified:
  03/16/09 19:50

Read: times


 
#163503 - Help with codes for serial communication
Hi guys, I've been reading the 8051 tutorial and I've tried writing a little piece of code to just check out the serial transmission from an 8051.

The code is a simple one, it's supposed to transmit the letter "A" continuously.

I didn't face any problem compiling it, but when I burned it onto the chip and looked at the output using an oscilloscope, it was wrong.

Instead of getting the waveform for the letter A, I got a periodic 28Khz square wave.

Here are the details, I hope you guys wouldn't mind lending me a hand with this:

Microcontroller: Atmel 89S51
Compiler:Fet@89c5x IDE
Crystal Frequency: 22.1184MHz

My codes are as follows:
ORG 0000H

MOV SCON, #01010000B
;serial, mode 1, 8-bit-UART

MOV TMOD, #20h
;timer 1 mode 2 8 bit auto relod for baud rate

MOV TH1, #high(-232)
;moves 232 into upper byte of timer 1 giving us
;a baud rate of 2400bps through the formula
;"TH1 = 256 - ((Crystal / 384) / Baud)"

SETB TR1 ;starts running timer 1

WAIT: CLR TI ;clears the transmit interrupt
MOV SBUF, 41H
JNB TI, $ ;waits for the transmission to be complete
JMP WAIT ;repeats the cycle

end


Thanks!



*Update*
Problem solved, it was a problem with the oscilloscope setting.

List of 15 messages in thread
TopicAuthorDate
Help with codes for serial communication            01/01/70 00:00      
   the mistake we all make, occsionally            01/01/70 00:00      
      RE: Help with codes for serial communication            01/01/70 00:00      
         Two changes - why?            01/01/70 00:00      
            Two changes - why?            01/01/70 00:00      
               Mistake with the baud rate            01/01/70 00:00      
                  Baud rate calculator            01/01/70 00:00      
               It's not a compiler...            01/01/70 00:00      
         Sending an A            01/01/70 00:00      
         the typical case            01/01/70 00:00      
            RE: the typical case            01/01/70 00:00      
   Finally! It's working now            01/01/70 00:00      
      Great!            01/01/70 00:00      
      Link?            01/01/70 00:00      
         RE: Link            01/01/70 00:00      

Back to Subject List