Shop OBEX P1 Docs P2 Docs Learn Events
CLKFREQ in the constant or DAT section? — Parallax Forums

CLKFREQ in the constant or DAT section?

Timothy D. SwieterTimothy D. Swieter Posts: 1,613
edited 2009-03-03 09:45 in Propeller 1
I am working on an assembly routine. This routine is a driver that may run on systems at different Propeller clock speeds. I would like to make the code untied to the specific system speed. In other words I want to do some time calculations upfront, during the "complie" and download to the Propeller. Therefore I was thinking about using the CLKFREQ command in the DAT section for initialized data, but that doesn't seem to be allowed. Then I was thinking having the DAT variable be initialized to a constant variable and have the constant section use CLKFREQ. That doesn't seem to work either.

I am eager to learn of any tips or tricks to accomplish my small design snag of initializing data. I suppose I could do it as a variable, but if it is possible to not use variables that is preferred.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
www.tdswieter.com

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-03 09:23
    The problem is that CLKFREQ isn't a constant. But you can read the initial and (hopefully) current CLKFREQ value as a LONG from hub RAM location $0000.

    -Phil
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-03-03 09:27
    Rereading the Propeller Manual I guess I see that, though it isn't stated explicitly (not sure if it should or shouldn't). OK - so it looks like maybe I should declare a set of longs and do the variable calculation. The DAT section can have initialized data and that data can point to the variables (I think), as long as the variables setup with the proper values before the ASM cog is started.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
    www.tdswieter.com
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-03 09:45
    Or you could just do a RDLONG clock_freq,#0 from your assembly program to get CLKFREQ into a cog location named clock_freq.

    -Phil
Sign In or Register to comment.