frequency counter example help
Martin_mech
Posts: 5
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
·
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
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.
Works great now!
Some one should fix up the
AN001 - Propeller Counters app note example on pg 18.!!!!
Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.