12F1822 troubles


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2010
    Posts
    409

    Default 12F1822 troubles

    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?

  2. #2
    Join Date
    May 2009
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Re: 12F1822 troubles

    Try setting WPUA register to $3B and see if it makes any difference. Weak pullup may be enabled on RA2.

  3. #3
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: 12F1822 troubles

    Quote Originally Posted by grahamg View Post
    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.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts