12f675 and midi!


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Lightbulb

    You set the use of an exernal oscillator in your programmer software, in your case you should look for HS oscillator. To make GP0 and 1 analog inputs, GP2 digital output and ADconverter 10bit, you should probably(never used the 12F675) use ....

    TRISIO = %00000011
    ANSEL = %00110011
    ADCON0 = %10000001

    ADvalue VAR WORD

    ADCIN 0,ADvalue ' Read channel 0
    ADCIN 1,ADvalue ' Read channel 1

  2. #2
    Alaskanphoenix's Avatar
    Alaskanphoenix Guest


    Did you find this post helpful? Yes | No

    Default

    I want to use gp0 and gp1 as analog inputs and gp3 as digital out to send midi messages:

    DEFINE OSC 20
    DEFINE DEBUG_BAUD 31250 ' midi baud rate
    DEFINE DEBUG_REG gpio ' Set Debug pin port
    DEFINE DEBUG_BIT 2 ' Set Debug pin bit
    DEFINE DEBUG_MODE 0

    adval var byte ' Create adval to store result
    ANSEL = %00000011 ' ----DDAA
    CMCON = 7 ' Analog comparators off

    loop: ADCIN 0, adval ' Read channel 0 to adval
    debug $b0,$00,adval
    Pause 250 ' Do it all about 10 times a second
    Goto loop ' Do it forever

    End

    how can i limit the results of analog inputs between 0-127?

    Thanks a lot

  3. #3
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    divide adval by 2

    adval = adval / 2
    adval = adval >> 2
    i know it's only microcontrolling, but i like it!

  4. #4
    Alaskanphoenix's Avatar
    Alaskanphoenix Guest


    Did you find this post helpful? Yes | No

    Talking YESSSS!!!! IT WOrks!!!

    Thank you all very much!
    It finally works!

    I use the Hs oscillator and it works ok!

    One last question, why if i connect a pot in gpio.0 and rotate it the numbers don't start from 0 but from $7f, go to 0 and arrive to $7f?

    i use adval >> 2 to limit till $7F

    Thanks

  5. #5
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    the pot values goes from 127 to 0 instead 0 to 127?

    then change the plus and minus on your pot, that changes the direction
    i know it's only microcontrolling, but i like it!

  6. #6
    Alaskanphoenix's Avatar
    Alaskanphoenix Guest


    Did you find this post helpful? Yes | No

    Default

    The pot starts from $7f, decreases till 0 and goes to $7f in the same direction!
    But i used advar = advar >> 1 instead of >> 2, because the second starts from $3f to 0 to $3F!

    Why?

  7. #7
    Join Date
    Apr 2006
    Posts
    92


    Did you find this post helpful? Yes | No

    Default Interesting, but a little confused...

    I'm also into MIDI. I've made a midi sender with the 18F452 and was wondering about the 12F683. But since it didn't have HSEROUT I wasn't sure if it would work. So it seems it can work with serout using a 20 Mhtz xtal?

    Something I'm confused about however is the setting up of the ANSEL.
    I see that in the example above by Ingvar there are 2 bits that are set high along with the appropriate pins: like this ANSEL %00110011, but in Allaskan's example he just does this: ANSEL %00000011

    So GPIO.0 and GPIO.1 are analog inputs, but what do the 1's in position 4 and 5 represent?
    What is the ADCON0 doing?

    Also, why do you have to disable the analog comparators?

    Thank,
    Tony
    Last edited by TonyA; - 14th April 2006 at 01:08.

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