12F629 beginning


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    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.

  2. #2
    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.

  3. #3
    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.

  4. #4
    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.

  5. #5
    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.

  6. #6
    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.

  7. #7
    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

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