Shop OBEX P1 Docs P2 Docs Learn Events
Doh! CON Section... — Parallax Forums

Doh! CON Section...

John R.John R. Posts: 1,376
edited 2010-03-08 20:58 in Propeller 1
In the category of I know better, but...

If you leave these two lines of code out of the CON section, objects that perform serial communication don't work so well...

CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000




Usually I'm starting with existing code, and going from there. In this case I was starting from scratch...

If you at least got a grin out of this at my expense, I've had a good day!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
Click here to see my Nomad Build Log

Comments

  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2010-03-07 00:03
    Good tip for any beginner (or those of us that may forget).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
    www.tdswieter.com
  • w8anw8an Posts: 176
    edited 2010-03-07 03:51
    So true.

    In fact, I grabbed a piece of code for an experiment today that didn't have serial communications in it, but I needed it and added it. The serial didn't work. The code started like this...
    CON
            _clkmode = xtal1 + pll8x
            _xinfreq = 10_000_000 
    
    



    It was Hydra code, I don't have a Hydra.
    When I saw the garbled output on my serial terminal, I changed it to

    CON                          
           _clkmode = xtal1 + pll16x
           _xinfreq = 5_000_000
    
    


    then it worked just fine.

    -Steve
  • RossHRossH Posts: 5,519
    edited 2010-03-07 04:05
    Yup, this one still gets me every so often as well, especially since I work on Props with so many different clock speeds (10Mhz, 6Mhz, 6.25Mhz, 5Mhz). In fact it caught me again just the other day while I was trying to get Hanno's ViewPort program working. Makes you feel like a real dope each time!

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-03-07 11:05
    Because the code can be built up with OBEX blocks, etc, I have seen multiple statements at the top of numerous blocks. I don't know which would take president over the end code, the first or the last.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point
  • hover1hover1 Posts: 1,929
    edited 2010-03-07 13:12
    The top object determines the value. All others have no affect.
    _CLKMODE is used to specify the desired nature of the System Clock. It is a pre-defined constant symbol whose value is determined by the top object file of an application. 
    
    

    Propeller Manual 1.1 Page 68
    Jim
    Toby Seckshund said...
    Because the code can be built up with OBEX blocks, etc, I have seen multiple statements at the top of numerous blocks. I don't know which would take president over the end code, the first or the last.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-03-07 13:32
    Thanks, I have always feared the worst and scouted through for any subsiquent ones.

    RTFM, again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point
  • WhitWhit Posts: 4,191
    edited 2010-03-07 13:38
    John R,

    I read in James Phelan's review of the Stingray in Robot Magazine that he was trying to copy and paste code from pdf and sometimes (depending on the zoom) that the "underscore" in _clkmode didn't acurately transfer. It has to be there, of course, and it gave him fits until he figured it out!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+


    "We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-03-07 15:24
    I have a starter program called "__blank.spin" that fills in these kinds of details. I'm hoping, at some point, that Parallax will add templates to the Propeller Tool (or I should just use BST more....).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon McPhalen
    Hollywood, CA
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-03-07 19:17
    On my LG monitors 1440x900, WinXP SP3, the underscores didn't show up. There were "spaces" where they were. Bumping up the font size made then appear again but that defeats the point of 1440x...... The progs would print them ok and paste them over to notepad etc.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point
  • VIRANDVIRAND Posts: 656
    edited 2010-03-07 19:44
    Toby Seckshund said...
    On my LG monitors 1440x900, WinXP SP3, the underscores didn't show up. There were "spaces" where they were. Bumping up the font size made then appear again but that defeats the point of 1440x...... The progs would print them ok and paste them over to notepad etc.

    That implies to me that your monitor does not have 1440x900 pixels, which certainly defeats the point.
    Not intending to be rude, what is the point of overdriving the maximum resolution?
  • Ken GraceyKen Gracey Posts: 7,401
    edited 2010-03-07 22:01
    @JonnyMac
    I've asked Jeff Martin to look at this thread and to begin including a Spin template with our Prop IDE installation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ken Gracey
    Parallax Inc.

    Follow me at http://twitter.com/ParallaxKen for some insider news.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-03-07 23:10
    Thanks, Ken. It would be nice if it was like the Stamp editor where I could specify a file to use as the template.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon McPhalen
    Hollywood, CA
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-08 00:35
    If you're jugging between a 5 MHz and 10 MHz crystal, just use the clkset object I've posted in the OBEX. That way, you can use

    CON
            _clkmode = xtal1 + pll8x
            _xinfreq = 10_000_000 
    
    
    


    for both platforms and still get an 80 MHz clock. The clkset object figures out which crystal you're using and makes the appropriate adjustments to the PLL mode and to clkfreq. It has a very small footprint.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 3/8/2010 12:40:18 AM GMT
  • hover1hover1 Posts: 1,929
    edited 2010-03-08 14:04
    Phil,

    I couldn't find the clkset.spin in the OBEX, but I did find it here:

    http://forums.parallax.com/showthread.php?p=809968

    Jim
    Phil Pilgrim (PhiPi) said...
    If you're jugging between a 5 MHz and 10 MHz crystal, just use the clkset object I've posted in the OBEX. That way, you can use

    CON
            _clkmode = xtal1 + pll8x
            _xinfreq = 10_000_000 
    
    
    


    for both platforms and still get an 80 MHz clock. The clkset object figures out which crystal you're using and makes the appropriate adjustments to the PLL mode and to clkfreq. It has a very small footprint.

    -Phil
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-03-08 20:54
    VIRLAND said That implies to me that your monitor does not have 1440x900 pixels, which certainly defeats the point.
    Not intending to be rude, what is the point of overdriving the maximum resolution?

    They are advertized as 1440x900 native and are recognized as 1440x900, by the Vid card, one is on DVI and the other on analog, so I assume that they are so. I am not a fan of wide screens on computers ( I prefered my old 1280x1024 ) but this pair were rebuilt "write offs" and so came with the " cheap, in-expencive and not costing much" catagory. My favorite !!!

    I'll have to drag out the old Sanyo 1024x768 to see if the same thing was hapening on that one as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point
  • hover1hover1 Posts: 1,929
    edited 2010-03-08 20:58
    I find myself going between a 5 and 6.25Mhz xtal these days. Even my uOLED-Prop-96 are the later 8Mhz and not the original 10Mhz although I do have a couple of 10Mhz that Parallax carried.

    I need to take a closer look at the code to see if it could be tweaked to smaller frequency differences..

    Jim
Sign In or Register to comment.