We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello I have connected SIM 900 (GSM Modem) with 89S52 Controller, via RS232 Communication. If I send AT from controller to Modem , it is replying with AT OK but my controller is just able to receive character “A”, (in below given cod if “A” is replace by “T” then it will not work)
I am using method in which , after a time period Interrupt will generate and it will check if data is received from RS232 . Please help me where m I wrong.
Code is given below :
//Interupt code void sEOS_ISR() interrupt INTERRUPT_Timer_2_Overflow { TF2 = 0; // Must manually reset the T2 flag if(i == 1) { check_connection(); //sending "AT" Command to Modem, send this command only 1 time time_stamp = 0; i = 0; //i is global variable ones it become 0 again it will not become 1 } rec_from_wire(); }
void rec_from_wire(void) {
if(RI == 1) { RI = 0; temp = SBUF; }
if(temp == 'A') { port_0_0 = 1; //LED 0 ON port_0_1 = 0; //LED 1 OFF
} else { port_0_0 = 0; //LED 0 OFF port_0_1 = 1; //LED 1 ON }
}
void check_connection(void) { send_on_wire('A'); send_on_wire('T'); send_on_wire(0x0D); send_on_wire(0X0A); }
Please review the posting instructions before posting source code again.
You'll need to be able to receive multiple characters and accumulate them with be able to see the echo, or "OK" and "ERROR" type responses. You'd probably want to manage the incoming data using an interrupt to collect them into a buffer.
Your code is unreadable.
But don't use any timer interrupt to try to send multiple characters with your send_on_wire() function. Unless you have a processor with enabled FIFO, the UART will not be able to receive multiple characters at the same time so the send code (which you didn't post) has to wait for the transmit register to get room for more data.
And not only that - you somewhere also wants code ready to pick up any echo from the modem when it arrives. And then you better not be busy doing a send.
That is a good reason for doing things one character at a time. And it's also a good reason for using an UART interrupt handler that can check if there is any received character and/or if the UART is ready to send one more character.
Thank you very much for paying attention to my query,
as you suggested i changed Receiving data on UART Interrupt (interrupt 4) and now i am able to receive all the characters into buffer.
i will get back here for more doubts in future
thank you sanjyot