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.

Reading Usart Data Help

Status
Not open for further replies.

Rocketman46

Member level 3
Joined
Jan 9, 2014
Messages
57
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,859
Hi All,

I need some guru C help. I am trying to read in data from a modem into my mcu. Is it better to read this string data into a fixed length array or a ring buffer. I have tried the ring approach but am currently struggling lots.

Cheers,

Rocketman46
 

What modem is it ? What is the size of data or data burst? Is it GSM modem ? Is data continuous like GPS ?

What is the size of ring buffer ?

What kind of problem you have in implementing ring buffer ?
 

Hi,

* Modem is a Telit GSM
* Ring Buff size 250
Code:
/************ This part works great ******/

// initial hello from modem to mcu after text "Text" sent
+CMT: "+441234567890","","16/05/20,12:10:39+04"
Test
52 // number of values in ring buffer

// usart received data printed back out to terminal
+CMT: "+441234567890","","16/05/20,12:10:39+04"



/************ This part does not work, I cannot grad "Test"  ******/

// Command sent to Telit modem to return message "Test"
AT+CMGR=1

// Message sent back from modem
+CMGR: "REC UNREAD","+441234567890","","16/05/20,12:10:39+04"
Test


// Message sent back from modem
+CMGR: "REC READ","+441234567890","","16/05/20,12:10:39+04"
Test

I cannot read back the message "Test". Is this better suited to a ring buffer or a standard array?

I am kinda double firing my rx interrupt but I cannot figure out how to over come this.

1) sent text to modem from phone
2) modem receives hello message not text, an interrupt is fired on mcu and initial hello is printed out, and command is sent to modem of this function to receive new text
3) read new text message and print out
4) can you see I am kind of stuck half in 2 and 3 and overloading the buffer.

I cannot see how to overcome this.
 

Hi Rocketman46,

Don't use the ring buffer better to use two standard buffer they are one is Rx buffer & another one is process buffer. When ever receive the data, MCU invoke Rx interrupt. In the interrupt handler copy the data in to the receive buffer.

After getting the data in to the Rx buffer, copy that data in to process buffer & then reset the Rx buffer to again to initial location.

what ever you want to perform some operations on the data, you can perform with process buffer.

Let me know you have any more info..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top