Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
serial transmission of intergers
#1
I've been trying very hard to write a serial interface to an AVR microcontroller. The AVR code is ok, because it works well with a terminal emulator. But my Qbasic code has a problem. Sometimes, the two bytes of the interger are swapped around, ie the AVR sends say 0x0a and 0x44 but it displays on my program the other way, 0x44 and 0x0a.
I'm using GET #1, , buff%(t%) to receive.
If I fiddle with the size of the 'buff' array, the problem may swap back. I was thinking there may be a character left in a buffer somewhere that puts everything out of sync?
Please help!!!!!!
Reply
#2
Dunno but it prolly has to do with your controller as a Big Endian register.

You could try after GETting....

Say A(1) is your integer value.

Byte1=A and 255
Byte2=A \256
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#3
You need to write code checking for a timeout or an end-of-message character to separe the messages. You can not expect your QB loop will run at the same speed as the microcontroller's loop...

An example of timeout is at
http://faq.qbasicnews.com/?blast=SerialComms
Antoni
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)