Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SIM900 MCU serial port receive question

Status
Not open for further replies.

hithesh123

Full Member level 6
Joined
Nov 21, 2009
Messages
324
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
lax
Activity points
3,548
I am trying to interface C8051F120 MCU with SIM900A.

I am polling the UART for reply from SIM900A.

The serial buffer SUBF0 is only 8 bits. How exactly does scanf work. Does it read the SBUF0 content when RI0 is 1 and then just move to the next line?
 

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.
 
Last edited:

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.

Line end is '\n' or 'carriage return'?

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.
 

Funny thing is - I see both AT and OK on the PC.
Does the Modem echo the command it receives?
 

Does the Modem echo the command it receives?
Yes, by default. See description of command ATE. "ate0" is often performed in modem initialization for embedded applications.

I guess, you should start operating the modem through a terminal to become familiar with AT commands.
 
Yes, by default. See description of command ATE. "ate0" is often performed in modem initialization for embedded applications.

I guess, you should start operating the modem through a terminal to become familiar with AT commands.

The command echo never happened when I was using a terminal program on PC (tera term).
 

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.
 

After sending ATE0, it's working. No echos.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top