PDA

View Full Version : 12F1822 troubles



Charlie
- 23rd June 2012, 17:56
I've got an 1822 doing basic things just fine, and now I'm trying to get a touch sensor going.
Any fresh eyes that can spot my (maybe obvious?) error?

'-----------------turn off unused registers----------------------------
CM1CON0 = 0 'turn off comparitor 1
CM1CON1 = 0 'configuration of comparitor
MDCON = 0 'turn off data modulator
DACCON0 = 0 'turn off DAC
DACCON1 = 0
ADCON1 = 0 'correct configuration for A-D converter
'------Initialize all the pins--------------------
APFCON0 = %11001111 'alternate pin configs - everything off RA0-RA2
PORTA = 0
LATA = 0
TRISA = 0 'Set them all to outputs to start
ANSELA = 0 'all pins digital to start
ADCON0 = %10000000 'right justify, channel 0, but leave it off
'-------------------set up sensor timers--------------------------
'Use timer 0 as the time base. When it overflows, it gates timer1
options var byte
options = %01100110 '128 seems best

T1CON = %11000001 'bit 0=0 to keep it off
T1GCON = %11010101 'set bit 3 to start the timed count
OPTION_REG = options 'doing it this way for use in multiple places

'-------------------set up touch sensors---------------------------
FVRCON = %11000010
CPSCON0 = %10001101 '(enabled, medium range, clocks timer 0)

CPSCON1 = %00000010 'set pin 7 (CPS2)
ANSELA.2 = 1 'set the corresponding bit
TRISA.2 = 1 'set the corresponding bit

At this point, I expect to see a triangle wave on pin5 (PORTA.2) but the pin goes high and stays there.
Thoughts?

grahamg
- 24th June 2012, 10:29
Try setting WPUA register to $3B and see if it makes any difference. Weak pullup may be enabled on RA2.

Charlie
- 24th June 2012, 12:53
Try setting WPUA register to $3B and see if it makes any difference. Weak pullup may be enabled on RA2.
WOW! Problem solved, and you did it first try. I'm humbled, and very appreciative! Who would have thought a weak pullup would kill the oscillator? I would have never found this.

Thank you so much for the assist, and for saving what little is left of my hair.