PortA.4 not working on 16F690


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2005
    Posts
    96

    Default PortA.4 not working on 16F690

    I am having trouble getting my 16F690 pin AN4 working as a digital output. No matter what I try the pin seems to float between high and low and creates an approx 2.6 volts using a multimeter.

    I think I have all the typical items covered like the ANSEL and ANSELH registers and the comparator registers.

    Here is the code, any thoughts are appreciated:

    [/code]
    'defines
    OSCCON=%01110101
    define OSC 8
    DEFINE SHIFT_PAUSEUS 100
    'end defines
    data 0,0
    'includes
    'end includes

    ' Config Fuses
    @ __config _INTRC_OSC_NOCLKOUT & _CPD_ON & _CP_ON & _BOR_ON & _MCLRE_ON & _PWRTE_ON & _WDT_ON & _IESO_OFF & _FCMEN_OFF
    ' PICBASIC PRO program to show button press on LED

    ANSEL = %00000000 ' Set all pins digital
    ANSELH = %00000000
    WPUA = %00000011 ' Enable pullups for buttons
    WPUB = %00000000
    OPTION_REG.7 = 0
    CM1CON0.0=0
    CM2CON0.0=0

    TRISA = %11001111 ' Set PORTA.4,5 (LEDs) to output


    loop:
    PORTA.4 = 1 ' Turn on 1st LED
    pause 1000
    goto loop

    [code/]

  2. #2
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Also I have been able to get the rest of the portA pins other then RA3 and RA4 to work as digital outputs.

    Thanks again

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by modifyit View Post
    I am having trouble getting my 16F690 pin AN4 working as a digital output. No matter what I try the pin seems to float between high and low and creates an approx 2.6 volts using a multimeter.

    I think I have all the typical items covered like the ANSEL and ANSELH registers and the comparator registers.

    Here is the code, any thoughts are appreciated:

    [/code]
    'defines
    OSCCON=%01110101
    define OSC 8
    DEFINE SHIFT_PAUSEUS 100
    'end defines
    data 0,0
    'includes
    'end includes

    ' Config Fuses
    @ __config _INTRC_OSC_NOCLKOUT & _CPD_ON & _CP_ON & _BOR_ON & _MCLRE_ON & _PWRTE_ON & _WDT_ON & _IESO_OFF & _FCMEN_OFF
    ' PICBASIC PRO program to show button press on LED

    ANSEL = %00000000 ' Set all pins digital
    ANSELH = %00000000
    WPUA = %00000011 ' Enable pullups for buttons
    WPUB = %00000000
    OPTION_REG.7 = 0
    CM1CON0.0=0
    CM2CON0.0=0

    TRISA = %11001111 ' Set PORTA.4,5 (LEDs) to output


    loop:
    PORTA.4 = 1 ' Turn on 1st LED
    pause 1000
    goto loop

    [code/]
    Read the datasheet, page 59, read the grayed note in the block right above example 4-1 on the right side of the page....then read your code again...you'll laugh, you'll cry, you'll hurl!


    Ok, just rechecked the datasheet. Unless I'm reading it wrong, page 59 (as described above) and page 60, paragraph 4.2.1 contradict each other.

    Also, which one is it? RA4 or AN4?
    Last edited by skimask; - 8th February 2007 at 04:44.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Where in the code do you turn off the LED?
    Shouldn't Wpau = %00000111 ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Clear as mud

    Quote Originally Posted by skimask View Post
    Ok, just rechecked the datasheet. Unless I'm reading it wrong, page 59 (as described above) and page 60, paragraph 4.2.1 contradict each other.

    Also, which one is it? RA4 or AN4?
    That confused you too? I thought it was only me.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    That confused you too? I thought it was only me.
    I checked the errata...nothing there.
    We must be missing something somewhere.
    Maybe the only way to figure it out is to try it, or maybe one of those other config bits overrides the ANSEL bits...or maybe it's time for another beer...

  7. #7
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default INTOSC Clock Out

    Hi,

    If the config fuses are not properly set (page 197 datasheet) this pin will function as a clock out (Fosc/4) with the internal oscillator enabled. Please check.
    Regards

    Sougata

  8. #8
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Sorry about that phat finger disease. PortA.4, RA4 is the pin I am having issues with.

    I've double checked the config and its set for INTOSCIO so it should not be acting as an oscillator out pin. I've also read the chip back into my programmer and it shows the config is set correctly.

    and yes it is time for another beer

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by modifyit View Post
    Sorry about that phat finger disease. PortA.4, RA4 is the pin I am having issues with.

    I've double checked the config and its set for INTOSCIO so it should not be acting as an oscillator out pin. I've also read the chip back into my programmer and it shows the config is set correctly.

    and yes it is time for another beer
    Try the ANSEL bits the other way around. You have them set as 0's, try them set as 1's. Like I said earlier, I think the datasheet is contradicting itself.

  10. #10
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    got it to work! some how my settings on the melabs programmer got goofed up and the config vars wern't writing to the chip.

  11. #11
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Simple

    It seems the difficult problems are easier to find !
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Blink.Bas on 18f45k20 Newbie seeks working example.
    By DiscoEd in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th December 2009, 03:36
  2. LOW PORTA cause serin2 not working.
    By mikewen in forum Serial
    Replies: 7
    Last Post: - 28th August 2009, 04:18
  3. LCD Display not working - PIC heating...
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 24th September 2006, 07:35
  4. PBP & 16F690 bug?
    By Ron Marcus in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th May 2006, 23:18
  5. Hserin not working...
    By robert0 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 22nd August 2005, 12:25

Members who have read this thread : 0

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