UART Communication Problems on Custom Board
Nate11
Posts: 2
I have designed and recently manufactured a circuit board that will be used to power the INS of a miniature drone. The board centers around a P8X32A in the LQFP package which is interfaced with a MPU9150 IMU, a connector for a UART GPS, and a connector to an Xbee (also communicating via UART). I have a 5MHz resonator on the board, but it is not currently working so I am running software in RCFAST mode. I am able to successfully upload code to both RAM and EEPROM.
The problem is that when I try to communicate with my PC using UART through the Propeller Plug, I end up with garbage in the terminal. For example:
serial.startRxTx(PCRX,PCTX,0,9600)
serial.str(string("Onboard Computer Remove Communications Started Successfully\n\0"))
Returns the following in the Parallax Serial Terminal:
®¢¯¡²¤ ¯*°µ´¥²²¥*¯¶¥ ¯**µ®©£¡´©¯®³´¡²´¥¤ µ££¥³³¦µ¬¬¹®
This happens when using both the "Parallax Serial Terminal" and "pcFullDuplexSerial" objects from the exchange.
It appears to me that the communication is somehow out of phase. The baud rate is correct and I've tried a wide variety of speeds from 300 to 57600. It makes me wonder if the internal clock is not running accurately. However, I am able to successfully upload code every time. I would think that the code upload would fail if this is the case. Doesn't the fact that uploading code works, confirm that serial communication should work?
Does anyone have any ideas of what could be going on here? Any help is greatly appreciated!
The problem is that when I try to communicate with my PC using UART through the Propeller Plug, I end up with garbage in the terminal. For example:
serial.startRxTx(PCRX,PCTX,0,9600)
serial.str(string("Onboard Computer Remove Communications Started Successfully\n\0"))
Returns the following in the Parallax Serial Terminal:
®¢¯¡²¤ ¯*°µ´¥²²¥*¯¶¥ ¯**µ®©£¡´©¯®³´¡²´¥¤ µ££¥³³¦µ¬¬¹®
This happens when using both the "Parallax Serial Terminal" and "pcFullDuplexSerial" objects from the exchange.
It appears to me that the communication is somehow out of phase. The baud rate is correct and I've tried a wide variety of speeds from 300 to 57600. It makes me wonder if the internal clock is not running accurately. However, I am able to successfully upload code every time. I would think that the code upload would fail if this is the case. Doesn't the fact that uploading code works, confirm that serial communication should work?
Does anyone have any ideas of what could be going on here? Any help is greatly appreciated!
Comments
Keep in mind that on download the Propeller actually does a calibration routine so that it can in fact communicate with the PC in RC mode.
While I focus on PropBASIC in this article, there is a section about manually tuning for your Propeller so that you can have serial coms in RC mode; this may be helpful:
-- http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
1) Defective PLL. This could be a result of not have the proper decoupling capacitors on all VDD/VSS lines.
2) A crystal outside the capacitance parameters. You mentioned resonator. Do you have a part number?
Here is a little demo about the calibration. It starts in RCFAST, which is the default with an assumed clkfreq=12MHz, and then uses a Spin clkset command to enter a calibrated frequency value. The demo uses two pins, one to output the raw frequency of the internal RC oscillator (HFPIN=19 here), and one to output a frequency that I would like to be 1kHz (LFPIN=18). But it will be 1kHz only after the actual value of myClkFreq is entered in the clkset command.
The frequency output on HFPIN will be near but not exactly 6MHz, and you can measure it with a counter or on an oscilloscope. Multiply times 2 to get the actual clkfreq, and enter it in the program. Then the 1kHz value will be right on. This has a particular value from one Prop where the RCfast clock was running at 13.245033 MHz. That is more than 10% different from 12MHz and would really mess up a baud rate.
You don't have to measure the ~6MHz. You can measure the low frequency output with a starting value of myClkFreq:=12_000_000, and then get a correction multiplier in the way Jon described in his article.
I'll try tuning RCFAST later and see if that resolves the issue, but it sounds like I really need to get the external timer issue worked out. Since this will (hopefully) eventually be put on an aircraft, it needs to work in a range of temperatures. Measuring and tuning with an oscilloscope won't be an option in the end product.
Crystal Input. Can be connected to output of crystal/oscillator pack (with XO left disconnected), or to one leg of crystal (with XO connected to other leg of crystal or resonator) depending on CLK Register settings. No external resistors or capacitors are required.
(emphasis mine)
On page 14 you'll find Table 14 that indicates the Propeller has built-in capacitors.
This is what I use in my designs:
-- http://www.digikey.com/product-detail/en/ECS-50-20-5PX-TR/XC1265CT-ND/827729