Please help a new guy get going with a PIC10F222


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Quacker's Avatar
    Quacker Guest

    Default Please help a new guy get going with a PIC10F222

    Hello all!

    I'm new to programming and that means that the least clearly documented area in programming (setting up the registers) has stopped me cold. I'm coding a 10f222 and I can get my program compiled, but it will not run. I strongly suspect that I don't understand what registers I need to set up. So I ripped down the program and I'm simply asking for GPIO.2 to pulse on and off (get the LED to light). Still nothing.

    What would be great is if someone would post a listing that DID work and I then could compile and run it. That would confirm that everything over here is working correctly, and who knows, I might even learn something!

    Thanks,
    Q

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    I believe the default Config settings is for GP3 to be used as MCLR (which means GP3 must be tied high). Could this be the cause of your problem?

    Although I have never used this PIC, this should blink GP0 at 1 Hz

    ADCON0 = 0 ; all pins digital
    TRISIO = 0 ; all pins output (except GP3)

    Main:
    GPIO.0 = 1 ; GP0 = high
    pause 500 ; Pause 500 mS
    GPIO.0 = 0 ; GP0 = Low
    pause 500
    goto Main

    End

    Good Luck,

    Paul Borgmeier
    Salt lake City, Utah
    USA

  3. #3
    Quacker's Avatar
    Quacker Guest


    Did you find this post helpful? Yes | No

    Default

    I have just gotten the chip to ALMOST work correctly. The only port that I can't get control of is GP.2. This port is shared with a clock that seems to be part of the timer, Tmr0. I can't tell from the data sheet, how to gain control. Perhaps someone can help. I figure that once i'm in control of the ports hat it will be much easier to get them to do what I want. Here is the listing that works. Note that GP.3 is always an input and I don't expect to see an noutput on it. Yes, I did throw the kitchen sink at it, but hey...

    @ Device PIC10F222, IOFSCS_4MHZ, MCPU_OFF, WDT_OFF, PROTECT_OFF, MCLR_OFF

    tmr0= %00000000
    TRISIO =%0000
    ADCON0 = %000000
    GPIO = %0000

    Start:
    high gpio.2 'test
    high gpio.0
    high gpio.1

    pause 1

    low gpio.2
    low gpio.0
    low gpio.1

    pause 9

    goto start
    Last edited by Quacker; - 28th May 2006 at 01:29.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    data sheet section 4.5 OPTION REGISTER

    Now try
    Code:
    @ Device PIC10F222, IOFSCS_4MHZ, MCPU_OFF, WDT_OFF, PROTECT_OFF, MCLR_OFF
    OPTION_REG.5=0 ' TOCS = FOSC/4
    ADCON0 = 0
    TRISIO =0
    GPIO = 0
    
    Start:
        high gpio.2 'test
        high gpio.0
        high gpio.1
    
        pause 500
    
        low gpio.2
        low gpio.0
        low gpio.1
    
        pause 500
    
        goto start
    Last edited by mister_e; - 29th May 2006 at 14:36.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Quacker's Avatar
    Quacker Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks Steve!

    I was hacking around last night and finally figured out the "OPTION_REG.5 = 0" To show you how new I am, I didn't know 'til then that I could actually change a specific register bit, let alone that the OPTION register was actually called the OPTION_REG!

    BTW, Jeff at MELabs confirmed that the ADCIN command does not run properly on this chip (yet?). The command executes but stuffs the answer in the adres register, not the one you specify.

    All-in-all though, a pretty impressive little chip.

    Best,
    Q

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    it's not so hard to do your own ADCIN so far. Just writing and reading the according register. It's pretty well explain in the datasheet. Will be faster and much code efficient.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. I2C with a PIC10F222 - is it possible
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th September 2009, 04:01
  2. Help with waking a PIC10F222
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd August 2009, 02:08
  3. Programming PIC10F222
    By brid0030 in forum General
    Replies: 5
    Last Post: - 19th August 2009, 22:43
  4. I shut this guy down
    By T.Jackson in forum Off Topic
    Replies: 5
    Last Post: - 25th May 2007, 03:27
  5. Danger ...unfair Guy
    By Acetronics2 in forum Off Topic
    Replies: 3
    Last Post: - 10th September 2005, 11:57

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