I am doing a project and in that project i am using one MAX232 but with multiple Microcontrollers i know that i cannot use RS-232 to multiple Microcontrollers but i am using MAX232 to convert the RS-232's 23V to TTL (5V) and so as the RS232 is converted to TTL so i think that it will work for multiple Microcontrollers (am i right?) well this is my stratigy ...
but my main task is that i want to send a HexaDecimal no through the Serial port so that the approriate Microcontroller will responce .... so i have coded some code but as i cant see the value came into SBUF in keil so could any one help me ?
Well Thankyou sir for your sharing of knowledge and i would like to thank you all of members who shared their knowledge well i have got little bit idea of how i can use Address bit and how to configure them but if i feel any difficulty then i would probabally create a new thread .... ;-)
"It would be a Really Bad Idea to call printf from inside your ISR...!
:-0 "
I agree with Andy. printf() is horribly large and slow on any microcontroller, especially in a 8051. You should never do lengthy operations inside a interrupt handler, to preserve system interrupt latency (the system response time for a interrupt).
Instead, you can prepare a buffer (e.g. unsigned char buf[]) with the ascii characters you want to send, and then directly feed the USART tx register with the characters, one at a time. The USART interrupt will be triggered on completion of each character transmission, and you can then get the next char from your buffer and send it to the USART, returning from the ISR. This takes just a few microseconds per char, and your main software can run while the USART is sending the char by the slow serial line.
Your problem needs to be addressed in several different levels. At each level, an agreed-upon common scheme must be used by the devices to achieve communication : a protocol.
At the lowest level (the physical), you have to provide an electrical interface and topology that can be used to connect all your uC together - a BUS. At this level, you need to be concerned with the electrical signaling, noise, speed, direction signaling (such as a master/slave selection), and ability to send/receive data at the same time or not. You must also think about whether or not the bus will possibly have multiple talkers at the same time, which is a collision.
The RS232 standard interface, as noted above, is a poor choice for a multiple node bus in a multidrop topology, unless there is only one master and only unidirectional data is sent from the master to all slaves (no slave is allowed to talk on the bus). That is because you can't just tie multiple TX lines together, unless you tristate them, or use open collector drivers (but neither of it is RS232 anymore, and you can't use a MAX232 line driver for that). If you have 2 USARTs in every node, you can use a ring or daisy-chain topology with standard RS232 to achieve a bus with token-pass of packets (expensive in hardware and software).
A RS-485 bus, as mentioned above, is perfect for multidrop, low-cost, long-distance, and very simple master/slave software protocol. If you can have a single master on the bus, you can stay away of bus collision issues, as bus collision on RS-485 is very tricky to detect. This is what industrial protocols like MODBUS do, and is really simple to implement in software.
Other links can be used if you need multiple masters and collision detection, like the I2C bus. Several 8051s have I2C master hardware support, making it very simple to implement.
The 9-bit mode of the USART can be used to detect slave address by hardware, but it is not essential. You can just as well use standard 8-bit data and make the address recognition in the software protocol - that is what MODBUS does, for example.
"What you should be looking at is RS485"
Maybe; Maybe not.
If the devices are not far apart, using low speeds, and noise is not a big concern, then RS485 may be overkill. A simple open-collector bus (as I2C uses) may be perfectly adequate.
But, whatever you do, you still need some scheme to address the slaves - and the 9-bit multiprocessor mode must be the obvious choice with an 8051?!
What your should be looking at is RS485 protocol. One master and many slaves. Max232 will not work. Look at www.maxim-ic.com/.../
"can i have your ID though i can communicate with you on PM.?"
No - keep it in the forum.
That way, others can also help, and others can also benefit from the discussion.
Well you are right i should learn to use the Existing tires .... thanks man... but there is one problem that can i have your ID though i can communicate with you on PM.?
"i am developing my own lame ideas for multiprocessing ... and my ideas are not so good"
So not only are you re-inventing the wheel, but your wheel is inferior to the wheels that already exist!
Would it not be better to simply study the good, proven wheels that are already available?!
http://www.keil.com/download/docs/200.asp
YOu have written that it would be really bad idea to call printf function from ISR so could you please tell me how to send multiple charecters or integers from SBUF ?
Lame because i am developing my own lame ideas for multiprocessing ... (its like i want to design a BMW from my own OLD Model TOYOTA) and my ideas are not so good that's why the word lame is used
Just out of curiosity, why do you call this "Lame" Multiprocessing?
int i=1;//global variable which is to be compared void xyz (void) interrupt 4 { if (R1) { if (SBUF==i) { /*My code probabally the Printf statememt*/ } } }
It would be a Really Bad Idea to call printf from inside your ISR...!
:-0
Actually, the Simulator has separate VTREGs for the transmit and receive halves of SBUF - so you can see them both in the simulator!
Look-up "VTREG" in the uVision Manual...
See ">http://www.keil.com/forum/docs/thread2882.asp
"whenever all the Microcontroller will get the byte sended from the Computer then only the Microcontroller whose id will be same as the byte recived then that Microcontroller will response"
Yes, that's exactly what the Multiprocessor mode does for you! If, as mentioned in the above links, you use a derivative with the Enhanced UART, then the address recognition can all be done automatically for you by the hardware with no software overhead!
"i am unawair of that 8051's 9-bit mode..."
Read the above-mentioned links!
It is also in the so-called "bible" for the 8051:
Chapter 1 - 80C51 Family Architecture: www.nxp.com/.../80C51_FAM_ARCH_1.pdf
Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set: www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Chapter 3 - 80C51 Family Hardware Description: www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf
" i think that i need the good link for 9-bit C code BADLY."
No, you need to understand first - then you can start thinking about code!
View all questions in Keil forum