12F629 beginning


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Sep 2007
    Posts
    12

    Question 12F629 beginning

    Hi you all again!

    Iīm already working with pics a little bit thanks to your help but didnīt work with these mcus for nearly a year.
    Iīm working with 16F628A and this is already ok for me, LCD text and frequency counters even
    digitally rev limiters for engines with two BCD rotary switches, works all fine.

    BUT: I need a little helper-program and donīt want to waste a 16F628 for this. The 12F629 could do just fine even without crystal etc. I just need one pin as Input and one as output for example for a LED.

    So what: I donīt even know how to start anything in PICBasic Pro (got the full version!!)
    for example something like blink.pbp .

    I can load a hex file into the PIC but i dont know how to adress the pins , start the intern oscillator . Thats for starters.

    hey donīt laugh that loud! iīm a mechanical by profession with just a few electrons in my veins.

    Thanks in Advance !

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


    Did you find this post helpful? Yes | No

    Default

    Configuration fuse : http://www.picbasic.co.uk/forum/showthread.php?t=543

    This one use GPIO instead of PORTA-PORTB
    TRISIO instead of TRISA-TRISB

    and you need to disable the analog comparator... same as 16F628 CMCON=7


    maybe the following would be enough to start
    http://www.picbasic.co.uk/forum/show...t=blink+12F629
    Steve

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

  3. #3
    Join Date
    Sep 2007
    Posts
    12


    Did you find this post helpful? Yes | No

    Smile Upgrade from Blinking

    Thanks Mister_e!
    The blink.pbp works with my 12F629 with pin 7 as output which is ok for me.

    Leaves one problem: I want to make for example pin 7 (GP0) output and pin 2 (GP5) Digital Input for frequency measure purposes. The program will switch the LED on when the input gets a lower than specified frequency . The program is no problem, just the PIN order.

    So theres one thing I see: I have to concentrate on a very small Number of different Pics to get used to them. My favorites: 12F629, 16F628A, 16F876A. That should do for the next years or so. Iīve learned the old school "two transistor 6-18V circuits" when I was 14. Thats 30 years ago. Now Iīm wriggling around sportscar engines and some electronics knowledge comes in handy you know.

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


    Did you find this post helpful? Yes | No

    Default

    I suggest you have a look to 12F683. Really nice one for a 8 pin device, PWM, A/D, Comparator and much more codespace.

    16F88 is also a nice one. Nice replacement for the 16F628

    16F88x are nice as well... OH well, hard to find my favourite... i had 50-60 different model before in stock. And Microchip seems to release a brand new model each week.
    Steve

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

  5. #5
    Join Date
    Sep 2007
    Posts
    12


    Did you find this post helpful? Yes | No

    Unhappy Damn input

    Hi Guys,

    my program shows a flaw but i dont know where.

    depending on the press of a button at GPIO.1 a led should flash defferent at GPIO.0.

    ************************************************** **************
    '* Name : Blink4.pbp *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2007 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 26.09.2007 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    @ DEVICE pic12F629, INTRC_OSC_NOCLKOUT ; System Clock Options
    @ DEVICE pic12F629, WDT_ON ; Watchdog Timer
    @ DEVICE pic12F629, PWRT_ON ; Power-On Timer
    @ DEVICE pic12F629, MCLR_OFF ; Master Clear Options (Internal)
    @ DEVICE pic12F629, BOD_OFF ; Brown-Out Detect
    @ DEVICE pic12F629, CPD_OFF ; Data Memory Code Protect
    @ DEVICE pic12F629, PROTECT_OFF

    DEFINE OSCCAL_1K 1' Set OSCCAL for 1k
    cmcon = 7 ' Comparator OFF


    TRISIO = %11111110 ' Set GPIO 0 as output 1-4 as input

    if gpio.1 = 1 then
    pulsout GPIO.0,10000
    else
    pulsout GPIO.0,2000

    endif

    I missed something, but dunno what. The led reacts at the first command line, whether theres a gpio.1 = 1 or gpio.1 = 0
    but never at the button itself. it doesnīt find the input.

    HELP!
    Last edited by Davidpower; - 27th September 2007 at 22:01.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    If that is all of your code it is stopping at the endif.

    Code:
    MAIN:    'Add this for a loop name.
    if gpio.1 = 1 then
    pulsout GPIO.0,10000
    else
    pulsout GPIO.0,2000
    
    endif
    GOTO MAIN    'Add this to start the loop again
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Sep 2007
    Posts
    12


    Did you find this post helpful? Yes | No

    Question Input/Output 12F629

    ok, this works but I donīt know how to adress in and outputs of the 12F629

    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2007 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 26.09.2007 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    @ DEVICE pic12F629, INTRC_OSC_NOCLKOUT ; System Clock Options
    @ DEVICE pic12F629, WDT_ON ; Watchdog Timer
    @ DEVICE pic12F629, PWRT_ON ; Power-On Timer
    @ DEVICE pic12F629, MCLR_OFF ; Master Clear Options (Internal)
    @ DEVICE pic12F629, BOD_OFF ; Brown-Out Detect
    @ DEVICE pic12F629, CPD_OFF ; Data Memory Code Protect
    @ DEVICE pic12F629, PROTECT_OFF

    DEFINE OSCCAL_1K 1' Set OSCCAL for 1k
    cmcon = 7

    trisio.5 = 1 ' port5 is an input

    led1_status var bit
    button1 var gpio.5
    led1 var gpio.0

    main:

    if button1 = 0 then ' if the button is pressed

    led1_status = 0 ' make it 0
    pulsout GPIO.0,10000
    pause 50 'debounce

    else

    led1_status = 1 ' the last state was a 0 so now make it a 1
    pulsout GPIO.0,2000

    pause 50 'debounce

    endif
    goto main

    there has to be a simple straightforward command to define inputs and outputs

    what the heck is it? I know the tris option for the 16F628A which works fine but doesnīt seem to work for me on the 12F629..why? This looks like "I define one port and hope the others work somehow for me" what do I miss? the explanation in the picbasic pro handbook doesnt help a bit because it adresses only the bigger Pics
    Last edited by Davidpower; - 1st October 2007 at 19:02.

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


    Did you find this post helpful? Yes | No

    Default

    Yes TRIS will work... but you need to use the according name as per the datasheet.... TRISIO will do the job as expected.

    Sure the PBP handbook will not cover it. TRISIO, TRIS is not a PBP command, just a PIC register.

    You could still use

    INPUT GPIO.0
    OUTPUT GPIO.1
    and so on.

    TRISIO= %00000001 ' set GPIO.0 as input, other to output... when possible (MCLR)

    it's not a bad idea to set initial value to your PORT as well.

    Don't forget, all i/o are set as input at POR.

    try this one
    Code:
            @ DEVICE pic12F629, INTRC_OSC_NOCLKOUT  ; System Clock Options
            @ DEVICE pic12F629, WDT_ON              ; Watchdog Timer
            @ DEVICE pic12F629, PWRT_ON             ; Power-On Timer
            @ DEVICE pic12F629, MCLR_OFF            ; Master Clear Options (Internal)
            @ DEVICE pic12F629, BOD_OFF             ; Brown-Out Detect
            @ DEVICE pic12F629, CPD_OFF             ; Data Memory Code Protect
            @ DEVICE pic12F629, PROTECT_OFF
            
            DEFINE OSCCAL_1K 1          ' Set OSCCAL for 1k
            CMCON = 7
            
            TRISIO = %00100000          ' port5 is an input
            
            Button1     var gpio.5
            Led1        var gpio.0
            
            GPIO = 0                    ' clear all outputs
            PAUSE 50                    ' internal OSC settle time... more than safe
            
    main:
    
        if button1 = 0 then             ' if the button is pressed
                pulsout Led1,10000
                while Button1 = 0 : wend
                pause 50
    
                else
                    pulsout Led1,2000
    
                endif
        
        goto main
    Last edited by mister_e; - 1st October 2007 at 19:35.
    Steve

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

  9. #9
    Join Date
    Sep 2007
    Posts
    12


    Did you find this post helpful? Yes | No

    Question The ultimate program.....

    thanks Mister_e,

    so I could define my ports for the 12F629 and best of all one input and one output covers my needs...
    at last I got my ultimate program: counting pulses on GPIO.5 and give a signal if a limit is exedeed:
    '************************************************* ***************
    '* Name : count12F629_1 *
    '* Author : Davidpower *
    '* Notice : Copyright (c) 2007 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 26.09.2007 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    @ DEVICE pic12F629, INTRC_OSC_NOCLKOUT ; System Clock Options
    @ DEVICE pic12F629, WDT_ON ; Watchdog Timer
    @ DEVICE pic12F629, PWRT_ON ; Power-On Timer
    @ DEVICE pic12F629, MCLR_OFF ; Master Clear Options (Internal)
    @ DEVICE pic12F629, BOD_OFF ; Brown-Out Detect
    @ DEVICE pic12F629, CPD_OFF ; Data Memory Code Protect
    @ DEVICE pic12F629, PROTECT_OFF

    DEFINE OSCCAL_1K 1' Set OSCCAL for 1k
    cmcon = 7

    trisio.5 = 1 ' port5 is an input

    LED var gpio.0
    Cnt VAR word ' Cnt is a word variable

    Cnt = 0
    LED = 0
    rpt :
    Count gpio.5, 500, CNT

    if CNT > 10 then
    LED = 1
    Else
    LED = 0
    ENDIF
    Goto RPT

    END ' End of program

    of course it doesnīt work and I dont know why. gets TTL square wave signal to GPIO.5 and recognizes the signal in another program when slow enough, that means it recieves and the voltage etc. is ok. Whats wrong?

    please help

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


    Did you find this post helpful? Yes | No

    Default

    Yeah but you also need to define LED as output. By default all I/o are configured as input... so TRISIO=%11111111.

    what if you're using the following
    Code:
    TRISIO=%11111110 ' Set GP0 as output, other to input
    This will set all I/Os in one shot, and configure GPIO.0 as an output

    You could still leave your current TRISIO setting as is but use HIGH LED and LOW LED instead. HIGH/LOW set the according pin to Output for you.

    Depending the frequency you want to measure, COUNT may work well or not. I would use a internal timer instead for that... but it's me.

    First make sure there's no real big DC offset which could trick the TTL threshold level.. hence produce weird/erratic results.

    What happen if you comment the DEFINE OSCCAL... line?
    Last edited by mister_e; - 1st October 2007 at 22:18.
    Steve

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

  11. #11
    Join Date
    Sep 2007
    Posts
    12


    Did you find this post helpful? Yes | No

    Smile Thanks Mister_e

    Thats the trick: the high GPIO.5 / low GPIO.5 makes the trick!

    my program needs to be refined but what the heck it works.

    And last not least: hey man that was a real FAST answer ! You need no sleep?
    Thanks VAR WORD

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


    Did you find this post helpful? Yes | No

    Default

    mmm, yeah i may sleep few hours/week Advantage to have dual screen in front of you

    One for the work, the other for forum and other stuff.

    Glad to hear it works!

    YouAreWelcome VAR LONG ' for PIC18 only
    Steve

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

Similar Threads

  1. 12f629 config settings
    By Dennis in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 1st December 2009, 22:39
  2. Basic help for 12F629
    By Gene Choin in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd September 2009, 04:06
  3. Servo control with 12F629
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd June 2005, 23:34
  4. Program returns to beginning at interupt
    By BGreen in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 25th April 2005, 11:20
  5. 12F629 I2C problems
    By AIW128ProGuy in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th November 2004, 23:41

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