This was the audio frequency counter code... posted there
http://www.picbasic.co.uk/forum/showthread.php?t=1044
And like i said it's also post on the Melabs website and include the schematics wich can help to figure few things
http://www.melabs.com/resources/samp...ed/counter.zip
Also, what are the CON numbers doing, as I changed them and get different results based on their number?
i always try to make it easy to read but here's a short explanation of those constants because the choice of their value are important in that.
If you look to the schematic and comments at the top of the original code, PORTA<3:0> is attach to a transistor wich is driving the Common anode on each 7 segment display. Each transistor need to be drive with a low level signal at the base.
Using constant make the code easier to read.
_7Seg1 con 14 ' enable more significant 7 segment display
and later we use...
PORTA=_7seg1 ' enable hundreds 7 segment
same as PORTA=14 or PORTA=%11111110
only the 'hundreds' display is used. When i look to your own definition, you choose more than one 7 segment display at the time so you display on more than one 7 segment at the time. this is one of the reason you see some odd results. few other things now- on PIC16F818, PORTA is analogue, you must set it to digital.
- PORTA.4 is open drain, you'll need to modify your hardware to fit to this pin.
- to use PORTA.5 you must set your configuration fuse to disable MCLR pin and use it as an i/o
- don't forget, the original code was made for a 20MHZ crystal speed and will really not do the same things with a 10 MHZ clock since the DelayBetweenEachDisplay is based on a MPLAB stopwatch simulation. you'll need to divide it by 2 to have about the same delay
Once everything above is done... it's suppose to give better results. well as i see now before to go to sleep...
Last edited by mister_e; - 17th June 2005 at 15:13.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks