Anda di halaman 1dari 2

E3 252 Assignment 1

1. Reading the data sheet of dsPIC30F4011

• What is the size of the data memory, that the programmer can use to store 1 byte (8 bits)
size variables? Note, this does not include the RAM space occupied by the special function
registers (SFR) like WREG etc. What is the first and the last address (16 bits).
• What is the size of the user program memory in terms a) number of program bytes (12
bits) b) number of 1 word long instructions and 3) 2 word long instructions. What is the
first and the last address (24 bits)?
• How many working registers are there?

2. Hardware connection of dsPIC30F4011

• There is a 15V power supply to your board, select a linear regulator or SMPS (manufac-
turer’s part number: MFPN) that will provide power to your DSC, make sure that the
regulator is capable of supplying the necessary current, when VDD = 5V and operating
speed is 30M IP S. Add necessary decoupling capacitances (MFPN and value).
• Select the pull up resistance (value and power rating) and a push-button switch (MFPN) for
the MCLR pin. To avoid voltage spikes below VSS , you may need to put another resistance
(Data sheet page 177).
• For high speed operation, select an external crystal oscillator (XT, XTL and HS mode) ,
10M Hz (MFPN) as a primary oscillator, design the required capacitances and resitances
(values). Note, that you can also use an external clock source (EC and ECIO mode) as
primary source. For low cost and less time critical and low frequency operation you can
even program the internal primary oscillator with an external RC network (ERC, ERCIO).
You can also enable an internal secondary crystal oscillator. This will provide a 32 kHz
clock for low power mode operation. You can also select an internal fast oscillator (FRC, 7.2
MHz) as your clock resource. There is a internal 512 kHz clock, LPRC, used during power
up etc. Read about the PLL, clock switching, fail safe clock monitor and programmable
post scalar. Refer to the section 7 of family reference manual and study figure 7.1.
• Draw a schematic showing the above hardware connections, for the DSC show only the
relevant pins.
3. Software configuration of dsPIC30F4011

• In order to initialize the DSC, you need to set four 24 bit configuration registers located
in the ROM (a part that is not accessed by the program counter). Refer to the section 24
of family reference manual The first one is FOSC. This is the clock configuration register,
set it such that a) clock switching and fail safe clock monitoring is disabled, b) primary
oscillator external 10M Hz crystal (XT) c) PLL x4. What is the address of FOSC?
• Configure FWDT to disable the watch dog timer.
• Configure FBORPOR to enable MCLR and disable brown out reset.
• Configure FGS to disable any protection of the user program memory.

5. Programming a peripheral

• This DSC has a large number of I/O pins that can be configured, either as input or output.
Note that most of these I/O pins are multiplexed with other peripherals. Study the TRISx,
PORTx and LATx registers (refer data sheet and the family reference manual).

6. Programming: Getting started

• Do the software initialization by properly setting the configuration registers in main.c.


Include p30f4011.h in this file. Open this file and see how SFRs are defined in structure
format.
• Initialize a GPIO port (setting up the directions) by calling a function at the beginning of
main function. Define this function in another .c file say init gpio.c.
• In the main function toggle a GPIO port, after completion of a for loop. Write this loop
in a infinte do while loop. Measure the frequency of the signal measured at the output
port. Change the frequency by changing the limits of the for loop. Check the assembly
code generated by the assembler.
• Your main.c should look like the following
# include <p30f4011.h.>
FOSC(); // configuration registers
// declaration of global variables and function prototypes happen here
void main (void)
{ // your code goes here }

Anda mungkin juga menyukai