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.
"it gives the code in assembler ... I really would prefer this to be written in C"
The assembler explains what you need to do; once you understand that, it should be easy to write it in 'C'
eg, reading & writing SFRs is a doddle:
MOV SCON, #50h MOV TMOD, #20h MOV TH1, #253 SETB TR1
just becomes
SCON = 0x50; TMOD = 0x20; TH1 = 253; TR1 = 1;
doesn't it?!
And the "Hello World" examples are in 'C': http://www.keil.com/support/man/docs/uv3/uv3_ex_hello.htm
And there's interrupt-driven 'C' code in the downloads...
so your saying i should remove the REG51.H file. Im not too experienced with keil as you may have guessed
there are two methods 1) if you are happy with the definitions for the old steam driven original '51 do not include a "SFR definition file" and the 'default' will be there. 2) if you want a specific set of SFR defs do like this
$NOMOD51 ;;// this removes the 'standard defs' $INCLUDE (cyf120.h)
Erik
Thanks a lot guys, you've been a great help :D
Actually, what I was really saying was that the fact that the examples are provided in assembler should not be an obstacle to you creating corresponding code in 'C' - you shouldn't need to build the examples just to be able to read & understand them.
Of course, building them may well be a useful exercise in itself, so:
"you're saying i should remove the REG51.H file"
No: I said that you can't have both the built-in definitions and the header file - you need to choose just one.
As Erik said, whether or not you choose to keep the header file depends largely on whether you think there's anything else in it that's worth having...