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.

Design Issue - How to make sure SIM800 response received over UART Rx ISR is complete

Status
Not open for further replies.

FrustratedEngineer

Newbie level 6
Joined
Nov 30, 2015
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
122
Guys,

This seems ubiquitous topic. I have read few of the topics on similar lines but didn't get satisfactory answer.

The question goes like this...

The PIC mcu is interfaced with SIM800 module.
The data Tx and Rx is done over ISR.

For Tx ISR, the size/length of buffer can be used to make sure when to finish transmission.

But for Rx ISR how to make sure frame is received and there is no byte remaining?
I can see following solutions...

1. Start a timer of 10-50msec after first RX ISR. After every subsequent RX ISR, clear the Timer. When the timer expires, mark it as complete reception of the frame and stop the timer.
2. Look for "\r\n" pattern in the SIM800 response. It should be the termination string.
3. Whatever AT-command is transmitted from PIC, wait for the "Expected Response" (as per SIM800 datasheet). Once the expected response is received, mark as complete frame received.

However, all the above solutions have some sort of problem and is not perfect in it's entirety.

Just want to know, your opinion on this. Which of the above solution is good? Is there any other solution available?
 

First 1 & 2 should be used. Each time RX interrupt occurs, you reset timer. In case of '\n' received you stop the timer. If timer expires that means that transmission is interrupted. Size of buffer depends of current application. You should know the maximum transmission size.
 

Hi,

I agree: in ISR set a flag when /n is received. This tells the main loop that the response is complete.
You may reset the timer within the ISR, but you may also build the timeout in the main loop, this may be more flexible.
It depends on your application and what else and how you process data in the main loop.

Klaus
 
This is applicable for single string receving. This devices normally sends more than one string in a row. So the better solution is to switch the pointer in array of pointers. The main loop goes over them and compare then with zero. If it is not a zero, it proccessing in.
 
First 1 & 2 should be used. Each time RX interrupt occurs, you reset timer. In case of '\n' received you stop the timer. If timer expires that means that transmission is interrupted. Size of buffer depends of current application. You should know the maximum transmission size.

I have thought of using \n as termination char. But, the SIM800 response has multiple \r\n in one response. That makes it difficult to find out where the frame has ended. :thumbsdown:
 

I have thought of using \n as termination char. But, the SIM800 response has multiple \r\n in one response. That makes it difficult to find out where the frame has ended.
Yes. The answer is you need to decode the AT modem response strings, being aware of errors messages and unsolicited messages, if required by your application.

Each time a \r\n is received, the respective response should be extracted from the RX FIFO and decoded. It's preferable to accept the message format as specified and not to rely on a specific string length.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top