la version que utilizo es 4.057. A continuación les cuelgo la librería del dsPIc que utilizo, y primero que a mi parecer le faltan muuuuuchisimas funciones, como la SET_MOTOR_PWM() , SET_DEAD_TIME(), entre otras..... Lei en algun foro que las direcciones de los registros estaban mal hechas pero no se que tan verdad sea esa afirmacion.
Lo de engorroso es porque a mi parecer es mucho más fácil programar el micro con el PIC C que con el C30 o C18 ya que no hay que andar seteando bits para la configuracion de los registros. Por ejemplo. Para configurar el timer1 seria algo como "setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1)". mientras que con el C30 una configuración tipica sería:
T1CON = 0;
TMR1 = 0;
PR1 = Fcy/512;
T1CON = 0x8030;
Cuestión de gustos pues....
//////// Standard Header file for the DSPIC33FJ32MC204 device ////////////////
#device DSPIC33FJ32MC204
#nolist
//////// Program memory: 11264x24 Data RAM: 2048 Stack: 31
//////// I/O: 43 Analog Pins: 9
//////// Fuses: WRTB,NOWRTB,CPBH,CPBS,NOCPB,PROTECTS,NOPROTECT,WRT,NOWRT,FRC
//////// Fuses: FRC_PLL,PR,PR_PLL,NOCKSFSM,CKSFSM,SC,LPRC,OSCIO,NOOSCIO,EC
//////// Fuses: HS,NOPR,WDT,NOWDT,WINDIS,NOWINDIS,WPRES128,WPRES32,WPOSTS1
//////// Fuses: WPOSTS2,WPOSTS3,WPOSTS4,WPOSTS5,WPOSTS6,WPOSTS7,WPOSTS8
//////// Fuses: WPOSTS9,WPOSTS10,WPOSTS11,WPOSTS12,WPOSTS13,WPOSTS14
//////// Fuses: WPOSTS15,WPOSTS16,NOPUT,PUT2,PUT4,PUT8,PUT16,PUT32,PUT64
//////// Fuses: PUT128,XT,FRC_PS,ALTI2C,NOALTI2C,IESO,NOIESO,PROTECTH
//////// Fuses: FRC_DIV_BY_16,IOL1WAY,NOIOL1WAY,DEBUG,NODEBUG,COE,NOCOE,JTAG
//////// Fuses: NOJTAG,ICS0,ICS1,ICS2,ICS3,PWMPIN,NOPWMPIN,HPOL_HIGH
//////// Fuses: HPOL_LOW,LPOL_HIGH,LPOL_LOW
////////
////////////////////////////////////////////////////////////////// I/O
// Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(),
// PORT_x_PULLUPS(), INPUT(),
// OUTPUT_LOW(), OUTPUT_HIGH(),
// OUTPUT_FLOAT(), OUTPUT_BIT()
// Constants used to identify pins in the above are:
#define PIN_A0 5648
#define PIN_A1 5649
#define PIN_A2 5650
#define PIN_A3 5651
#define PIN_A4 5652
#define PIN_A7 5655
#define PIN_A8 5656
#define PIN_A9 5657
#define PIN_A10 5658
#define PIN_B0 5696
#define PIN_B1 5697
#define PIN_B2 5698
#define PIN_B3 5699
#define PIN_B4 5700
#define PIN_B5 5701
#define PIN_B6 5702
#define PIN_B7 5703
#define PIN_B8 5704
#define PIN_B9 5705
#define PIN_B10 5706
#define PIN_B11 5707
#define PIN_B12 5708
#define PIN_B13 5709
#define PIN_B14 5710
#define PIN_B15 5711
#define PIN_C0 5744
#define PIN_C1 5745
#define PIN_C2 5746
#define PIN_C3 5747
#define PIN_C4 5748
#define PIN_C5 5749
#define PIN_C6 5750
#define PIN_C7 5751
#define PIN_C8 5752
#define PIN_C9 5753
////////////////////////////////////////////////////////////////// Useful defines
#define FALSE 0
#define TRUE 1
#define BYTE unsigned int8
#define BOOLEAN int1
#define getc getch
#define fgetc getch
#define getchar getch
#define putc putchar
#define fputc putchar
#define fgets gets
#define fputs puts
////////////////////////////////////////////////////////////////// WDT
// Watch Dog Timer Functions: SETUP_WDT() and RESTART_WDT()
//
// Constants used for SETUP_WDT() are:
#define WDT_ON 1
#define WDT_OFF 0
////////////////////////////////////////////////////////////////// Control
// Control Functions: RESET_CPU(), SLEEP(), RESTART_CAUSE()
// Constants passed into RESTART_CAUSE() are:
#define RESTART_POWER_UP 0x0003
#define RESTART_BROWNOUT 0x0001
#define RESTART_WATCHDOG 0x0010
#define RESTART_SOFTWARE 0x0040
#define RESTART_MCLR 0x0080
#define RESTART_ILLEGAL_OP 0x4000
#define RESTART_TRAP_CONFLICT 0x8000
//
// Constants passed into SLEEP() are:
#define SLEEP_FULL 0 // Default
#define SLEEP_IDLE 1 // Clock and peripherals don't stop
////////////////////////////////////////////////////////////////// INTERNAL RC
// Constants used in setup_oscillator() are:
#define OSC_INTERNAL 32
#define OSC_CRYSTAL 1
#define OSC_CLOCK 2
#define OSC_RC 3
#define OSC_SECONDARY 16
////////////////////////////////////////////////////////////////// Timer
// Timer Functions: SETUP_TIMERx, GET_TIMERx, GET_TIMERxy,
// SET_TIMERx, SET_TIMERxy
// Constants used for SETUP_TIMERx() are:
// (or (via |) together constants from each group)
#define TMR_DISABLED 0x0000
#define TMR_INTERNAL 0xA000
#define TMR_EXTERNAL 0xA002
#define T1_EXTERNAL_SYNC 0xA006 //This only applies to Timer1
#define T1_EXTERNAL_RTC 0xC002 //This only applies to Timer1
#define TMR_DIV_BY_1 0x0000
#define TMR_DIV_BY_8 0x0010
#define TMR_DIV_BY_64 0x0020
#define TMR_DIV_BY_256 0x0030
#define TMR_32_BIT 0x0008 // Only for even numbered timers
/////////////////////////////////////////////////////////// INPUT CAPTURE
// Functions: SETUP_CAPTURE, GET_CAPTURE,
//
// Constants used for SETUP_CAPTURE() are:
#define CAPTURE_OFF 0x0000 // Capture OFF
#define CAPTURE_EE 0x0001 // Capture Every Edge
#define CAPTURE_FE 0x0002 // Capture Falling Edge
#define CAPTURE_RE 0x0003 // Capture Rising Edge
#define CAPTURE_DIV_4 0x0004 // Capture Every 4th Rising Edge
#define CAPTURE_DIV_16 0x0005 // Capture Every 16th Rising Edge
#define CAPTURE_INTERRUPT_ONLY 0x0007 // Interrupt on Rising Edge when in Sleep or Idle
// The following defines can be ORed | with above to configure interrupts
#define INTERRUPT_EVERY_CAPTURE 0x0000 // Interrupt on every capture event
#define INTERRUPT_SECOND_CAPTURE 0x0020 // Interrupt on every second capture event
#define INTERRUPT_THIRD_CAPTURE 0x0040 // Interrupt on every third capture event
#define INTERRUPT_FOURTH_CAPTURE 0x0060 // Interrupt on every fourth capture event
// The following defines can be ORed | with above to select timer
#define CAPTURE_TIMER2 0x0080 // On capture event Timer 2 is captured
#define CAPTURE_TIMER3 0x0000 // On capture event Timer 3 is captured
// The following defines can be ORed | with above to select idle operation mode
#define CAPTURE_HALT_IDLE 0x2000 // Capture module halts during idle mode
#define CAPTURE_CONTINUE_IDLE 0x0000 // Capture module continues during idle mode
/////////////////////////////////////////////////////////// OUTPUT COMPARE
// Functions: SETUP_COMPARE, SET_PWM_DUTY, SET_COMPARE_TIME
//
// Constants used for SETUP_COMPARE() are:
#define COMPARE_OFF 0x0000 // Compare OFF
#define COMPARE_SET_ON_MATCH 0x0001 // Pin from low to high on match
#define COMPARE_CLR_ON_MATCH 0x0002 // Pin from high to low on match
#define COMPARE_TOGGEL 0x0003 // Pin will toggle on every match occurrence
#define COMPARE_SINGLE_PULSE 0x0004 // Pin will generate single pulse on first match
#define COMPARE_CONT_PULSE 0x0005 // Pin will pulse for every match
#define COMPARE_PWM 0x0006 // Compare operates as PWM with fault pin disabled
#define COMPARE_PWM_FAULT 0x0007 // Compare operates as PWM with fault pin enabled
// The following defines can be ORed | with above to select timer
#define COMPARE_TIMER2 0x0000 // Timer 2 is the base timer
#define COMPARE_TIMER3 0x0008 // Timer 3 is the base timer
// The following defines can be ORed | with above to select idle operation mode
#define COMPARE_HALT_IDLE 0x2000 // Compare module halts during idle mode
#define COMPARE_CONTINUE_IDLE 0x0000 // Compare module continues during idle mode
////////////////////////////////////////////////////////////////// ADC
// ADC Functions: SETUP_ADC(), SETUP_ADC_PORTS()
// SET_ADC_CHANNEL(), READ_ADC()
//
// Constants used for SETUP_ADC() are:
// Clock is at ADCS<5:0> of ADCON3 Reg. (0x02A4)
// Tad = (Tcy/2)*(ADCS<5:0>+1)
#define ADC_CLOCK 0x0000 // External
#define ADC_CLOCK_DIV_2 0x0001
#define ADC_CLOCK_DIV_4 0x0003
#define ADC_CLOCK_DIV_8 0x0007
#define ADC_CLOCK_DIV_16 0x000F
#define ADC_CLOCK_DIV_32 0x001F
#define ADC_CLOCK_DIV_64 0x003F
#define ADC_CLOCK_INTERNAL 0x8000 // Internal
// The following may be OR'ed in with the above using |
// Auto-Sample Time bits
#define ADC_TAD_MUL_0 0x0000
#define ADC_TAD_MUL_2 0x0200
#define ADC_TAD_MUL_4 0x0400
#define ADC_TAD_MUL_8 0x0800
#define ADC_TAD_MUL_16 0x1000
#define ADC_TAD_MUL_31 0x1F00
// Constants used in READ_ADC() are:
#define ADC_START_AND_READ 0x07
#define ADC_START_ONLY 0x01
#define ADC_READ_ONLY 0x06
// Constants used in SETUP_ADC_PORTS() are:
// First argument:
// OR together desired pins
#define sAN0 0x0001 //| B0
#define sAN1 0x0002 //| B1
#define sAN2 0x0004 //| B2
#define sAN3 0x0008 //| B3
#define sAN4 0x0010 //| B4
#define sAN5 0x0020 //| B5
#define sAN6 0x0040 //| B6
#define sAN7 0x0080 //| B7
#define sAN8 0x0100 //| B8
#define NO_ANALOGS 0 // None
#define ALL_ANALOG 0xFFFFFFFF //
// Optional Second argument:
#define VSS_VDD 0x0000 // Range 0-Vdd
#define VREF_VREF 0x3000 // Range VrefL-VrefH
#define VREF_VDD 0x2000 // Range VrefL-Vdd
#define VSS_VREF 0x1000 // Range 0-VrefH
////////////////////////////////////////////////////////////////// INT
// Interrupt Functions: ENABLE_INTERRUPTS(), DISABLE_INTERRUPTS(),
// CLEAR_INTERRUPT(), INTERRUPT_ACTIVE(),
// EXT_INT_EDGE()
//
// Constants used in EXT_INT_EDGE() are:
#define L_TO_H 0x40
#define H_TO_L 0
//
// Constants used in other interrupt functions are:
#define INTR_GLOBAL 0x400
#define INTR_NORMAL 0x100
#define INTR_ALTERNATE 0x200
#define INTR_NESTING 0x300
#define INTR_LEVEL0 0x500
#define INTR_LEVEL1 0x501
#define INTR_LEVEL2 0x502
#define INTR_LEVEL3 0x503
#define INTR_LEVEL4 0x504
#define INTR_LEVEL5 0x505
#define INTR_LEVEL6 0x506
#define INTR_LEVEL7 0x507
#define INT_OSCFAIL 1
#define INT_ADDRERR 2
#define INT_STACKERR 3
#define INT_MATHERR 4
#define INT_DMAERR 5
#define INT_EXT0 6
#define INT_OC1 8
#define INT_TIMER1 9
#define INT_TIMER2 12
#define INT_TIMER3 13
#define INT_SPI1 14
#define INT_RDA 15
#define INT_TBE 16
#define INT_ADC1 17
#define INT_SI2C 19
#define INT_MI2C 20
#define INT_CN1 21
#define INT_IC7 22
#define INT_RDA2 29
#list
Saludos.
Soy nuevo en el foro, espero poder ir ayudando a todos con sus dudas y colaborando en lo que pueda. Más adelante iré publicando mis avances.