Page 1 of 1

RS232 serial communication not working

Posted: Thu Feb 15, 2018 7:32 am
by imtiaz9
I want to communicate 18f452 device to PC through RS232 and try to display a byte number on hyperterminal. But only different symbols are display when i pressed any key on 18f452. Any idea to solve it

Re: RS232 serial communication not working

Posted: Thu Feb 15, 2018 11:05 am
by Benj
Hello,

You are simply printing the TOTAL variable as a byte if you look at the ASCII table then you can see that the values 0-255 will generate lots of different characters.

http://www.asciitable.com/

If you instead convert total to a string and then print the string then this will print the number as an ASCII set of digits representing the value of the number.

str = ToString$(TOTAL)

If you only want to print a single digit 0-9 then you can change the SendRS232Char parameter from TOTAL to TOTAL + '0'. This shifts the value up by the ASCII value for 0, again refer to the ASCII table link for info. You will also need to bounds check the TOTAL value so when incrementing and decrementing the value it cannot go lower than 0 or higher than 9.

Hope this helps.

Re: RS232 serial communication not working

Posted: Fri Feb 16, 2018 7:55 am
by imtiaz9
thanks benj. its solved...