Serial Comm problem

I am using the standard serial_send_blocking() and serial_receive_blocking() functions for my communication.
Also, by the way, these functions worked correctly on my 3pi robot. Let me explain what I mean by correctly.
My program is involved with other activity while waiting for incoming serial data. On the 3pi the data is captured correctly and placed in the buffer.
On my Baby O though, I miss the data unless I make my external activity watch for incoming data and immediately return when it is seen. I do this with this line
if ((PIND&1)==0) return;
While this “works”, it often means I need to abandon an activity before it is finished.
My questions are… Am I wrong in expecting the Baby O’s UART to work in the background?.. and if this should work, what might I be doing wrong. I am initializing the baud to 9600… no other initialization…

OOPS… after a little digging, it seems the problem is really a problem… just me.
Apparently the 3pi performs its own initializtion of the serial ports, so code that works on it requires a little tweeking before it runs properly on the Baby O.
For the most part, all I had to do was issue a serial_receive() …ONCE at the beginning of my program…and that sets up the background buffer operations. At least my first tests seem to confirm that things are working.
I LOVE THE BABY O… it has more bang for the buck than any other processor. I am using it for many projects, but one that may interest readers here is a FULL RobotBASIC Robot Operating System (RROS) that allows a robot to be controlled from RobotBASIC including full simulation support… the more I use the Baby O the more I like it… again sorry about not seeing my problem on my own… just too many projects going on at the moment.

Hello. I’m glad you were able to figure out your problem. Assuming your 3pi and Baby Orangutan both have the ATmega328P, you should be running the exact same serial library on both and it should work identically on both.

If you are calling serial_receive just to initialize the UART, you might consider calling serial_set_baud_rate instead because I think that would make the code cleaner. I think you probably have to call that function at some point anyway.


David… now you have me curious.
I was calling serial_set_baud_rate(), but that DID NOT WORK… the serial routines would NOT work in the background until I called serial_receive() one time at the beginning of my program… then everything worked exactly as it did on the 3pi… I am happy it is all now working…but now very curious about why it did not work as I originally thought… especially after your comments.