Datasheet
iii
Preface v
1. Overview 1
1.1. Overview of Microcontrollers ............................................................................................... 1
1.2. The dsPIC30F4011 ............................................................................................................ 2
1.3. Building Programs ............................................................................................................. 3
2. First Program - Blink an LED 5
2.1. Creating the project ........................................................................................................... 5
2.2. Editing and Compiling the Source ..................................................................................... 11
2.3. Running the Simulator ...................................................................................................... 14
2.4. Running the program in the dsPIC .................................................................................... 16
2.5. Debugging the program .................................................................................................... 17
2.6. Documenting the program ................................................................................................ 17
3. Configuration Registers 19
4. Timers 21
5. Interrupts 23
6. Liquid Crystal Displays 25
7. The I
2
C Device Routines 27
7.1. I
2
C Device Connections ................................................................................................... 27
7.2. Using the MCP4726 DAC ................................................................................................. 27
7.3. Using the MCP23008 I/O Expander .................................................................................. 28
7.4. Using the MB85RC16V FRAM .......................................................................................... 30
8. The I
2
C Library 31
8.1. The I
2
C Transaction ......................................................................................................... 31
8.2. The I
2
C Control Byte ........................................................................................................ 31
8.3. Sending data to an I
2
C device .......................................................................................... 32
8.4. Reading data from an I
2
C device ...................................................................................... 32
9. Building Libraries 33
10. Analog Inputs 35
11. Reading Switches 37
12. Pulse Width Modulation 39
13. Serial Output 41
14. Serial Input 43
15. Unusual Devices 45
A. Installing MPLAB-X 47
B. Setting up a project in MPLAB-X 51
C. The C Language 55
C.1. Introduction ..................................................................................................................... 55
C.2. Identifiers ........................................................................................................................ 56
C.3. Types, Operators and Expressions ................................................................................... 56
C.3.1. Scalar types ......................................................................................................... 56
C.3.2. Array and Pointer types ........................................................................................ 57