Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

3Pi + RS232 Bluetooth Sparkfun


#1

Hello everyone, I’m currently working on a program that will send a message trough bluetooth for my 3pi, but I can’t seem to be able to read anything that I send or receive. Here’s the code I’m currently working with:
code.txt (4.3 KB)

I want to use the external clock at 20MHz and the standard baud rate of 115200.
I think my serial com setup is good, but I can’t quite grasp the problem with my UART
communication. what I’m trying to do is send a value between 0-100 to my 3pi and then
my 3pi would confirm it by TXing it back to me. I have the sparkfun modem Rx to TX and TX to RX
and working as previously tested with a serial com port on my Cellphone.

I’m wondering if I set my clock and COM right, because since the code is so simple, I don’t understand
where to look anymore. Can anyone give me some advices?

thanks in advance.


#2

Hello.

Before I start looking at your code, can you provide a link to the Bluetooth module you are using with the 3pi? Also, can you post pictures of your setup clearly showing how you have everything connected? I just want to make sure that there isn’t anything obviously wrong in your physical setup first.

You mention wanting to use an external clock source in your setup. Just to clarify, are you referring to the external clock source on the 3pi?

By the way, you might consider looking at (or using) our serial slave program for the 3pi. You can find more details about the program under the “Serial slave program” section of the 3pi user’s guide. Also, it might be helpful for you to look at the OrangutanSerial portion of the AVR library to see how the class provides access to the 3pi’s serial port. See the “Orangutan Serial Port Communication” section in the Pololu AVR Library Command Reference.

- Amanda


#3

I’m using the SparkFun Bluetooth Modem - BlueSMiRF Silver, https://www.sparkfun.com/products/12577.
and yes i’m referring to the external clock source on the 3pi.
I’ve been wanting to use your library, but due to school limitations I need to use my own programming to complete
this project even I did get the right documentation and have already checked the much detailed library you made.

Please advise. Thank you.


#4

Here’s a print screen of the signal I’m sending, and my program echoing it back after.


#5

Thanks for posting a scope trace showing the problem. It does look like there is an issue with the baud rate. Looking at your code, you define FOSC as 20000000, not 20000000UL, so it might be treated as a 16-bit integer. You could try adding the UL suffix so that the value is treated as an unsigned long int.

By the way, I noticed you also define F_CPU. It seems unnecessary to have two variables specifying the clock speed. Since F_CPU is used by avr-libc and FOSC is not, I suggest removing FOSC and changing MYUBRR to use F_CPU instead.

- Amanda


#6

Hi Amanda,

it seems that it might not be the proper fix to my problem. I did correct my FOSC to
20 000 000UL and removed the F_CPU, but here’s the result:

Maybe a problem with the Fuse settings? I have them set on: Brown out detection disabled, Boot flash 2048 words start address $3800 and EXT full swing crystal Start-up time PWRDWM/RST: 16CK/14CK +4.1ms


#7

Tests with a baud rate of 2MHz, possibly an Oscillator setup problem?


#8

Hi Amanda,

after looking at the fuses I found that the LOW.CKDIV8 was enabled!
it completely differed my clock from the result I was looking for.
I’m finally out of the woods.

Thanks for having a look. Have a good one.


#9

That is great! Glad to hear you figured out the issue and fixed it; thanks for letting us know.

- Amanda