Shop OBEX P1 Docs P2 Docs Learn Events
Location of clkfreq variable in ram — Parallax Forums

Location of clkfreq variable in ram

Stupid question but I'm trying to read the clkfreq from a pasm 2 program. I haven't found anything in the documentation. I've seen another program where it was obtained by rdlong var, #20. On my p2 it seems to be at location 68

Comments

  • See Spin document, Spin2 language -> Variables (page 6).

    CLKMODE => $00040
    CLKFREQ => $00044

  • Cluso99Cluso99 Posts: 18,069

    Spin will save the clock and mode (pnut/PropTool save it in a different location to FlexProp).
    In Pasm only code it is up to you to save it AFAIK.

  • Thank you both

  • ersmithersmith Posts: 6,052
    edited 2021-03-23 21:44

    Worth noting that the Spin2 interpreter differs from every other language for the P2, which all use the location for $14 for clkfreq. If you want your code to be portable or compatible, it's best to pass clkfreq in to the PASM from the high level language (Spin, C, BASIC, or whatever).

  • Actually, $14 is used for clkfreq. $1c is used for the user baud rate.

  • @"Dave Hein" said:
    Actually, $14 is used for clkfreq. $1c is used for the user baud rate.

    Aargh yes, thanks for the correction. I'll update my original post to fix this.

Sign In or Register to comment.