2
\$\begingroup\$

I'm trying with blue tooth module HC05 with pic controller here and i would like to check my cross check my baud rate via scope or simulation.

I would like to know the steps or good methods that you guys do while ensuring proper usart communication and baudrate.

One method I trust I could follow is to do with scope :).And Proteus would be the least preferred. I would like to have your point of thinking to have a learning for me.

\$\endgroup\$

2 Answers 2

9
\$\begingroup\$

I use a bog standard analogue oscilloscope I was given years ago. It's all you need if you know what you're doing.

The trick with RS232 is to use its protocol to your advantage. There is one special character which, if you send it repeatedly in a tight loop, reveals the baud rate to you. More strictly, it reveals half the baud rate to you.

U

Character U is hexadecimal 0x55, or in binary, 0b01010101. Add that to the start and stop bits, and you get a bit sequence of 1010101010. Repeatedly send that in a tight loop and you get a nice square wave which you can see on the oscilloscope by connecting it directly to either the TX or RX pin depending on if you are transmitting or receiving the U at that point.

Work out the period of that square wave, take the reciprocal of it, and you have the frequency. Double it, and you have the baud rate. Or, if you have a fancy oscilloscope that can detect frequencies, that can tell you precisely what half your baud rate is - just double the figure it gives you.

\$\endgroup\$
7
  • \$\begingroup\$ Can't we check the oscilloscope at the rxt and tx pin of controller and verify it?I trust it would give the baudrate.And 'u' seems to be the master short cut. \$\endgroup\$
    – Rookie91
    Commented Jul 11, 2014 at 9:43
  • \$\begingroup\$ That's 'U', not 'u' (upper case is important). I'm not sure what you mean by "check the oscilloscope at the rxt and tx pin of controller and verify it". \$\endgroup\$
    – Majenko
    Commented Jul 11, 2014 at 9:45
  • \$\begingroup\$ I meant about dirctly connecting the rx and tx pin of the controller to the scope probe and watching the controller sending 'U' in a tight loop.Is it the correct way.Sorry for my bad english \$\endgroup\$
    – Rookie91
    Commented Jul 11, 2014 at 9:49
  • 1
    \$\begingroup\$ Yes, that is what I mean by the "square wave" - it's the pattern observed on the scope by connecting it to either the TX or the RX pin while sending (or receiving) a U. \$\endgroup\$
    – Majenko
    Commented Jul 11, 2014 at 9:50
  • \$\begingroup\$ I think the tight loop must be 'C' dependent?.I got frequencies b/w 2.8 -3.8 khz in the scope while observing \$\endgroup\$
    – Rookie91
    Commented Jul 11, 2014 at 12:20
2
\$\begingroup\$

To answer the simulation part of the question I'll describe what I did when I got my hands on my very first PIC. (it was nearly 20 years ago now ....)

I built the bare PCB needed. (PIC, de-coupling capacitors, all supply pins connected on the PIC, MAX232 with caps, 9 pin D type connector etc... )

The supplied demo's failed (very frustrating) Back then I only had UV erasable PIC's to use... 30 minutes between flash slows you right down.

I gave up the "tweek and test" and sat down to work from first principles and calculated the input pin changes to recieve a character and ran it in the PIC (debugger?) simulation.

The simulation allowed you to simulate the pins changing on the PIC at specific times. This was soo usefull when trying to get the timming right.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ +1 for bringing back memories, but it's fairly rare to bit-bang asynch communications these days (thank goodness). \$\endgroup\$ Commented Jul 11, 2014 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.