tterev3's PIC quickstart guide

The link in the OP for the XC8 compiler is broken. For anyone wondering, here is the download link for the XC8 compiler:

It's on the left hand sidebar under Downloads > XC8 > Windows.

EDIT: other than forgetting to define my batt_save mode, it compiled without issues. Now I just play the waiting game for my PICs to arrive :)

Yes, the Attiny10 has very similar specs to the 10F322. I have used both parts successfully for applications like this

Thanks for your prompt reply.
I am a dummy to program the MCU. I would like to ask if I define PB0 for tactile switch or touch switch, PB1 for PWM output and PB2 for voltage monitor ADC of the attiny 10 is on the right way?

The pin configuration depends on your software. The software can define the pin functions in many different ways to fit your needs. Are you writing software yourself or using existing code? Are you trying to make it work with an existing PCB or making a new one?

I am thinking to try writing my own code and am learning from the existing code. The PCB will be a new one. The reason for that pin configuration is that except VCC, GND and RST. There have 3 I/O pins left. All of the 3 pins can be defined for ADC. The OC0A and OC0B are located at PB0 and PB1 which seem to be a good choice for PWM and Q-Touch. If I am wrong, please correct me. I am really don’t know how to write program.
I am appreciated that you can give me some examples to follow. I noted that the attiny10 is quite different from the 13A and other tiny series. For example, it is 8-bit ADC and 16-bit Timer/Counter. Open source C code for attiny10 is difficult to find.

Hi Microa,
Since this thread is devoted to PIC, I started another one to show an example implementing the same thing on ATTiny10:
ATTiny starter code

Hey guys I need some help, remember I’m pretty much computer illiterate…

I have MPLAB X installed along with the XC8 compiler, I even have it opened up and the chip I want to use selected (12F1822) but that’s as far as I can make it, step 7. In what places do I add the HTC.H and P12F1822.h files? I just threw them in there randomly and pressed build and it actually did something (that surprised me lol) but didnt work, what do I do?

make[2]: * [build/default/production/D10 v1.obj] Error 1
make[1]: * [.build-conf] Error 2
make: * [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 719ms)

I can’t be of much help, MPLAB X sucks so I still use 8. I think you can get away with ignoring the include files and not linking them in, not sure though. In my opinion your best option is to uninstall X and get 8

I second tterev3's statement. I'm using MPLAB 8 IDE because when I tried X is was just stupid.

8 is older so there is a lot more user generated support material out there so its a lot easier to find answers via Google. The last release of MPLAB 8 was 8.92 and is available here: http://www.microchip.com/pagehandler/en-us/devtools/dev-tools-parts.html

I can tell you how to do everything you asked about for X....but in 8 lol.

- Matt

Ok guys got X removed and 8 installed (note if you install X first you will also have to remove XC8 as well, the version of XC8 installed with X wont work with eight, [stupid smileys] ), I see how you add the files now, thats much simpler however my first attempt I still get an error. I'm trying to use code tterev3's blog (his D10 code) on a 12f1822, I added the htc.h and the PIC12F1822.h files as well as the source code I d/l'd from his blog site, its a .ASM file, do I need to change its extension?

edit using V8.92 and XC8 V1.32 on a vista 64bit machine.

Build C:\Users\Dan\Documents\MPLAB\D10\D10 for device 12F1822
Using driver C:\Program Files\Microchip\xc8\v1.32\bin\xc8.exe

Make: The target "C:\Users\Dan\Documents\MPLAB\D10\D10 v1.p1" is out of date.
Executing: "C:\Program Files\Microchip\xc8\v1.32\bin\xc8.exe" -C "C:\Users\Dan\Documents\MPLAB\D10\D10 v1.ASM" -q --chip=12F1822 -P --runtime=default --opt=default -N-1 -D__DEBUG=1 -g --asmlist "–errformat=Error [%n] %f; %l.%c %s" "–msgformat=Advisory[%n] %s" "–warnformat=Warning [%n] %f; %l.%c %s"
Error [141] C:\Users\Dan\Documents\MPLAB\D10\D10 v1.ASM; 5.24 can't open include file "p12F1822.inc": No such file or directory
(908) exit status = 1

********** Build failed! **********

Looks like you have the wrong files included. If you look at the top of the source file, you can see the list of what you need to include. They are:

    #include    <p12F1822.inc> ; processor specific variable definitions
    #include    <instructions.inc>

Don't mix up the .h and the .inc, and don't add anything like htc.h (that is for a C compiler, this is written in assembly so you're not using the compiler). If you don't have my instructions.inc macro file, you can get it here

Where do I find those files? neither are in xc8>v1.32>include. edit: I went to add file and typed in those 2 files (selecting the entire XC8 folder as the directory) and it looked like it added them (listed under Other Files) but didnt work:

Build C:\Users\Dan\Documents\MPLAB\D10\D10 for device 12F1822 Using driver C:\Program Files\Microchip\xc8\v1.32\bin\xc8.exe 

Make: The target "C:\Users\Dan\Documents\MPLAB\D10\D10 v1.p1" is out of date.
Executing: "C:\Program Files\Microchip\xc8\v1.32\bin\xc8.exe" -C "C:\Users\Dan\Documents\MPLAB\D10\D10 v1.ASM" -q --chip=12F1822 -P --runtime=default,+clear,+init,-keep,+osccal,-download,-resetbits,-stackcall,-config,+clib,+plib --opt=default,+asm,-debug,-speed,+space,9 --warn=0 -N255 -D__DEBUG=1 -Bsmall --double=32 --float=32 --cp=16 --addrqual=ignore -g --asmlist "–errformat=Error [%n] %f; %l.%c %s" "–msgformat=Advisory[%n] %s" "–warnformat=Warning [%n] %f; %l.%c %s"
Error [141] C:\Users\Dan\Documents\MPLAB\D10\D10 v1.ASM; 5.24 can't open include file "p12F1822.inc": No such file or directory (908) exit status = 1 ********** Build failed! **********

They won’t be in the xc8 folder since we’re not using the compiler, they’ll be in the MPASM folder (the assembler)

Ok got the chip file but the instructions.inc file is not coming up (when I type it in it comes up but has “(file not found)” next to it in the list.

edit: also since I’m not using the compiler do I still push the same button? or do I need to start this whole project over without the XC8?

See my earlier post (#59)

Yes, same button

I can’t help but wonder if it’d be easier to just use a Makefile and a command line. GUI front-ends often seem harder somehow.

I’m looking forward to doing more firmware in the near future… and some reviews. I can almost see the light at the end of the tunnel; my 14-hour work days should be ending in about a week, I think.

Ok D/L’d it and added it to the same directory (MPASM Suite) then hit build and its still giving me an error but the file is there, I found it and selected it, not just typed the name in:

Make: The target "C:\Users\Dan\Documents\MPLAB\D10\D10 v1.p1" is out of date.
Executing: "C:\Program Files\Microchip\xc8\v1.32\bin\xc8.exe" -C "C:\Users\Dan\Documents\MPLAB\D10\D10 v1.ASM" -q --chip=12F1822 -P --runtime=default --opt=default -N-1 -D__DEBUG=1 -g --asmlist "--errformat=Error   [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s" 
Error   [141] C:\Users\Dan\Documents\MPLAB\D10\D10 v1.ASM; 5.24 can't open include file "p12F1822.inc": No such file or directory
(908) exit status = 1

Are you sure you have the .inc and not the .h?

yes sir, sent you a screen shot via email

If I understand correctly, .h is a traditional C header file with definitions for linking but no function bodies, while the .inc is for code to include inline in the main source file(s)? It has been like 15 years since I used C on a regular basis so I’m a bit rusty, and I always used multiple object files instead of inlining library functions into the primary source file.

It might also be worth double-checking the punctuation used on the includes… <> tells it to search the system devel paths, while “” tells it to search the same directory as the current file. Global vs local. Can’t include a local file with <>’s.