Datasheet
Page 4
Page 5
Let’s make a simple “Hello world” example for the
selected microcontroller. First thing embedded
programmers usually write is a simple LED blinking
program. So, let’s do that in a few simple lines of
Basic code.
LED blinking is just turning ON and OFF LEDs that
are connected to desired PORT pins. In order to see
the example in action, it is necessary to connect
the target microcontroller according to schematics
shown on Figure 2-1. In the project we are about
to write, we will use only PORTB, so you should
connect the LEDs to PORTB only.
Priortocreatinganewproject,itisnecessarytodothefollowing:
Step 1: Install the compiler
Install the mikroBasic PRO for dsPIC® compiler from the Product
DVDordownloaditfromtheMikroElektronikawebsite:
http://www.mikroe.com/eng/products/view/229/mikrobasic-pro-for-dspic/
Step 2: Start up the compiler
Double click on the compiler icon in the Start menu, or on your desktop
to Start up the mikroBasic PRO for dsPIC® compiler. The mikroBasic
PROfordsPIC®IDE(IntegratedDevelopmentEnvironment)willappear
on the screen. Now you are ready to start creating a new project.
2. Hardware Connection
DIP 40
VCC
VCC
VCC
VCC
RB8
VCC
GND
RB7
RB6
RB5
RB4
RB3
RB2
RB1
RB0
MCLR
RC13
RC14
RA11
RD9
RD3
GND
OSC1
OSC2
RF2
RF5
RF4
RF1
RF0
RD1
RD0
RB12
RB11
RB10
RB9
AGND
AVCC
RB7
RB6
RB5
RB4
RB3
RB2
RB1
RB0
RF3
RF6
RD8
RD2
VCC
VCC
GND
dsPIC30F4013
X2
8MHz SEC
C22
22pF
C21
22pF
RB7
RB6
RB5
RB4
RB2
RB1
RB0
RB3
R1
4K7
R5
4K7
R2
4K7
R6
4K7
R3
4K7
R7
4K7
R4
4K7
R8
4K7
LD0
LED
LD4
LED
LD1
LED
LD5
LED
LD2
LED
LD6
LED
LD3
LED
LD7
LED
Figure 2-1:
Hardware connection
schematics