Basic help for 12F629


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Gene,

    I was looking at the PBC manual on the MElabs website. Here are some examples of setting the ports. You will also need to have a copy of the 12F629 datasheet to get the register information.

    Code:
    Symbol PortA = 5 'Define PortA register location 
    Symbol TrisA = $85  'Define PortA direction register location  
     Poke TrisA,0  'Make all PortA pins outputs 
     
     
     Peek PortA,B0  'Get current PortA pin states to variable B0  
     Bit1 = 1  'Set Bit1 in B0 which will become PortA pin 1 high  
     Bit3 = 0  'Set Bit3 in B0 which will become PortA pin 3 low  
      'Bit0, 2 and 4 will remain unchanged  
     Poke PortA,B0  'Send the new byte to PortA to complete the change
     
     End   
    
    5.23. POKE
    
    POKE Address, Value
    
    Writes Value to the PICmicro MCU register at the specified Address. Special PICmicro MCU features such as A/D converters and additional I/O ports may be written using POKE. POKE is a PICBASIC™ Compiler statement and is not supported on the BASIC Stamp. (See PEEK for more information.)
    
    Poke $85,0 'Write 0 to register hexadecimal 85 (Sets PortA to all outputs)
    I also just finished looking for some older examples of programs I wrote in PBC but they are at home on my older computer so I don't have access to them until this coming weekend.

    You need to look at the READ.ME file that came with your compiler program to check and see if the 12F629 will work with PBC. I didn't see it in the manual's list. You may be wasting your time with this chip if its not supported!

    HTH,

    BobK
    Last edited by BobK; - 22nd September 2009 at 01:53. Reason: Got more information

  2. #2
    Join Date
    Sep 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Cool 12F629 Input read problems

    Thanks for looking. I have the latest Microcode Studio and programming sw and it handles the 12F629 fine.
    I've programmed it to do all kinds of functions, but it just won't read the input.

    First, I do address the ports, not as TRIS0, but as each port GP1, ... directing them to be inputs or outputs.
    I did add the CMCON,7 statement
    And SYMBOL CMCON $1f (that was from Another advice).
    The programs proceeds through the light flasing, but doesn't change when I ground GP1.
    I did have one error Letting B0 = 1. It should be B0=0 to clear register.
    BUTTON claims to look at pin 1, what state is is to be when pressed and when it's pressed, what to goto.
    It does that but tHe BUTTON command just follows whatever I set B0 at. No update by the BUTTON command from GP1 (pin1).

    I tried the "Button.BAS in the examples and it did the same. No workee! BUT, they give you only the code snippet without any setup.

    ' BUTTON Command
    '
    ' Demonstrate BUTTON command. Prints working variable (in this case B0) to
    ' show how auto-repeat works. Prints "PRESS" when button is pressed or
    ' repeated.

    Symbol CMCON = $1f
    SYMBOL B = pin1 ' Button Input
    poke CMCON,7 'all digital
    'symbol GPIO=$00001000
    'symbol TRISIO=$00001000
    Output 0 'Make GPIO0 the Strike output
    Input 1 'Make GPIO1 the Run Sense in
    Output 2 'Make GPIO2 the Filament Drive out
    Input 3 'Make GPIO3 the MCLR in
    Output 4 'Make GPIO4 the START LED out
    Output 5

    Let B0 = 0 ' Zero Button Working Buffer
    Loop:
    Button B,0,10,5,B0,0,Skip ' Check Button (Skip if Not Pressed)
    Pulsout 5, 2000
    Goto Loop
    Skip:

    PULSOUT 4,2000 ' Indicates Button Pressed
    Pause 100 ' Visual Pause
    Goto Loop ' Forever

Similar Threads

  1. Sending Commands from Visual Basic about IR to Pic
    By tne_de in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th April 2009, 06:09
  2. Indexer not indexing...a basic PBP problem??
    By jellis00 in forum General
    Replies: 8
    Last Post: - 24th March 2009, 16:53
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Visual Basic 2005
    By keithdoxey in forum Off Topic
    Replies: 4
    Last Post: - 1st August 2007, 12:10
  5. vb6 to pic basic
    By Darrenmac in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th December 2005, 01:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts