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