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?
UART comunication truncated data
- filip.grujcic
- Posts: 822
- Joined: 14 May 2018 08:34
Re: UART comunication truncated data
Hi,
Can you send the code where you do this, or attach an entire project here please?
Kind regards,
Can you send the code where you do this, or attach an entire project here please?
Kind regards,
Filip Grujcic
Re: UART comunication truncated data
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.
Re: UART comunication truncated data
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.
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.
- filip.grujcic
- Posts: 822
- Joined: 14 May 2018 08:34
Re: UART comunication truncated data
Hi,
Can you tell me what are the UART specifications of the module you are communicating with using AT commands?
Kind regards,
Can you tell me what are the UART specifications of the module you are communicating with using AT commands?
Kind regards,
Filip Grujcic
Re: UART comunication truncated data
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
It's cofigured to 8-bit data, 1 stop bit, no parity bit, and no flow control
Re: UART comunication truncated data
Hi,
I have not progressed yet. Any help?
I have not progressed yet. Any help?
- filip.grujcic
- Posts: 822
- Joined: 14 May 2018 08:34
Re: UART comunication truncated data
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,
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