12F629 beginning


Results 1 to 12 of 12

Threaded View

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

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