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 ?
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
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 ?
http://www.keil.com/download/docs/200.asp
"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.