• AVR Freaks

AnsweredHot!Serial Communication Example / UART Meaningless Data

Author
sevincom
New Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2020/05/12 16:13:18
  • Location: 0
  • Status: offline
2020/05/18 15:25:05 (permalink)
0

Serial Communication Example / UART Meaningless Data

Hello,
 
I am trying to communicate PIC16F877A with 3rd party device. I am using XC8 compiler and I have downloaded uart.h library from internet since it was not included with MPLAB X IDE v5.35.
For the simplicity of test, first I am testing it by a simulator called hercules.
 
The problem is, I am getting data which is not the same what I am trying to send to hercules from PIC.
For example when I send OK string I receive % sign. I have also tried different type of data like, "0", "52", "NUL". When I write these strings from PIC, I read characters like -, ae .. from PIC. And the weird thing is, this character is not constant. For example when I write string "NUL", hercules reads VE, then UE, then TE etc. So, this makes it more difficult for me to understand.
 
I did some ASCII-HEX conversion stuff with PLCs in the past. But with PIC, I could not find suitable conversion table. I find ascii table on internet, but it does not fit the results which I get. Could you help me to understand:
- What makes the hercules to read different data while PIC has only programmed for one string?
- Which table I can use to convert data between these two devices?
 
#include <pic16f877a.h>
#include "seri_config.h"
#include <stdio.h>
#include <stdlib.h>
#include "lcd_config.h"
#include <string.h>
#include "uart.h"
 
void main(void) {
TRISA=0XFF;
TRISB=0X00;
PORTB=0X00;
TRISD=0b00000011;
 
while(1){
if(PORTDbits.RD0==1){
UART_Write_Text("NUL");
PORTB=0b00000001;
__delay_ms(500);
PORTB=0b00000000;
__delay_ms(500);
}
}
}
#1
katela
Super Member
  • Total Posts : 1809
  • Reward points : 0
  • Joined: 2013/06/11 05:25:18
  • Location: South Africa
  • Status: offline
Re: Serial Communication Example / UART Meaningless Data 2020/05/20 06:59:22 (permalink) ☼ Best Answerby sevincom 2020/05/20 08:36:33

Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
#2
sevincom
New Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2020/05/12 16:13:18
  • Location: 0
  • Status: offline
Re: Serial Communication Example / UART Meaningless Data 2020/05/20 07:49:25 (permalink)
+1 (1)
Yes, sorry, that was posted 2 days ago and did not publish. I thought it is deleted but it was actually on approval.
#3
Jump to:
© 2020 APG vNext Commercial Version 4.5