ShortBus
- 14th June 2007, 01:20
New guy here with both microcontrollers and PBP...
All I want to do is count the number of times a switch cycles over the timespan of a second and output it to a serial port. The serial output is working fine, but I'm getting only lines that read "Hertz:". I beleive that it's a problem with the registers, but I've tried various combinations without luck.
The switch is connected between pin 12 (DIP package) on the PIC and +5VDC, and my code looks like this:
INCLUDE "Modedefs.bas"
' Have tried various registers. Here's what I currently have:
ANSEL = %00000000 ' no analog inputs
CMCON0 = %00000111 ' comparators off
W1 Var word
Loop:
COUNT 1,1000,W1
SEROUT 0,N2400,["Hertz: ",W1,13,10]
PAUSE 1000
GOTO Loop
End
Any suggestions? Thanks!
All I want to do is count the number of times a switch cycles over the timespan of a second and output it to a serial port. The serial output is working fine, but I'm getting only lines that read "Hertz:". I beleive that it's a problem with the registers, but I've tried various combinations without luck.
The switch is connected between pin 12 (DIP package) on the PIC and +5VDC, and my code looks like this:
INCLUDE "Modedefs.bas"
' Have tried various registers. Here's what I currently have:
ANSEL = %00000000 ' no analog inputs
CMCON0 = %00000111 ' comparators off
W1 Var word
Loop:
COUNT 1,1000,W1
SEROUT 0,N2400,["Hertz: ",W1,13,10]
PAUSE 1000
GOTO Loop
End
Any suggestions? Thanks!