Programming 12F683 in QBASIC


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default Re: Programming 12F683

    Hi,
    Well, that code won't even compile with PBP, which compiler are you using?

    * The format 0x07 isn't supported in PBP, to write in hexadecimal notation use $07.
    * The individual bits on GPIO registers are accessed as GPIO.x not GPx.

    Try changing that for starters and see if it makes it better.

    /Henrik.

  2. #2
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Programming 12F683

    Hi Henrik,

    I don't know what PBP means?

    I'm using what I know as qbasic, I'm too long in the tooth to change I'm afaraid. I use PICSIMULATORIDE for simulating and compiling, then PICKIT2 for burning.

    With the above set-up I can program 16F819 PICs and I've had the 12F683 with a LED flashing, but can't get any inputs.

    Cheers, Camerart.

  3. #3
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Programming 12F683

    Hi,

    I now know what PBP means

    Anyway! I got a simple timer working, here is the code I used:

    '03.01.14

    'Test 12F683

    OSCCON = %01100000 'Internal 4MHz osc
    ADCON0 = 0 'A/D off
    CMCON0 = 7 'Comparators off
    ANSEL = 0 'Set all digital
    WPU = 0 'Internal pull-ups = off
    OPTION_REG = %10000000 'Pull-ups = off, GPIO.2 = I/O, prescaler to Timer1
    GPIO = %00000000 'All outputs = 0 on boot
    TRISIO = %00001000 'GPIO,0=data in, GPIO,1=IRLED out, GPIO,2,3,4,5 unused

    Dim s As Byte 'Seconds

    'needs reset>>>>>>>>>>>>>>>>>>>>>>>.

    start:
    If GP3 = 1 Then
    Gosub sequence
    Endif
    Goto start

    End

    sequence:
    GP5 = 1
    WaitMs 200
    GP5 = 0
    WaitMs 200
    GP5 = 1
    WaitMs 200
    GP5 = 0
    WaitMs 200
    For s = 0 To 52
    WaitMs 1000 '50 seconds
    Next s
    GP5 = 1
    WaitMs 200
    GP5 = 0
    WaitMs 200
    GP5 = 1
    WaitMs 200
    GP5 = 0
    WaitMs 200
    s = 0

    Return

    I noticed on the data sheet, it said "GP3 is only input" so I changed my input to GP3 and it works. I'm sure if I understood better, I could get more inputs though.

    Cheers, Camerart

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default Re: Programming 12F683 in QBASIC

    Hi,
    I'm glad you figured it out!
    As you probably know, this forum is primarily targeting PBP (PIC BASIC Pro) from Micro Engineering Labs. Unfortunatley there are differences between various BASIC compilers so what applies to PBP may not be relevant to the compiler you're using.

    It's not that the people around here wouldn't want to help just because you're using another brand compiler but you'll most likely get much better help on a forum or newsgroup discussing the particullar compiler you're using.

    /Henrik.

  5. #5
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Programming 12F683 in QBASIC

    That GP3 has tripped me up more than a few times as I was just learning. That is true, it can only act as an input (or the MCLR, depending on your configuration fuses)

    In fact on all the PIC's that I have worked with so far... What ever pin is the MCLR pin can ONLY act as Input or MCLR.
    All the other 5 pins can act as either input or output depending on the TRISA register.

    Be sure and get (download) the datasheet for any PIC that you choose to work with.
    It is essential to refer to as you are setting up and defining the pin functions and other features (timers, A/D, PWM, etc).

    The configuration (CONFIG) register is the one that defines the function of that GP3 pin, (and other things like WDT, Brown Out Reset, etc). This register can ONLY be defined at the time you burn the program into the PIC. It can NOT be changed on the fly by your program as it runs. So you must choose how you want the bits in the CONFIG register set and leave them that way unitl you re-program the PIC.

    good luck
    Last edited by Heckler; - 4th January 2014 at 16:16.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  6. #6
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Programming 12F683 in QBASIC

    Hi Heckler,

    I always download the datasheet, but I don't always quite understand them

    I don't think this chip has Trisa or trisb but has Trisio. I've tried various combinations of Trisio's but so far can only use GP3 as input. This is what my config looks like: TRISIO = %00000100

    In all of the examples on the datasheet, it shows language like in post #1, and I only know qbasic.

    Cheers, Camerart.

  7. #7
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Smile Re: Programming 12F683 in QBASIC

    Camerart,

    Yeah, sorry, it is the TRISIO register that defines the In/Out direction of each pin on the 12f683 (again you MUST consult the datasheet as it is likely named something else on a different PIC). But there is a hardware limitation on GP3, that pin can NEVER act as an output, regardless of what is in that bit position of the TRISIO register.

    So I am curious about this QBASIC that you are using for writing PIC programs.

    Can you provide a link to it?

    The PBP compiler that this forum supports is going to be VERY similar to any other "basic" language. With some minor differences that should be easy to learn.

    It is a VERY powerful compiler and well supported.

    The website for PBP is http://melabs.com
    It is a bit of an expense to purchase but well worth it

    There are some world class sofware and hardware folks that hang around here, and are very willing to help (as long as the asker shows some amount of effort before asking.)

    Most of the code examples that you will find on the PIC datasheets is going to be in assembly or machine code, not in a higher level language like basic.

    good luck and keep asking questions.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

Similar Threads

  1. first program 12f683
    By sparkness in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 4th January 2014, 16:07
  2. 12f683 help!!!! L@@K!!!
    By thm ov3rkill in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 2nd December 2008, 22:46
  3. 12F683 Programmer
    By Red_Stafford in forum Schematics
    Replies: 9
    Last Post: - 2nd October 2008, 21:44
  4. Replies: 2
    Last Post: - 23rd July 2006, 08:16
  5. 12F683 Startup
    By GregK in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th March 2005, 00:25

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