View Full Version : RA7/CLKIN as analog input
mischl
- 14th January 2005, 15:13
hello
in an existing environment i want replace a 16C58 with an 16F628A. originally at the CLKIN (RA7) there was an potentiometer. how can i read in analog this pin and must configure them?
thanks for an idea and greetings
mister_e
- 14th January 2005, 15:16
Use POT or RCTIME statement. Must add an external capacitor prior to make it work. Input must be set to analog too. CMCON=7.
mischl
- 14th January 2005, 16:42
thanks for the information, unfortunalety it doesn't run...
can you tell my link where CNCOM is described online?can't find a good information
POT and RCTIME are described in the PBP Compiler Manual, but im not sure if my code is arranged right
could you tell me a short example in PBP?
thank you very much
mister_e
- 14th January 2005, 16:58
this one comes from Melabs code example
' PicBasic Pro program to read pot and display on LCD
' Define LCD pins
Define LCD_DREG PORTA
Define LCD_DBIT 0
Define LCD_RSREG PORTA
Define LCD_RSBIT 4
Define LCD_EREG PORTB
Define LCD_EBIT 3
' Allocate variables
x var byte
CMCON = 7 ' Set PORTA to digital
Pause 100 ' Wait for LCD to start
mainloop: Pot PORTB.0, 127, x
Lcdout $fe, 1, "pot=", #x ' Send value to LCD
Pause 100 ' Do it about 10 times a second
Goto mainloop ' Do it forever
End
in the PBP you have also one code example for POT and the according schematic. BTW if you don't have any book on hand, they provide one online
pdf:
http://www.melabs.com/downloads/pbpm304.pdf
Html:
http://microengineeringlabs.com/resources/pbpmanual
CMCON is the register for analog comparator of the PIC16F628. You'll find it in the datasheet section 9.0
datasheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/40300c.pdf
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.