UART comunication truncated data

General discussion on mikroBasic PRO for AVR.
Post Reply
Author
Message
legianrd
Posts: 8
Joined: 14 Aug 2018 13:40

UART comunication truncated data

#1 Post by legianrd » 24 Sep 2018 20:00

Hi,

I'm trying to communicate with a module via AT commands using Uart library. Sending data is ok, but when I'm receiving data from this I'm getting some truncaded data among the expected data. For example, when I'm supposed to receive "ERROR", I'm getting 9 or 10 chars, but only 3 ou 4 are part of the original string

I've tried to communicate with this module using a USB-serial (CP2102) module and I don't have the same problem

Am I missing something?

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: UART comunication truncated data

#2 Post by filip.grujcic » 25 Sep 2018 14:15

Hi,

Can you send the code where you do this, or attach an entire project here please?

Kind regards,
Filip Grujcic

legianrd
Posts: 8
Joined: 14 Aug 2018 13:40

Re: UART comunication truncated data

#3 Post by legianrd » 25 Sep 2018 15:57

Hi

Code: Select all

program UART_TEST

' LCD module connections
  dim LCD_RS as sbit  at PORTC6_bit
  dim LCD_EN as sbit  at PORTC5_bit
  dim LCD_D4 as sbit  at PORTC4_bit
  dim LCD_D5 as sbit  at PORTD2_bit
  dim LCD_D6 as sbit  at PORTD3_bit
  dim LCD_D7 as sbit  at PORTD4_bit

  dim LCD_RS_Direction as sbit at DDC6_bit
  dim LCD_EN_Direction as sbit at DDC5_bit
  dim LCD_D4_Direction as sbit at DDC4_bit
  dim LCD_D5_Direction as sbit at DDD2_bit
  dim LCD_D6_Direction as sbit at DDD3_bit
  dim LCD_D7_Direction as sbit at DDD4_bit
  ' End LCD module connections

 dim txt1 as string[20]
 dim txt2 as char[3]
 dim datain as char[20]

 dim j as byte

main:

Lcd_Init()                        ' INICIALIZA LCD
   Lcd_Cmd(_LCD_CLEAR)               ' Clear display
   Lcd_Cmd(_LCD_CURSOR_OFF)          ' Cursor off
   txt1 = "UART TEXT"
   LCD_Out(1,1,txt1)
  datain = ""
  UART1_init(9600)
  'sending AT COMMAND
  UART1_Write_text("ATw")
  UART1_Write(0x0D)  'carriage return
  UART1_Write(0x0A)  'new line
  while(UART1_Data_Ready() <>1)
  'waiting until it's ready to read
  wend
  j=0
    while(UART1_Data_Ready() =1)
    datain[j] = UART1_Read()
    j=j+1
    Delay_ms(2)
  wend
  byteToStr(j, txt2) 'printing number of chars received
  Lcd_out(3,1,txt2)

  while (j>0)     'printing chars received
  LCD_Chr(2,j, datain[j])
  j=j-1
  wend


while TRUE        'loop infinito

wend

end.

legianrd
Posts: 8
Joined: 14 Aug 2018 13:40

Re: UART comunication truncated data

#4 Post by legianrd » 26 Sep 2018 12:03

Hi,

I've just identified that the strange chars are <CR> (0X0D) and <LF> (0x0A), but I'm still not receiving the entire status data I needed.

In this example code I should receive "ERROR", but I'm receiving:
"<CR>,<LF>,<LF>,<CR>,<LF>,0x45, 0x52, 0x52,<LF>, <LF>"
or sometimes:
"<CR>,<LF>,<LF>,<CR>,<LF>,0x45, 0x52, 0x4F,<LF>, <LF>"

There are missed chars.

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: UART comunication truncated data

#5 Post by filip.grujcic » 26 Sep 2018 13:16

Hi,

Can you tell me what are the UART specifications of the module you are communicating with using AT commands?

Kind regards,
Filip Grujcic

legianrd
Posts: 8
Joined: 14 Aug 2018 13:40

Re: UART comunication truncated data

#6 Post by legianrd » 26 Sep 2018 14:20

Sure! It's a ESP8266 module ESP-01 version. I'm using 9600 baud rate. I've tried another rate, but without sucess too.

It's cofigured to 8-bit data, 1 stop bit, no parity bit, and no flow control

legianrd
Posts: 8
Joined: 14 Aug 2018 13:40

Re: UART comunication truncated data

#7 Post by legianrd » 01 Oct 2018 12:43

Hi,

I have not progressed yet. Any help?

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: UART comunication truncated data

#8 Post by filip.grujcic » 02 Oct 2018 15:35

Hi,

Could you please post a picture of the connections of MCU and the module and zip and attach your project here for inspection?

Kind regards,
Filip Grujcic

Post Reply

Return to “mikroBasic PRO for AVR General”