ATSAMD20-XPRO, UART callback overwrite issue to be resolved.

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dear Community Experts,

Device: ATSAMD20-XPRO

IDE: Atmel Studiov7

Framework: ASF

 

I am trying to implement a UART communication between ATSAMD20-XPRO and GSM module. Here I wish to store the contents of a received SMS (GSM) on ATSAMD20's EEPROM.

 

Separately, the UART communication between ATSAMD20 and GSM works fine, I have used USART Callback method. Also, ATSAMD20 EEPROM read/write works fine.

When combined the above, I faced issues in restoring complete buffer containing responses of the GSM module, like currently I had placed the "usart_read_buffer_job" function in a while loop with a condition till the buffer gets a "K", also copying the buffer data into another buffer2 for further use. Although, SAMD20 UART prints the received response without any data loss, but it fails to retain the data in the buffer and hence even buffer2 has NULL data.

Irrespective of the initialized buffer size, every received character (response from GSM) overwrites at 1st element, probably this is a normal behavior.

I tried implementing using "buffer[i]" and later in the same loop "i++", but it again failed, I don't understand why it fails, at least the immediate copying should have worked.

Kindly, help me out here. Also if implementing Ring-buffer like logic is the only solution for this, then please share how it can be implemented in this USART callback type of code, I have tried implementing ring-buffer logic but have failed in doing it effectively.

Thank you.

DVISH

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Someone might be able to help if you attached your code.

I just note that you generally don't want to print everything you receive and are trying to buffer, makes it harder to keep up with the input.

/Lars

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Sir,

 

Yes right I wish to buffer only the useful out of the received SMS like time-stamp and the actual message. 

Okay, noted, find the attached code and a snap of selected modules in the project.

 

Also I am attaching the serial output for the code. (Serial Terminal used: Docklight)

Attachment(s): 

DVISH

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sir, I have attached the code, can you please check and suggest on any possible solution.

DVISH

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I suggest you base your solution on a generic input handler and not having all loops busy wait with usart_read_buffer_job. Maybe a line buffer like I did here:

https://www.avrfreaks.net/forum/...

/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, thank you Sir.

I will try implementing this and reply accordingly.

DVISH