Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with RS-232 interfacing

Status
Not open for further replies.

dhruvil_90

Newbie level 3
Joined
Apr 16, 2010
Messages
3
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Mumbai
Activity points
1,306
Hey guys. I have a problem with interfacing my bluetooth module (aubtm-20) with Atmega 640. The BT module works perfectly and responds to the commands sent when connected directly to a PC. I have also debugged the code and it works perfectly. But when I connect the BT module (Rx and Tx pins are connected to MAX232 and then to DB9 connector) to the microcontroller using DB9 connector + MAX232, I get incomplete response.

For example, instead of getting getting the response as "<CR><LF>OK<CR><LF>", I get a response like "<CR><LF>O<LF><CR><LF>". The response I get seems to be a part of the actual response but I get a different response everytime.

Rx of BT module is connected to Tx of microcontroller and Tx of BT module is connected to Rx of microcontroller.

I also have shorted grounds of both the boards and have ensured that the baud rates are proper.

Please let me know what the problem could be.
 

These things are nearly always a problem with the UART settings or timing.

(Sorry if you already know all of this, but I don't know how much experience you have)...

What crystal are you using for the ATMega, and do your settings generate an accurate baud-rate clock for the UART?

Have you tried (with the same settings) connecting the ATMega to the PC, and checking that the ATMega can receive similar data correctly from the PC?
 

These things are nearly always a problem with the UART settings or timing.

(Sorry if you already know all of this, but I don't know how much experience you have)...

What crystal are you using for the ATMega, and do your settings generate an accurate baud-rate clock for the UART?

Have you tried (with the same settings) connecting the ATMega to the PC, and checking that the ATMega can receive similar data correctly from the PC?

I have double-checked the UART settings and they seem fine. I did connect the ATMega to the PC and it works fine and as expected. There seems to be some problem when I connect the two boards together. I'm using a 14.7456 MHz crystal for the ATMega.
 

hi dhruvil
would you please tell me how to give <cr> and <lf> using ATmega to AUBTM-20?

---------- Post added at 02:06 ---------- Previous post was at 02:05 ----------

hi dhruvil
would you please tell me how to give <cr> and <lf> using ATmega to AUBTM-20?
 

would you please tell me how to give <cr> and <lf> using ATmega to AUBTM-20?


Code:
char cr = '\r';  // carriage return;
char lf = '\n'; //  line feed;

or according to ASCII table:
**broken link removed**

Code:
char cr = 0x0D;  // carriage return  ;
char lf = 0x0A; //  line feed;

ps: dhruvil90,
Sorry for the off-topic
 

Hey guys. So the problem was solved. All the UART settings were proper. It was the way I had written the ISR that was the problem. Tweaked it a bit and worked like a charm! Thanks for the help. :)

@mgate: No problem at all :)
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top