Commit | Line | Data |
---|---|---|
bba33fe1 JM |
1 | This project is a general template file for the PIC12 Family of |
2 | microcontrollers. It's purpose is to provide a project shell for users to | |
3 | get started designing their own applications. Final qualification and testing | |
4 | of this project is left to the user. | |
5 | ||
6 | ADVANCED USER TIP | |
7 | ||
8 | From the main menu, refer to the Task list by going to Window > Tasks (Ctrl+6). | |
9 | As long as the task window is not configured to filter out any tasks, | |
10 | the getting started TODO list embedded in this project will be displayed. | |
11 | ||
12 | Make sure the 'Show tasks for the main project and for the open projects which | |
13 | depend on it' option is selected on the left hand side of the Tasks window so | |
14 | that tasks related to other projects are not active. | |
15 | ||
16 | HOW TO ADD YOUR OWN CODE TO A TEMPLATE | |
17 | ||
18 | STEP 1 | |
19 | ||
20 | First install the appropriate C compiler if you have not done so already. | |
21 | ||
22 | See www.microchip.com/compilers | |
23 | ||
24 | Next, build this project by clicking the Clean and Build Icon (the hammer and | |
25 | broom symbol) in the MPLAB X IDE Toolbar. If this project builds, then you are | |
26 | ready to make changes for your own application. If the project does not build, | |
27 | you need to troubleshoot why the project does not build before moving on. | |
28 | ||
29 | STEP 2 | |
30 | ||
31 | Embed your device's configuration bits into the code. Instructions for this | |
32 | are commented in configuration_bits.c | |
33 | ||
34 | STEP 3 | |
35 | ||
36 | Unless interrupts are not used in your application, fill in the interrupt | |
37 | vector code. Code stubs are provided in interrupts.c. Check the device | |
38 | datasheet to confirm that you are servicing all the relevant enabled | |
39 | interrupts in your application within the ISR. Note that it is important | |
40 | to check interrupt flags in sequence within one conditional statement to | |
41 | avoid interrupt contention which could result in corrupting the interrupt | |
42 | context. | |
43 | ||
44 | STEP 4 | |
45 | ||
46 | Define system parameters such as the system operating frequency in system.h. | |
47 | ||
48 | If your device stores an oscillator calibration value at the end of program | |
49 | memory, incorporate the _READ_OSCCAL_DATA() function in system.c. The device | |
50 | datasheet will tell you if calibration data is stored at the end of the | |
51 | device memory. | |
52 | ||
53 | Add system level functions to system.h and system.c. For example, if | |
54 | you want a function to determine the reset source of the device to know if you | |
55 | need to backup data, do an oscillator switch, enter a low power mode, etc... | |
56 | these types of functions may be added to system.c and prototypes can go in | |
57 | system.h. | |
58 | ||
59 | STEP 5 | |
60 | ||
61 | Add user level functions to user.h and user.c. User level functions are | |
62 | functions that initialize I/O, initialize user peripherals like the ADC, | |
63 | compute user algorithms, perform calculations on sampled user data, and so on. | |
64 | User function prototypes and macros may be placed in user.h, and user | |
65 | functions themselves may go in user.c | |
66 | ||
67 | STEP 6 | |
68 | ||
69 | Add code to main.c on the line that says <INSERT USER APPLICATION CODE HERE>. | |
70 | For example, here you would call functions in user.c or system.c, or possibly | |
71 | setup your own state machine or primary code loop. | |
72 | ||
73 | Global variables may be added to main.c as well. As a general practice, macros | |
74 | and prototypes may go in header files, but variable declarations should not | |
75 | go in .h files. Variable declarations should be placed in .c files. | |
76 | ||
77 | STEP 7 | |
78 | ||
79 | Design the rest of your application. Add new files to the application, and | |
80 | test the finished product. | |
81 | ||
82 | STEP 8 | |
83 | ||
84 | Document what the project does and include other project information in | |
85 | project_information.txt. | |
86 |