Using the pic12F683


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006
    Posts
    92

    Default Using the pic12F683

    Hi,

    I am a little confused about how to set up the pic12F683, was wondering if some can offer some help. I'm using PicBasic Pro

    I'm just using ANO-AN2 as analog inputs to read pots.
    GP5 as an output to drive a speaker. (I'm using the SOUND command to make some noise).

    This is what I have for the setup so far:

    DEFINE OSC 8 'Oscillator speed in MHz
    DEFINE ADC_BITS 10
    DEFINE ADC_SAMPLEUS 50

    OSCCON = %01110000 ' Set to 8MHz
    CMCON0 = 7 ' Analog comparators off

    ANSEL = %00000111 ' Set AN0-AN2 analog, rest digital

    'And then my main code just does something like this:

    main:

    adcin 0, result 'read pot on pin

    adcin 1, result1

    adcin 2, result2

    sound 5, [stuff] 'pin 2 is sound ouput

    I was wondering if I have to also set up the TRISIO, and if I am missing anything else here.

    I'm just piecing this togther for bits of code I find on the web, trying to make sense of it. Any help would be appreciated, thank you.

    Tony A

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Tony,

    You don't necessarily have to set these pins to inputs with TRISIO before
    using ADCIN, but it definitely is good practice to do so.

    Pins are inputs by default at power-up, but I always include TRIS statements
    in code just to be 100% sure the pin is an input before reading it.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Apr 2006
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    Thank you.

    For this particular chip the ANSEL is used instead of ADCON1?

    Would I still need to set up the ADCON0 if the ANSEL is set up?

    Would you only disable the analog comparator when using a digital input?


    Here's what I have now:

    DEFINE OSC 8 'Oscillator speed in MHz
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 15
    OSCCON = %01110000 ' Set internal OSC to 8MHz
    ANSEL = %00001111 ' Set AN0-AN3 analog, rest digital
    TRISIO.5 = 0 ' GP5 is output
    ADCON0.7 = 1 ' Right justify for 10 bit result

    INTCON = %00000000 'all interrupts OFF



    Thanks again,
    Tony


    Quote Originally Posted by Bruce
    Hi Tony,

    You don't necessarily have to set these pins to inputs with TRISIO before
    using ADCIN, but it definitely is good practice to do so.

    Pins are inputs by default at power-up, but I always include TRIS statements
    in code just to be 100% sure the pin is an input before reading it.
    Last edited by TonyA; - 6th April 2006 at 17:47.

Similar Threads

  1. Pic12f683 Cmcon0 = 7
    By penelopepug in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 12th June 2009, 18:23
  2. Programming Problem PIC12F683
    By StoneColdFuzzy in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 2nd June 2009, 21:39
  3. pic12f683 being picky about pins...
    By erice1984 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th March 2009, 23:16
  4. pic12F683 , gpio.5 not accessible...
    By flipper_md in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 9th May 2008, 05:25
  5. How to calculate ADC resolution (pic12f683)
    By peu in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th April 2007, 18:39

Members who have read this thread : 2

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