Shop OBEX P1 Docs P2 Docs Learn Events
Propeller Problems (Xtal and serial libraries) — Parallax Forums

Propeller Problems (Xtal and serial libraries)

Agent CobaltAgent Cobalt Posts: 88
edited 2006-05-14 02:39 in Propeller 1
After receiving my propeller and USB2SER, I went to the local electronics store to pick up a crystal and some other parts. I know it needed to be 2 pin and anywhere from 4-80MHz. Now all I have to do is just put it across pins 30 and 31, right? If so, I did that and when I compiled and ran my code, the propeller wouldn't run. Are there any certain other specifications as to what the crystal should be?

Second, I've been working on prototyping a design on the propeller and can't seem to get the serial libraries (simple and full duplex) to work right. I specified the parameters necessary, but the propeller doesn't seem to output any data on the out pin I specified. Is there some information on how to properly use the libraries because I'm thinking I have done something wrong.

Any help is appreciated. Thank you.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truth can be dangerous... Trust can be deadly.

Comments

  • GadgetmanGadgetman Posts: 2,436
    edited 2006-05-12 19:24
    You don't NEED a crystal to run the Propeller.
    (it has a RC-clock built-in that it runs on until you specify something else )

    Anyway, what's the specification on the crystal?
    If it is more than 10MHz, DO NOT enable the PLL as it multiplies the xtal frequency with 16, and 160MHz is the max before the PLL fails. (this happens whether or not you actually USE the 16x output of the PLL, as it ALWAYS multiplies with 16, and just varies which 'tap' it takes the output from)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-12 19:27
    You did not specify which crystal you got, so the default parameters may not be correct in the code for your setup.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Agent CobaltAgent Cobalt Posts: 88
    edited 2006-05-12 19:29
    It's a 4Mhz crystal. Sorry that I forgot to mention it's value. I use the XTAL1 clock setting in my code with the 16x multiplier on. I'm trying to get the crystal to work because upon analyzing the libraries for graphics, it seems I need at least 15 MHz to use them.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truth can be dangerous... Trust can be deadly.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-12 19:31
    Okay, now we have the crystal, I should've added to know what type of device you're talking to, and how you're connected to it.· Does it use TRUE or INVERTED baud mode and what baud rate parameter did you use?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Agent CobaltAgent Cobalt Posts: 88
    edited 2006-05-12 19:34
    For the serial object, I'm using 9600 baud trying to output to the BASIC Stamp debug window since I can't run the TV libraries on the internal oscillator (at least that's what I understand from reading the code for them).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truth can be dangerous... Trust can be deadly.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-12 20:23
    Are you using the Propeller Clip, USB2SER or a serial interface to get the data to the BASIC Stamp Editor Debug Window?· What circuitry is connected between the Propeller and the PC that's running the Stamp Editor?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Agent CobaltAgent Cobalt Posts: 88
    edited 2006-05-12 20:29
    I'm using the USB2SER module to get the data to the BASIC Stamp debug window. I'm not sure if anything is supposed to be connected in between as all I have is the wire from the propeller to the Rx line on the USB2SER. I also just retested the propeller with my 4Mhz crystal with the simple blink an LED example and that doesn't even run.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truth can be dangerous... Trust can be deadly.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-12 20:50
    Are you saying the code downloads perfectly but just doesn't appear to work?· How are you powering the Propeller Chip?· Can you take a picture of your setup and or post your code?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Agent CobaltAgent Cobalt Posts: 88
    edited 2006-05-12 21:50
    Attached is a picture of my setup and below is the code. The LED just remains on and never turns off. Other programs using any serial also do not work.
    I've wired the propeller up just as shown in the manual I downloaded.

    CON
      _clkmode = rcfast
    ' 
      High = 1                         'A CONstant used to set an output port to about 3 volts
      Low  = 0                         'A CONstant used to set an output port to about 0 volts
      Out = %1                         'A CONstant used to set a port's direction to Out
    ' 
    VAR
      Byte Pin                         'Declares Pin to be a global VARiable of a type Byte
    '
    OBJ
      serial    : "Simple_Serial"
       
    PUB Start                          'A PUBlick procedure named Start
      serial.start(-1, 30, 9_600)                                                             
      BlinkingLED                      'Calls the PRIvate procedure BlinkingLED
    '                                                                                                                               
    PRI BlinkingLED                    'A PRIvate procedure named BlinkingLED
      Pin := 16                        'Assigns 16 to the variable Pin                                      
      DirA[noparse][[/noparse]Pin] := Out                 'Makes port A16 an output port
      Repeat 5                         'Repeats the code indented under it 5 times' 
             OutA[noparse][[/noparse]Pin] := High         'LED ON
             serial.str(string("LED ON"))                                      
             WaitCnt(6_000_000 + Cnt) 'ONE-HALF SECOND WAIT
             OutA[noparse][[/noparse]Pin] := Low          'LED OFF
             serial.str(string("LED OFF"))
             WaitCnt(6_000_000 + Cnt) 'ONE-HALF SECOND WAIT
    '
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truth can be dangerous... Trust can be deadly.
    1144 x 856 - 391K
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-13 03:35
    Okay, first you're using the internal oscillator which I don't believe will work with the Serial Object.· I will have to check on that because oddly enough I don't seem to have it.· But I also wanted to ask how you are powering the Propeller Chip?· Do you get any errors downloading the code?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-13 04:20
    I agree with Chris; you need to use a stable crystal for reliable async comms·with the serial objects.· Since you have a 4 MHz crystal, put these in your first CON block:

    · _CLKMODE· = XTAL1 +·PLL16X
    · _XINFREQ· = 4_000_000

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Beau SchwabeBeau Schwabe Posts: 6,547
    edited 2006-05-13 04:32
    You can't use 'RCFAST or RCSLOW' in conjunction with '_CLKFREQ or _XINFREQ' which is what I suspect that "Simple_Serial.spin" uses to calculate
    the proper timebase for the specified Baud.

    With that said, you shouldn't be able to downlaod the code to the Propeller due to the following message...


    attachment.php?attachmentid=41629


    ...So I'm a little confused as to how the LED is "ON" at all.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 5/13/2006 4:37:12 AM GMT
    363 x 132 - 15K
  • Beau SchwabeBeau Schwabe Posts: 6,547
    edited 2006-05-13 05:34
    Agent Cobalt,

    Jon's suggestion as far as specifying the crystal should work.




    Below is more of an FYI:

    This method is not extremely accurate, but it would be comparable to the RC time.
    The difference is that you can use the PLL options as well as '_CLKFREQ or _XINFREQ'.

    Simply use a 10uH coil in place of where you would put a crystal.

    In code, specify using a xtal3 so that the internal 16pF capacitor is selected.
    The frequency comes out to be about 12.6MHz, so specify this for your '_xinfrequency' value.


    F = [noparse][[/noparse] 1 / (2 * pi) ] * sqrt [noparse][[/noparse] 1 / (L * C) ]

    Now, as I said, this isn't extremely accurate so don't expect to be able to use high speed baud rates with this method.



         _clkmode = xtal3
    _xinfrequency = 12_600_000
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 5/13/2006 5:49:35 AM GMT
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-05-13 07:00
    Has anyone mentioned that you don't really need any crystal over 10Mhz [noparse][[/noparse]unless you want some exact odd frequency]
    And you must not run the PLL for crystals over 10Mhz as the speed limit is 160Mhz?

    Above that, things get funky.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Agent CobaltAgent Cobalt Posts: 88
    edited 2006-05-13 08:48
    I figured that using the internal oscillator with the serial libraries wouldn't work so well. As Beau said I shouldn't be able to download the program, the fact that I could puzzles me. I added the crystal to the board and changed the clock mode settings per Jon and the propeller doesn't even run. The code downloads, but then nothing executes. Could it possibly be the crystal (even though it's new)? Are there different types of crystals or does the crystal have to meet certain characteristics?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truth can be dangerous... Trust can be deadly.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-05-13 09:07
    I took a look at the photo of your breadboard and notice that you're missing a couple power and ground connections. I don't know whether these are redundantly bonded or not. But you might try connecting them anyway, just to be sure.

    -Phil
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-05-13 09:44
    The resistor going from the Power strip(GND?) and to H21, is it connected to anything else?

    One thing I've always had as a habit when working with such boards is to have the GND at the bottom and Vin at the top.
    I find it much easier to spot errors then, as schematics are also drawn that way.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-05-13 09:47
    Just for fun, if you ONLY call the BlinkLED object, not the simpleserial one, what happens then?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • Agent CobaltAgent Cobalt Posts: 88
    edited 2006-05-13 18:20
    With the crystal, nothing. Without the crystal, the LED blinks happily. The resistor that you mentioned going to H21 was left over from a different LED program I was working on and wasn't being used.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truth can be dangerous... Trust can be deadly.

    "I'm leaving!"
    "But I haven't set you on fire yet!"
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-05-13 18:52
    Could it be that you have a dud crystal?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • Beau SchwabeBeau Schwabe Posts: 6,547
    edited 2006-05-13 18:59
    Agent Cobalt,

    Not to look past the obvious, you are changing the code that specifies rc or crystal aren't you?


    _CLKMODE = rcfast
    
    



    or

     _CLKMODE  = XTAL1 + PLL16X
     _XINFREQ  = 4_000_000
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Agent CobaltAgent Cobalt Posts: 88
    edited 2006-05-14 01:25
    Yea, I am changing the code when I use the crystal and when I don't. I think Gadgetman might be right in that I could have a dud crystal. Is there a way I could tell if it's a dud or not since I won't be able to get back to the electronics store for a decent length of time?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truth can be dangerous... Trust can be deadly.

    "I'm leaving!"
    "But I haven't set you on fire yet!"

    Post Edited (Agent Cobalt) : 5/14/2006 2:18:02 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-05-14 02:39
    Usually the only way to test a crystal is to put it in a simple oscillator and see if it works. If you have a 10uH coil or close to it, try it in place of the crystal as Beau suggested. If the coil works, the crystal is probably bad.
Sign In or Register to comment.