Hot!Basic program for dsPIC33EP256MC504 on MCP8025 Development board.

Page: 12 > Showing page 1 of 2
Author
litunbls
Junior Member
  • Total Posts : 107
  • Reward points : 0
  • Joined: 2016/12/28 10:29:43
  • Location: 0
  • Status: offline
2018/01/12 14:01:39 (permalink)
0

Basic program for dsPIC33EP256MC504 on MCP8025 Development board.

Dear all, i have got MCP8025 motor driver development board
 
 
I am triang to do a basic program as follows
// DSPIC33EP256MC504 Configuration Bit Settings

// 'C' source line config statements

// FICD
#pragma config ICS = PGD1 // ICD Communication Channel Select bits (Communicate on PGEC1 and PGED1)
#pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled)

// FPOR
#pragma config ALTI2C1 = OFF // Alternate I2C1 pins (I2C1 mapped to SDA1/SCL1 pins)
#pragma config ALTI2C2 = OFF // Alternate I2C2 pins (I2C2 mapped to SDA2/SCL2 pins)
#pragma config WDTWIN = WIN50 // Watchdog Window Select bits (WDT Window is 50% of WDT period)

// FWDT
#pragma config WDTPOST = PS32768 // Watchdog Timer Postscaler bits (1:32,768)
#pragma config WDTPRE = PR128 // Watchdog Timer Prescaler bit (1:128)
#pragma config PLLKEN = ON // PLL Lock Enable bit (Clock switch to PLL source will wait until the PLL lock signal is valid.)
#pragma config WINDIS = OFF // Watchdog Timer Window Enable bit (Watchdog Timer in Non-Window mode)
#pragma config FWDTEN = ON // Watchdog Timer Enable bit (Watchdog timer always enabled)

// FOSC
#pragma config POSCMD = NONE // Primary Oscillator Mode Select bits (Primary Oscillator disabled)
#pragma config OSCIOFNC = OFF // OSC2 Pin Function bit (OSC2 is clock output)
#pragma config IOL1WAY = ON // Peripheral pin select configuration (Allow only one reconfiguration)
#pragma config FCKSM = CSDCMD // Clock Switching Mode bits (Both Clock switching and Fail-safe Clock Monitor are disabled)

// FOSCSEL
#pragma config FNOSC = FRCDIVN // Oscillator Source Selection (Internal Fast RC (FRC) Oscillator with postscaler)
#pragma config PWMLOCK = ON // PWM Lock Enable bit (Certain PWM registers may only be written after key sequence)
#pragma config IESO = ON // Two-speed Oscillator Start-up Enable bit (Start up device with FRC, then switch to user-selected oscillator source)

// FGS
#pragma config GWRP = OFF // General Segment Write-Protect bit (General Segment may be written)
#pragma config GCP = OFF // General Segment Code-Protect bit (General Segment Code protect is Disabled)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include "MCP802X.h" // must be first include for FCY
#include <xc.h>
#include <dsp.h>
#include <stdio.h>
#include <stdlib.h>

/*
 *
 */

// Select Internal FRC at POR
//_FOSCSEL(FNOSC_FRC & IESO_OFF);
// Enable Clock Switching and Configure Primary Oscillator in XT mode
//_FOSC(FCKSM_CSECMD & OSCIOFNC_OFF & POSCMD_NONE);
int main()
{
// Configure PLL prescaler, PLL postscaler, PLL divisor
PLLFBD=63; // M=65
CLKDIVbits.PLLPOST=0; // N2=2
CLKDIVbits.PLLPRE=1; // N1=3
// Initiate Clock Switch to FRC oscillator with PLL (NOSC=0b001)
__builtin_write_OSCCONH(0x01);
__builtin_write_OSCCONL(OSCCON | 0x01);
// Wait for Clock switch to occur
while (OSCCONbits.COSC!= 0b001);
// Wait for PLL to lock
while (OSCCONbits.LOCK!= 1);


    TRISAbits.TRISA4=0;
    LATAbits.LATA4=1;
    TRISBbits.TRISB10=0; TRISBbits.TRISB11=0; TRISBbits.TRISB12=0; TRISBbits.TRISB13=0;
    LATBbits.LATB10=1;LATBbits.LATB11=1;LATBbits.LATB12=1;LATBbits.LATB13=1;
        while(1)
          {}
        
        
    return 0;
}

I use the Internal Fast RC oscillator.
But it is not working.
Am I missing something....?
#1

20 Replies Related Threads

    litunbls
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2016/12/28 10:29:43
    • Location: 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/12 14:03:00 (permalink)
    #2
    du00000001
    Just Some Member
    • Total Posts : 2019
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: online
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/12 14:35:24 (permalink)

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #3
    jtemples
    Super Member
    • Total Posts : 10854
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/12 14:50:31 (permalink)
    0
    You have the watchdog timer enabled.
    #4
    litunbls
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2016/12/28 10:29:43
    • Location: 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/12 21:08:40 (permalink)
    0
    The example code is showing error. Not compiling.
    I have set the watchdog timer off.
     
    Here i just want to program the dsPIC and also I am able to flash: But somehow nothing is working.
    Is there anything wrong?

     

     
    #5
    du00000001
    Just Some Member
    • Total Posts : 2019
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: online
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 03:22:24 (permalink)
    5 (1)
    The example code is showing error.

    Honestly? Make "error" disappear prior starting to modify the code!

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #6
    litunbls
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2016/12/28 10:29:43
    • Location: 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 04:32:06 (permalink)
    0
    Thank You.
    I have changed the Osc configuration to #pragma style(Configuration bits set).
    But still I get the following error while compiling the example.
     
    make[2]: *** No rule to make target 'E:/MPLABX/C_Compilers/XC16/lib/libdsp-elf.a', needed by 'dist/default/production/MCP8025_Evaluation_Board.production.hex'. Stop.
    make[2]: *** Waiting for unfinished jobs....

     
    In my opinion the MCP8025_Evaluation_Board.production.hex file should be generated after compilation.
    #7
    RISC
    Super Member
    • Total Posts : 5240
    • Reward points : 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 04:51:46 (permalink)
    0
    Hi,
    From your error message it shows that MPLAB X cannot find the dsp library.
    On which drive did you install the Xc16 compiler ?
    As it seems your files are on the E:\ drive it might be the reason whiy it does not find the DSP libraries 
    Please follow this thread : http://www.microchip.com/forums/m822301.aspx
    Regards
     
    #8
    litunbls
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2016/12/28 10:29:43
    • Location: 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 05:16:24 (permalink)
    0
    RISC
    Hi,
    From your error message it shows that MPLAB X cannot find the dsp library.
    On which drive did you install the Xc16 compiler ?
    As it seems your files are on the E:\ drive it might be the reason whiy it does not find the DSP libraries 
    Please follow this thread : http://www.microchip.com/forums/m822301.aspx
    Regards
     


    I install the Xc16 compiler C:\Program Files (x86)\Microchip\xc16\v1.31
    And my project is here C:\Users\SKUMARSA\Documents\MicrochipBLDC\MCP8025_Evaluation_Board_08SEP2014_R1
    #9
    litunbls
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2016/12/28 10:29:43
    • Location: 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 05:36:15 (permalink)
    0
    More over i find following note in user manual 50002307A
     
    Note: Note that the following project options may need to be changed for the
    computer being used to build the firmware:
    1• Add Library libdsp-elf.a located in XC16 ???\src\Libdsp\lib
    directory.
    2• Add XC16-as ASM Include Directory in XC16 ???\src\Libdsp\asm.
    3• Set Hardware tool to “ICD 3”, “REAL ICE”, or “PICkit3”.
     
    I find point no 1. is ok. But what is point no 2.? 
    #10
    RISC
    Super Member
    • Total Posts : 5240
    • Reward points : 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 07:23:42 (permalink)
    3 (2)
    Hi,
    Can you show again your error message.
    In post #7 it was :

     
    make[2]: *** No rule to make target 'E:/MPLABX/C_Compilers/XC16/lib/libdsp-elf.a', needed by 'dist/default/production/MCP8025_Evaluation_Board.production.hex'. Stop.
     
    make[2]: *** Waiting for unfinished jobs....

    [/code]
     
    This clearly shows that it is searching on the drive E:\ (not C:\)...
    Have you installed MPLAB X and / or XC16 on the E:\ drive ????
    If so you should adjust the paths...
    (you can check this in MPLAB X build tools tab)
    Regards
     
    post edited by RISC - 2018/01/13 07:25:41
    #11
    litunbls
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2016/12/28 10:29:43
    • Location: 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 08:12:47 (permalink)
    0
    CLEAN SUCCESSFUL (total time: 103ms)
    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    make[1]: Entering directory 'C:/Users/SKUMARSA/Documents/MicrochipBLDC/MCP8025_Evaluation_Board_08SEP2014_R1/MCP8025_Evaluation_Board'
    make -f nbproject/Makefile-default.mk dist/default/production/MCP8025_Evaluation_Board.production.hex
    make[2]: Entering directory 'C:/Users/SKUMARSA/Documents/MicrochipBLDC/MCP8025_Evaluation_Board_08SEP2014_R1/MCP8025_Evaluation_Board'
    make[2]: *** No rule to make target 'E:/MPLABX/C_Compilers/XC16/lib/libdsp-elf.a', needed by 'dist/default/production/MCP8025_Evaluation_Board.production.hex'. Stop.
    make[2]: *** Waiting for unfinished jobs....
    "C:\Program Files (x86)\Microchip\xc16\v1.31\bin\xc16-gcc.exe" source/MCP8025_Evaluation.c -o build/default/production/source/MCP8025_Evaluation.o -c -mcpu=33EP256MC504 -MMD -MF "build/default/production/source/MCP8025_Evaluation.o.d" -mno-eds-warn -g -omf=elf -DXPRJ_default=default -no-legacy-libc -mlarge-data -O0 -msmart-io=1 -Wall -msfr-warn=off
    "C:\Program Files (x86)\Microchip\xc16\v1.31\bin\xc16-gcc.exe" source/uart.c -o build/default/production/source/uart.o -c -mcpu=33EP256MC504 -MMD -MF "build/default/production/source/uart.o.d" -mno-eds-warn -g -omf=elf -DXPRJ_default=default -no-legacy-libc -mlarge-data -O0 -msmart-io=1 -Wall -msfr-warn=off
    make[2]: Leaving directory 'C:/Users/SKUMARSA/Documents/MicrochipBLDC/MCP8025_Evaluation_Board_08SEP2014_R1/MCP8025_Evaluation_Board'
    nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
    make[1]: Leaving directory 'C:/Users/SKUMARSA/Documents/MicrochipBLDC/MCP8025_Evaluation_Board_08SEP2014_R1/MCP8025_Evaluation_Board'
    nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
    make[1]: *** [.build-conf] Error 2
    make: *** [.build-impl] Error 2

    BUILD FAILED (exit value 2, total time: 1s)

     
    I do not have E drive at all in my PC.
    I also checked in this project properties that XC16 is installed in C drive only.
     
     
    #12
    RISC
    Super Member
    • Total Posts : 5240
    • Reward points : 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 08:41:58 (permalink)
    5 (1)
    Hi,
    If you look at the error message of your post #12, your project is again searching in drive E:\ .... :

    'C:/Users/SKUMARSA/Documents/MicrochipBLDC/MCP8025_Evaluation_Board_08SEP2014_R1/MCP8025_Evaluation_Board'
    make[2]: *** No rule to make target 'E:/MPLABX/C_Compilers/XC16/lib/libdsp-elf.a', needed by 

    It means there is a path somewhere or maybe in the project which searches on drive E:\
    Look at the project tree or the project properties (compiler, linker,...) to find this path and correct it
    Regards
    #13
    litunbls
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2016/12/28 10:29:43
    • Location: 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 10:10:41 (permalink)
    0
    Thanks RISC & du00000001 .Problem solved :) . I manually removed the lib file and added again from the C drive.
     
    I have earlier worked with dsPIC33EP512MU806 but for the fist time i am using a library file in this PIC project. can you explain why i need this libdsp-elf.a file.
     
     
    #14
    RISC
    Super Member
    • Total Posts : 5240
    • Reward points : 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 10:44:42 (permalink)
    0
    Hi,
    This project uses special libraries which take advantage of the special DSP instructions.
    ANSI C compilers are not allowed to use special enhancements to architectures because the code must be portable.
    In dsPIC the DSP instructions allow a significant acceleration of DSP algorithms but they need to be added as libraries
    Regards
     
    #15
    litunbls
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2016/12/28 10:29:43
    • Location: 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 10:54:10 (permalink)
    0
    Thanks.
    Least but not least,  can you or the admin, please allow me to post the picture in forum.
    Thanks again.
    #16
    RISC
    Super Member
    • Total Posts : 5240
    • Reward points : 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 12:05:25 (permalink)
    0
    Hi,
    I have the same issue as you ;=)
    Generally I cannot post pictures because the forum software is weak...
    Regards
    #17
    rodims
    Super Member
    • Total Posts : 1312
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 13:17:35 (permalink)
    1 (1)
    Somtimes it is possible sometimes not. I never found a real logic so far. Sometimes it is possible at least to attach an image to a post, but not to embed it in the text. Better than nothing.
     
    If nothing else works, you can place your picture on e.g. imgur.com or similar hosters and place a link to that image here in the forum, however this still requires the readers to click on it.
     
    https://imgur.com/a/PWc21
     
    Imgur (e.g)  also provides the direct link to the image contained in the above URL, which you can embed.
     
    https://i.imgur.com/KEccoVy.jpg
     
    If you place this as "image URL" into the Insert/Edit Image dialog box, then you have this image in location.

     
    If I try to do the same, but instead attach the image to the Microchip forum post, then I usually fail to embed the image in the text (and receive some error message). 
    #18
    litunbls
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2016/12/28 10:29:43
    • Location: 0
    • Status: offline
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 13:42:24 (permalink)
    0
    A picture is worth a thousand words. I mean screenshots, oscilloscope picture, display, pcb schematic etc.
     
    I had tried https://imgur.com/a/PWc21. still it shows Access Denied.
    #19
    du00000001
    Just Some Member
    • Total Posts : 2019
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: online
    Re: Basic program for dsPIC33EP256MC504 on MCP8025 Development board. 2018/01/13 14:44:13 (permalink)
    0
    Every now an then the forums get "their days", working even worse than "normally".
    I haven't yet found out whether these days correlate with the moon phase, ambient temperature (where?) or humidity.
     
    Seems we have to somehow cope with that...

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2018 APG vNext Commercial Version 4.5