Shop OBEX P1 Docs P2 Docs Learn Events
UART Communication Problems on Custom Board — Parallax Forums

UART Communication Problems on Custom Board

Nate11Nate11 Posts: 2
edited 2013-05-29 08:01 in Propeller 1
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!
Layout Board.jpg
1024 x 689 - 61K

Comments

  • JonnyMacJonnyMac Posts: 9,107
    edited 2013-05-28 09:19
    Even a 9600 baud RCFAST is probably not accurate enough for reliable serial coms -- you should get your crystal sorted so that you have an accurate timebase.

    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
  • PublisonPublison Posts: 12,366
    edited 2013-05-28 10:44
    A couple of things come to mind.

    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?
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-05-28 12:51
    The RCFAST oscillator nominally runs at 12MHz, but that varies from Prop to prop and also with temperature and supply voltage. Without calibration, baud rates can be off by more than the 5% or so that is tolerable.

    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.

    [FONT=courier new][SIZE=1]CON
      ' program to demo and adjust the calibration of the RCfast oscillator
    
      HFPIN = 19       ' will generate a frequency of around 6MHz, clkfreq/2
      LFPIN = 18       ' we want this to be a frequency of 1kHz after calibration
    
    PUB zing | time, period, myClkFreq
      myClkFreq := 13245033            [SIZE=1]' 12_000_000 nominally[/SIZE]
      clkset(0_00_00_000, myClkFreq)   ' RCfast at myClkFreq
      dira[LFPIN..HFPIN]~~
    
      ctra := constant(%00100 << 26) + HFPIN  ' this pin outputs clkfreq/2
      frqa :=  negx
    
      period := clkfreq/2000   ' set up a synchronized delay, nominal 0.5ms
      time := cnt
      repeat
        waitcnt(time+=period)
        !outa[LFPIN]                   ' want this to be 1kHz
    [/SIZE][/FONT]
    
  • Nate11Nate11 Posts: 2
    edited 2013-05-29 06:47
    This is the resonator that I have attempted to implement with the Prop. It has a capacitance of 15pF. According to another thread, the Prop should have a crystal that is 18-20pF. Would having 15pF stop the chip from running in any XTAL mode?

    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.
  • JonnyMacJonnyMac Posts: 9,107
    edited 2013-05-29 08:01
    If you look at the data sheet you'll find this description:

    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
Sign In or Register to comment.