Friday, May 28, 2021

Beginning dsPIC30F1010 coding using XC16

Microchip dsPIC30F1010 is a 16-bit micro-controller, targeting for Switch Mode Power Supply (SMPS) Digital Signal Controller (DSC). It comes with many features that I don't show them all here. It has DSP (Digital Signal Processor) engine. It's 10-bit ADC module is able to convert analog signal up to 2Msps. Central Processing Unit (CPU) executes up to 30MIPS.

Start dsPIC30F1010 coding using XC8

dsPIC30F1010 reference image

It has DIP and SMD packages options. DIP package is friendly for breadboard prototyping. I choose a 28-pin SMD package.

Start dsPIC30F1010 coding using XC16

Pin diagrams of dsPIC30F1010

XC16 compiler is a C compiler developed by Microchip Technology. It has a free version that allow the programmer to code without code size limitation. Another C compiler for this 16-bit device is MikroC for dsPIC. However MikroC has code size limitation of 2kB of program space. MikroC has many library functions including peripheral libraries and external device interface libraries. Here I select XC16 v1.32 and MPLABX IDE v1.51. 

To get started I select pin RE5 of Port E to toggle at the rate of 500mS. The device will operate using its internal fast RC oscillator (FRC) with the nominal frequency of 15MHz at +5V DC supply voltage. Main C program shows below.

/*
 * Blinking dsPIC30F1010 using XC16 
 * in MPLABX IDE
 */
#include <p30F1010.h>
#include "config.h"

/*Nominal internal fast oscillator frequency of 15MHz*/
#define FCY 15000000UL
#include <libpic30.h>

void main(void){
    /*Additionaly select the maximum nominal frequency of 15MHz*/
    OSCTUNbits.TUN=0x07;
    /*Clear I/O of PORTE*/
    PORTE=0x0000;
    LATE=0x00000;
    /*PORTE direction as output*/
    TRISE=0x0000;
    while(1){
        /*Toggling RE5*/
        LATEbits.LATE5^=1;
        /*Wait for 0.5 second*/
        __delay_ms(500);
    }
}

It need configuration setting that store in another C header file "config.h" within project directory.

// DSPIC30F1010 Configuration Bit Settings

#include <p30Fxxxx.h>

// FBS
#pragma config BWRP = BWRP_OFF          // Boot Segment Write Protect (Boot Segment may be written)
#pragma config BSS = NO_BOOT_CODE       // Boot Segment Program Flash Code Protection (No Boot Segment)

// FGS
#pragma config GWRP = GWRP_OFF          // General Code Segment Write Protect (General Segment may be written)
#pragma config GSS = GSS_OFF            // General Segment Code Protection (Disabled)

// FOSCSEL
#pragma config FNOSC = FRC              // Oscillator Mode (Internal Fast RC (FRC))

// FOSC
#pragma config POSCMD = PRIOSC_OFF      // Primary Oscillator Source (Primary Oscillator Disabled)
#pragma config OSCIOFNC = OSC2_IO       // OSCI/OSCO Pin Function (OSCO pin has digital I/O function)
#pragma config FRANGE = FRC_HI_RANGE    // Frequency Range Select (High Range)
#pragma config FCKSM = CSW_FSCM_OFF     // Clock Switching and Monitor (Sw Disabled, Mon Disabled)

// FWDT
#pragma config WDTPS = WDTPOST_PS32768  // Watchdog Timer Postscaler (1:32,768)
#pragma config FWPSA0 = WDTPRE_PR128    // WDT Prescaler (1:128)
#pragma config WWDTEN = WINDIS_OFF      // Watchdog Timer Window (Non-Window mode)
#pragma config FWDTEN = FWDTEN_OFF      // Watchdog Timer Enable (Disable)

// FPOR
#pragma config FPWRT = PWRT_128         // POR Timer Value (128ms)

// FICD
#pragma config ICS = ICS_PGD            // Comm Channel Select (Use PGC/EMUC and PGD/EMUD)

// FUID0

// FUID1

Its schematic diagram is shown below.

Start dsPIC30F1010 coding using XC16
Schematic Diagram

Click here to download its zip file.

Start dsPIC30F1010 coding using XC16

XC16 in MPLABX IDE

Start dsPIC30F1010 coding using XC16

Circuit wiring on breadboard

I bought an SMD version of dsPIC30F1010. It was solder on SMD to DIP adapter that will be pinned on breadboard. As we have seen on the figure above, dsPIC30F1010 is placed on breadboard. ICSP adapter of PICKIT 2 connects to this microcontroller for in system programming and powering via USB bus. The controller operates at +5V from USB bus. It does not require an external crystal oscillator, as its internal fast RC oscillator is used.

 


No comments:

Post a Comment

Search This Blog

Labels

25AA010A (1) 8051 (7) 93AA46B (1) ADC (30) Analog Comparator (1) Arduino (15) ARM (6) AT89C52 (7) ATMega32 (56) AVR (57) CCS PICC (28) DAC (1) DHT11 (2) Display (105) Distance Sensor (3) DS18B20 (3) dsPIC (2) dsPIC30F1010 (2) EEPROM (5) Environment Sensor (4) esp8266 (1) I2C (29) Input/Output (67) Interrupt (19) Keil (5) Keypad (10) LCD (47) Master/Slave (1) MAX7221 (1) MCP23017 (5) MCP23S17 (4) Meter (3) MikroC (2) Motor (15) MPLABX (71) Nokia 5110 LCD (3) OLED (2) One-Wire (6) Oscillator (8) PCB (6) PCD8544 (3) PCF8574 (5) PIC (107) PIC12F (2) PIC16F628A (2) PIC16F630 (1) PIC16F716 (3) PIC16F818 (10) PIC16F818/819 (2) PIC16F84A (15) PIC16F876A (1) PIC16F877A (9) PIC16F88 (1) PIC16F887 (60) PIC18 (19) PIC18F1220 (4) PIC18F2550 (3) PIC18F4550 (12) PWM (11) RTC (8) Sensor (10) SH1106 (1) Shift Register (11) Shift Registers (3) SPI (24) STM32 (6) STM32 Blue Pill (6) STM32CubeIDE (6) STM32F103C8T6 (6) SysTick (3) temperature sensor (11) Thermometer (21) Timer/Counter (31) TM1637 (2) UART (7) Ultrasonic (4) Voltmeter (7) WDT (1) XC16 (2) XC8 (94)