Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I continuously send and receive with wireless serial-port in 8051?
    primarykey
    data
    text
    <p>I'm trying to make a microcontroller communicate with a program on my desktop. I'm using serial port connections with Xbee radios on both ends. </p> <p>The communication works fine when I send something from the microcontroller to the desktop and the program on the desktop then sends something back to the microcontroller. </p> <p>However, when I require the information to be sent from the controller to the desktop program continuously until the desktop program sends a particular answer it doesn't work. </p> <p>Here's the code for what I'm talking about:</p> <pre><code> unsigned char ans = 'N'; unsigned int count = 0; void main(void) { while(1) { if(count == 0) { Configure(); count = 1; } //there is some more code here but is irrelevant to the serial communication } } void Configure() { //Repeat this until the user accepts the sent string as correct while(ans == 'N') { BuildString(); Send(); Receive(); } } void Send() { unsigned int i; TMOD = 0x20; TH1 = 0xFD; SCON = 0x50; TR1 = 1; for(i=0; i&lt;4; i++) { SBUF = toSend[i]; while(TI == 0); TI = 0; } } void Receive() { unsigned int j; TMOD = 0x20; TH1 = 0xFD; SCON = 0x50; TR1 = 1; for(j=0; j&lt;2; j++) { while(RI == 0); Received[j] = SBUF; RI = 0; } if(count == 0) ans = Received[1]; else { RunType = Received[0]; Move = Received[1]; } } </code></pre> <p>The BuildString() function simply constructs a string on the basis of some sensor inputs. The send and receive functions work fine usually but when I need them to send and receive continuously, like in the Configure() function above, it doesn't work. </p> <p>Any suggestions? I'd really appreciate them.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload