Presume that there will be a receive interrupt procedure in your software, implementing a ring buffer between 8051 UART and decoding of received data. You'll usually won't call scanf() before a line end has been received.
If you are using Keil C, the default _getkey() function which is directly reading from the UART will be overloaded by a function pulling data from the ring buffer.
Presume that there will be a receive interrupt procedure in your software, implementing a ring buffer between 8051 UART and decoding of received data. You'll usually won't call scanf() before a line end has been received.
If you are using Keil C, the default _getkey() function which is directly reading from the UART will be overloaded by a function pulling data from the ring buffer.
I am sending "AT" and expecting "OK" as the reply, using printf and scanf statements.
The MCU is not getting "OK" as reply. I have connected the TX pin of SIM900A to MCU as well as USB to UART converter.
On PC, I can see the reply as "OK".
But MCU is not recognizing it as "OK".
when I debug on Keil C51, it works.
- - - Updated - - -
The scanf in my code just reads the first char of "OK".
I get just "O"
I must admit that I never used scanf() with default (unbuffered) _getkey(), thus I don't exactly know how it behaves. The complete modem response is <CR><LF>OK<CR><LF>. I wonder how your scanf() format string looks like to receive the response?
Getting no more characters sounds like UART overflow.
The OK answer is only the simple case. Things become more challenging when you have to expect responses of different formats to a specific command and unsolicited responses in addition.
A Hayes compatible modem has a user and a factory defined profile. After power on-reset or an ATZ command , the user defined profile is in effect, it may involve changes to the default behaviour, e.g. disabled echo. After recalling the factory defined profile with AT&F, command echo will be on.