This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Serial Communication

I need to communicate between an RS232 and the UART of an 80C2051 microcontroller in order to program another 8051 chip. I have configured the correct settings for the UART set up, all I would really like to do is send a character from RS232 and view it in hyperterminal, writing the software in C language as opposed to Assembly. does any one know the correct way to do this? I have looked at many code examples and they dont really give much as to how this is done for example sending the character '$' and how it is recieved on UART, and how you can check this is correct using Hyperterminal.

Parents
  • Hi Erik

    the following assembly code kicks out errors in keil:

    MOV SCON,#50h
    MOV TMOD,#20h
    MOV TH1,#253
    SETB TR1
    
    JNB RI,$
    MOV A,SBUF
    CLR RI
    CLR TI
    MOV SBUF,A
    JNB TI,$
    SJMP
    

    Please bear in mind I have used #include<REG51.h> and #include<stdio.h> and saved the file as an A51 file. When built the error message is 'C:\Keil\C51\INC\ATMEL REG51.H: error A10: ATTEMPT TO DEFINE AN ALREADY DEFINED SYMBOL, and it appears to do this for all the UART configurations as shown above. Any suggestions?

Reply
  • Hi Erik

    the following assembly code kicks out errors in keil:

    MOV SCON,#50h
    MOV TMOD,#20h
    MOV TH1,#253
    SETB TR1
    
    JNB RI,$
    MOV A,SBUF
    CLR RI
    CLR TI
    MOV SBUF,A
    JNB TI,$
    SJMP
    

    Please bear in mind I have used #include<REG51.h> and #include<stdio.h> and saved the file as an A51 file. When built the error message is 'C:\Keil\C51\INC\ATMEL REG51.H: error A10: ATTEMPT TO DEFINE AN ALREADY DEFINED SYMBOL, and it appears to do this for all the UART configurations as shown above. Any suggestions?

Children
  • based on the little you give, I can only guess

    1) Look in the .lst file, you may see that inadvertently you define something twice.

    2) You should never include stdio in an assembler file GET RID OF IT

    Erik

    If this does not solve the problem, then post the whole .lst file, I know it will fill up some spece here, but so be it.

    Erik

  • "the following assembly code kicks out errors in keil"

    No, it doesn't!

    Read the message carefully, and think about what it is telling you:

    'C:\Keil\C51\INC\ATMEL REG51.H: error A10: ATTEMPT TO DEFINE AN ALREADY DEFINED SYMBOL
    


    The message refers specifically to the REG51.H file - not to the code that you posted!

    Remember that REG51.H is a 'C' header file: it defines the 8051 SFRs, because 'C' knows nothing of SFRs - but the Assembler has these definitions built-in. Thus using the 'C' header tries to re-define things that are already built-in to the assembler; ie, it attempts to define already-defined symbols - just as the message says!

    See: http://www.keil.com/support/man/docs/a51/a51_xb.htm

    And, as Erik says, stdio.h has no place in an assembler file!