Hey all, I'm getting started programming PICs, preferrably in C. I have a fairly strong background in C, so it is naturally my language of choice. I already have several C compilers to work with, as well as a modified JDM programmer.
Anyhow, I'm finding tons of resources on programming the 16 and 18 series PICs, but not alot on the 12 series, which I want to use for a compact design.
My goal is to have an LED connected to GP0 flash at 10Hz while a button connected to GP1 is pressed, but otherwise remain off. I found several simple programs for this in BASIC and ASM, but none in C.
Also, I have a working program for simply flashing an LED in C, but it's developed for the 16F84. As I understand, the 12 and 16 series use different instruction sets, so it won't work on the 12F629.
I tried the BoostC compiler, but I didn't care for it. I'm currently using mikroC compiler though.
Anyhow, thanks for clearing that up about the 12F629.
Basically, when I compile the program for a 16F, it works fine, but for the 12F629 it gives me a bunch of errors like I said before. The program I'm using is;
Supposedly, mikroC takes care of the headers and the fuses, but I like to see all of the coding. Is there a C compiler that works more like that? Something similiar to ol' Visual Studio? lol
Anyhow, perhaps someone can shed some light on the program I'm using, I'm sure I'm doing something it doesn't like.
First off, the PIC 8pin, 6pin devices use GPIO,0, GPIO,1,.. instead of PortA,1, PortA,2....etc. So unless the compiler is somehow doing the conversion for you? Sometime you will have to look at the compiler manual/docs, data sheets, or failing that, search out an example using your particular device and compiler.
P.S. The 12f629 is in the same family as the popular 12f675, so code for that should work with the 12f629.
First off, the PIC 8pin, 6pin devices use GPIO,0, GPIO,1,.. instead of PortA,1, PortA,2....etc. So unless the compiler is somehow doing the conversion for you? Sometime you will have to look at the compiler manual/docs, data sheets, or failing that, search out an example using your particular device and compiler.
P.S. The 12f629 is in the same family as the popular 12f675, so code for that should work with the 12f629.
Thanks for the code, I'll give that a shot when I get home. I didn't try and run it in MPLAB, I just didn't care for the IDE. Anyhow, thanks for the help, that bit of code explains alot.
Thanks everyone, I got it working. In the MPLAB Project Wizard I set it as using a 12F629, but used the BoostC 16 Series compiler. Everything from there on worked perfectly. ^_^
Now though, I have a question about looping. I know the mcu needs to be intentionally stuck in an infinite loop, correct? In a simple program like that one, it's clearly looped by the "while" statement. However, if in a more complicated program, several other functions take place before the "void main", will the while loop still be in effect?
Sorry if that sounds a little cloudy, it's just weird to phrase correctly.
Sorry for the double posts and whatnot, but I have another question and my internet time is limited.
I've got the 12F629 working for the project I needed it for, so I'm onto something else. Now, I'm working on using a 16F882. However, I'm having problems with the coding for it.
Just so I can get an idea of the 16F882's structure, could someone post a blinking LED program for it?
It's a 14 bit device and uses the same core as all others, the 16F628 examples in my tutorials will work with VERY minor changes - just compare the two datasheets.
This has some good C code it for a pickit1 it use 12f675 but all you change for most of them is 12f675 to 12f629 inc and lkr.**broken link removed** down load the one that is All lessons
12f629 doesn't have analog-to-digital converter I thought it did but it don't
I used the same Hex on both chips lol for a blinky
Not to say it wrong Mike I bet you been playing with the 12f683 I love that chip
I missed that Thanks for the help Mike I have a door lock Thanks to you and digg He showed me how to use arrays better. I think I like C better then basic. Thought he was still using the 12f629. Man I hope some day I can pop clean
code out like you can Mike . My thing is I want to put the horse behind the cart. Still need to work on flow