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

Back to Subject List

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


 
#163177 - My code
Responding to: ???'s previous message
#include"reg5131.h"

org 0000h
LJMP START

START:

/*Configure UART communication*/

mov CKCON0, #01h /* select 6 clock cycle, X2 = 1 */
mov PCON, #80h /* set 1000 0000 to PCON, double baud rate, SMOD1= 1, SMOD1 is to select double baud rate */
mov BDRCON, #0Eh /* baud rate control register, SPD=1, RBCK=1, TBCK=1 */
mov SCON, #50h /* Serial control register, UART mode 1, REN = 1*/

/* Baudrate UART 24MHz */
/* 9600 = 100 (0x64) */
/* 19200 = 178 (0xB2) */
/* 38400 = 217 (0xD9) */
/* 57600 = 230 (0xE6) */
/* 115200 = 243 (0xF3) */

mov BRL, #64h /* Baud rate reload register for the internal baud rate generator, baud rate = 9600 */
mov BDRCON, #1Eh /* Start internal baud rate generator */


wait: jnb RI, wait
clr RI

mov ACC, SBUF
mov R1, ACC

mov ACC, p2 /* read out the latch of port 2 to accumulator */
ANL ACC, #00h /* pull the port 2 pins low, as output */
mov p2, ACC
mov P2, R1

END /* end program */

List of 11 messages in thread
TopicAuthorDate
how to debug this serial communication            01/01/70 00:00      
   post your '51-side code            01/01/70 00:00      
   My code            01/01/70 00:00      
      your program runs away            01/01/70 00:00      
   Hardware            01/01/70 00:00      
      I will check            01/01/70 00:00      
         Still wrong            01/01/70 00:00      
            Back to hardware            01/01/70 00:00      
               MAX232            01/01/70 00:00      
                  but            01/01/70 00:00      
   I found out where the problem is            01/01/70 00:00      

Back to Subject List