Shop OBEX P1 Docs P2 Docs Learn Events
frequency counter example help — Parallax Forums

frequency counter example help

Martin_mechMartin_mech Posts: 5
edited 2007-04-06 23:36 in Propeller 1
I modified the code in the frequency counter example to see the output on the serial port (monitor), I don’t have the TV connection.
·
I just get zero's. As this is my first program, I am having difficulty in debugging. I dont know if there is a problem with the counter part of the program or the cont variable being returned.
·
I have a 8mhx xtal oscillator with 3v output connected to pin 0.
·
Some advice on what I have done wrong would be appreciated.
·
The code is attached.

the Simple Debug object was downloaded from the Propeller Object Exchange.

Martin


CON
· _clkmode = xtal1 + pll16x
· _XinFREQ = 5_000_000
OBJ
· 'txt : "VGA_Text"
· txt· : "sIMPLEdEBUG"
VAR
· long ctr, frq
PUB Go | freq
· 'txt.start(16)
· txt.start(19_200)
·
· cognew(@entry, freq)
· repeat
··· 'txt.out($00) 'clear the screen
··· 'txt.str(TEST)
··· waitcnt(3_000_000 + cnt)·
··· txt.dec(freq) 'display the value (in Hz)
··· txt.putc($0D)
···
···
DAT
······· org
·······
entry·· mov············ ctra, ctra_ 'establish mode and start counter
······· mov············ frqa, #1 'increment for each edge seen
······· mov············ cnt_, cnt 'setup time delay
······· add············ cnt_, cntadd
·······
:loop·· waitcnt········ cnt_, cntadd 'wait for next sample
······· mov············ new, phsa 'record new count
······· mov············ temp, new 'make second copy
······· sub············ new, old 'get delta
······· mov············ old, temp 'set next delta's base
·······
······· wrlong········· new, par
······· jmp············ #:loop
·······
ctra_·· long··········· %01010 << 26 + 0 'mode + APIN --- WAS 7
cntadd· long··········· 80_000_000 'wait 1 second, answer in Hz
cnt_··· res············ 1 'next count to wait on
new···· res············ 1
old···· res············ 1
temp··· res············ 1

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-05 05:29
    Your cognew statement has to be "cognew(@entry,@freq)".
  • SkogsgurraSkogsgurra Posts: 231
    edited 2007-04-05 06:42
    Thanks Mike!

    You put me on right track, too. I am starting to appreciate the assembler, but had a very similar problem. And then some...

    Devil's in the details.
  • Martin_mechMartin_mech Posts: 5
    edited 2007-04-05 14:18
    Thanks Mike

    Works great now!

    Some one should fix up the
    AN001 - Propeller Counters app note example on pg 18.!!!!

    Martin
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-04-06 23:36
    Argh, this is a bug in my code which was pointed out a while ago. I will rev the Ap Note with all noted errors now ESC and the prelim datasheet·is done and I have a little more "free" time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.