Programming 12F683 in QBASIC
Hi,
I can't get a 12F683 PIC to accept inputs. Here is an example of what I've tried.
'03.01.14
'Test 12F683
OSCCON = %01100000 'Internal 4MHz osc
ADCON0 = 0 'A/D off
CMCON0 = 0x07 '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 = %00100100 'GPIO,0
Config GP2 = Input
start:
If GP2 = 1 Then
GP5 = 1
Else
If GP2 = 0 Then
GP5 = 0
Endif
Endif
Goto start
End
At one time I had a TOGGLE LED to show it was working, and even though the program didn't work properly, did show a change when the input went high.
I copied the top part where is sets up, and have changed it a little!
Cheers, Camerart.
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.
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
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.
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 :D
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.
Re: Programming 12F683 in QBASIC
FYI - QBASIC is a relatively high level language compiled (or interpreted depending on the version) to run on DOS or Windows PCs. It was written by Microsoft, and discontinued many years ago when they moved to Visual Basic. I don't think there was ever a version that compiled for PIC.
Re: Programming 12F683 in QBASIC
Hi Charlie,
As I said I learnt basic basic, soon after it came out, and have continued ever since. I've considered learning other programs, but it was hard enough to do one time, so I didn't. I've made processing equipment, automatic vehicles, and lots small stuff, and still find it amazing to have flashing lights, once I get something working. Today I have almost finished programming a remote heater start-up switch so I can warm the vehicle up, 10 mins before getting in. I compile with picsimulatoreide, and burn with pickchip2. Simple, headachy, but fun!
Cheers, Camerart.
Re: Programming 12F683 in QBASIC
Glad you've had some successes. What you may not realize is that there are dozens of versions of BASIC targeting many different processing platforms, and many different versions even for the same platform. I can name a half dozen versions for PIC alone, not to mention a few for Android, and several for Windows. Saying you use BASIC is a little like saying you speak human.
You are currently posting on a forum dedicated to only one of those flavors - apparently not the one you are using. A major advantage of this particular version of BASIC is a large group of users that help each other, as you are discovering. Many of the other versions also have helpful communities if you can find them. Unfortunately, other than very general things, you are not likely to get much specific help for your environment from the folks here. But welcome - there are lots of great ideas here, even if there won't be specific help. And who knows... you might even find a reason to "convert" :-)
Re: Programming 12F683 in QBASIC
Hi Hecler,
I thought I had already replied, but perhaps not. Here is a link to the kind of Basic I am using: http://www.qbasic.com/
Cheers, Camerart.
Quote:
Originally Posted by
Heckler
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 :D
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.
Re: Programming 12F683 in QBASIC
Hi Charlie,
I did kind of realize that there are more versions of basic. I'm just glad I learnt 'QBASIC' when, and in the way I did or I would never have learnt any. I need to go into all sorts of efforts, to learn. At present I 'need' tolearn MORSE, and it's quite a challenge, for me anyway. I'm getting there.
Cheers, Camerart. UK
Quote:
Originally Posted by
Charlie
Glad you've had some successes. What you may not realize is that there are dozens of versions of BASIC targeting many different processing platforms, and many different versions even for the same platform. I can name a half dozen versions for PIC alone, not to mention a few for Android, and several for Windows. Saying you use BASIC is a little like saying you speak human.
You are currently posting on a forum dedicated to only one of those flavors - apparently not the one you are using. A major advantage of this particular version of BASIC is a large group of users that help each other, as you are discovering. Many of the other versions also have helpful communities if you can find them. Unfortunately, other than very general things, you are not likely to get much specific help for your environment from the folks here. But welcome - there are lots of great ideas here, even if there won't be specific help. And who knows... you might even find a reason to "convert" :-)
Re: Programming 12F683 in QBASIC
SORRY!!!
I have been informed that: I first learnt SPECTRUM BASIC,then QBASIC and now I'm using PICBASIC to program my PIC chips. It is confusing, at least for us oldies :)
Cheers, Camerart.
Re: Programming 12F683 in QBASIC
Getting closer... now which version of PICBASIC? Look for an *ABOUT* button.
Re: Programming 12F683 in QBASIC
Hi Charlie,
No clear answer I'm afraid, even asking my son who 'understands'. I use PICSIMULATOREIDE. This doesn't show the actual version, but has a 'basic compiler reference manual' where the programming words are. The program can then be simulated and compiled. I suppose it's been modified by Vladimir Soso, the designer. For me it's a brilliant program.
Sorry if it's like pulling teeth, but I'm a bit limited as a computer technician:)
Cheers, Camerart.
Re: Programming 12F683 in QBASIC
I believe you're using the OshonSoft [url=http://www.oshonsoft.com/picbasiccompilerexamples.htmlPIC Simulator IDE integrated PIC Basic compiler[/url]. It's unfortunate that several companies calls their respective product for PIC BASIC whatever as it leads to confusion like the one we're currently having. Like I said previously, most BASIC compilers are similar but still they are ALL different from one another in some aspects.
PIC BASIC PRO <--- The one that this forum discusses
Swordfish PIC BASIC compiler.
PROTON PIC Basic Compiler
Oshon Soft PIC Basic Compiler
mikroBasicPro for PIC from MikroE
PIC BASIC: GCBASIC
Great Cow BASIC for PIC (probably the same as above)
AMICUS18 Basic (which is the same as Proton but limited device support)
The list goes on.....and then there's the various modules running interpreted BASIC like the classic BASIC Stamps, and the ATOMs and again, they are all BASIC in one way shape or form (just like Visual Basic, GWBasic, QBasic and so on are) but they are ALL different from one another.
/Henrik.
Re: Programming 12F683 in QBASIC
Quote:
Originally Posted by
HenrikOlsson
I believe you're using the OshonSoft [url=http://www.oshonsoft.com/picbasiccompilerexamples.htmlPIC Simulator IDE integrated PIC Basic compiler[/url]. It's unfortunate that several companies calls their respective product for PIC BASIC whatever as it leads to confusion like the one we're currently having. Like I said previously, most BASIC compilers are similar but still they are ALL different from one another in some aspects.
PIC BASIC PRO <--- The one that this forum discusses
Swordfish PIC BASIC compiler.
PROTON PIC Basic Compiler
Oshon Soft PIC Basic Compiler
mikroBasicPro for PIC from MikroE
PIC BASIC: GCBASIC
Great Cow BASIC for PIC (probably the same as above)
AMICUS18 Basic (which is the same as Proton but limited device support)
The list goes on.....and then there's the various modules running interpreted BASIC like the classic BASIC Stamps, and the ATOMs and again, they are all BASIC in one way shape or form (just like Visual Basic, GWBasic, QBasic and so on are) but they are ALL different from one another.
/Henrik.
Hi Henrik,
That seems correct.
Thanks, Camerart.