Simple program for 12F629


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    Jun 2008
    Posts
    8

    Default Simple program for 12F629

    Hello

    I need som help with this program.
    It should work like this: when power on, GPIO.2 is high. When I apply HI on GPIO.0, after 3 sec GPIO.2 should be low. Config is mclr=off, pwrt=on, wdte=on,boren=on, int OSC I/O.

    Here is the code

    CMCON=7

    ul var GPIO.0 'Define GPIO.0 pin as ul
    izl VAR GPIO.2 'Define GPIO.2 pin as izl

    High izl
    Input ul

    loop:
    if ul=1 then
    pause 3000
    low izl
    end if
    goto loop

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Does 'blinky LED' work?

  3. #3
    Join Date
    Jun 2008
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Does 'blinky LED' work?
    I'm sorry, but I can't find 'blinky LED' example.

  4. #4
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Code:
    ' Example program from manual to blink an LED connected to PORTB.0 about once a second
    
    loop:   High 0          ' Turn on LED connected to PORTB.0
            Pause 500       ' Delay for .5 seconds
    
            Low 0           ' Turn off LED connected to PORTB.0
            Pause 500       ' Delay for .5 seconds
    
            Goto loop       ' Go back to loop and blink LED forever
            End
    http://www.melabs.com/resources/samples.htm#pro


    Hope this helps..
    "It will never happen here!" just happened here.
    My thoughts and prayers for Sandy Hook victims and families.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rele View Post
    I'm sorry, but I can't find 'blinky LED' example.
    WOW!!!!!!!

  6. #6
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    WOW!!!!!!!
    I know its tough, but count to ten, take deep breaths and read Mels most http://www.picbasic.co.uk/forum/show...99&postcount=1

    If you look at his code, there is some logic in his thinking, he has made an attempt to write a program, which doesn't work, and thus came here seeking assistance...

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink Ladies and Gentlemen ... please

    Hi,

    First of all let's leave guns and knives outside ...

    Won't you think a little ( real ! ) SCHEME would be compulsory, here ???

    just to verify how and what to inputs and outputs are linked ...


    "my two cents"

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    Join Date
    Jun 2008
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    I need to disable writing to external eeprom few secconds after power is applyed. So, GPIO.2 pin is connected to the WP pin of eeprom, and GPIO.0 pin have +5V when eeprom have +5V. Between VCC and MCLR is 4K7.

    I know this is very simply for most of you, but this is my first program, and it has practical purpose.

    Regards
    Last edited by rele; - 27th July 2008 at 13:12.

  9. #9
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    I think the point that skimask was trying to get over, is that for a 1st program, the main goal is to get the chip to flash a LED correctly, then go on to develope that.

    A golden rule here is to look at the datasheet, and then set the pic up accordingly. Often these small chips don't have their pins set to digital i/o by default, so need the config set accordingly.

    Once you have a bit of code that blinks an LED, then introduce inputs and modify the code to get the result you want.

  10. #10
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rele View Post

    I know this is very simply for most of you, but this is my first program, and it has practical purpose.

    Regards
    Hi,

    NOOOOOO ... nothing is simple !!!

    We still do not know what is connected to your Pic I/Os ...

    Just remember if hardware is False ... software can't work as expected !!! ... and vice versa.

    We must know everything of your project, if you want us to give a serious answer.


    Now, for some fun ...

    You ask for help...Ok, but you do not tell us even if it works ... How do you verify GPIO.2 works ( or doesn't work ! ) properly ???
    How do you drive GPIO.0 ???



    For the day,We do not use the crystal ball on this Forum ... so, you must do your "part of the work" of debugging, and tell us what's on your side ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  11. #11
    Join Date
    Jun 2008
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,

    NOOOOOO ... nothing is simple !!!

    We still do not know what is connected to your Pic I/Os ...

    Just remember if hardware is False ... software can't work as expected !!! ... and vice versa.

    We must know everything of your project, if you want us to give a serious answer.
    Pin1 - +5V
    Pin2 - N/C
    Pin3 - N/C
    Pin4 - +5V thru 4K7
    Pin5 - Output pin
    Pin6 - N/C
    Pin7 - Input pin
    Pin8 - GND

    Output pin is connected directly to WP pin of external eeprom. Input pin is connected directly to VCC pin of external eeprom. Purpose of program is to disable writing to external eeprom for 3 secconds after power is applyed to eeprom.

    I verify condition of GPIO.2 with logic probe.

    Regards

  12. #12
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Just a little innocent question ...

    Does your program compile ???

    ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  13. #13
    Join Date
    Jun 2008
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Program is ok, I have one mistake in hardware. I put one resistor 10K between input pin and GND and now it is ok.

    Thank you for your help.

    Regards

  14. #14
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rele View Post
    Output pin is connected directly to WP pin of external eeprom. Input pin is connected directly to VCC pin of external eeprom. Purpose of program is to disable writing to external eeprom for 3 secconds after power is applyed to eeprom.
    I verify condition of GPIO.2 with logic probe.
    Regards
    Curious as to why you want to connect WP and disable writing for 3 seconds.
    Is it to be extra double super sure that the eeprom doesn't get written to?

  15. #15
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink Humour ...

    Hi,


    Just a little innocent question ...

    Does your program compile ???
    Code:
    CMCON=7
    
    ul var GPIO.0 'Define GPIO.0 pin as ul
    izl VAR GPIO.2 'Define GPIO.2 pin as izl
    
    High izl
    Input ul
    
    loop:
    if ul=1 then
    pause 3000
    low izl
    end if ... sure about the spelling ???
    goto loop
    You sure ??? just a Typo, I wonder ...

    Now, connecting GPIO.0 to +5v would have been so simpler to find there were NO problem in your code ...
    Do not tell us you have two separate 5v supplies ...

    Alain
    Last edited by Acetronics2; - 28th July 2008 at 09:40.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  16. #16
    Join Date
    Jun 2008
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Yes I have two separate +5V. It is for coded caraudio. When I reprogram eeprom for immo off and connect +5V to WP pin of eeprom carradio is working but memory station is not working, also settings for audio dont work, all data that are usualy stored to eeprom.
    I need to disable writing just for first few secconds when MCU is checking one location in e2prom.

    Quote Originally Posted by Acetronics View Post
    [code]
    end if ... sure about the spelling ???
    My mistake
    Last edited by rele; - 28th July 2008 at 21:48.

Similar Threads

  1. Simple Blink program doesnt work.
    By sccoupe in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 1st March 2009, 20:30
  2. Help with simple program
    By mykewl in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 31st July 2008, 08:58
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. simple counting program - please help!!
    By john meiers in forum mel PIC BASIC
    Replies: 3
    Last Post: - 20th February 2006, 13:17
  5. Simple Interrupt Program
    By eoasap in forum General
    Replies: 5
    Last Post: - 28th October 2005, 16:22

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