• AVR Freaks

DAC dsPIC33FJ64GP802!!!???

Author
stai
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2009/04/26 19:13:58
  • Location: Colombia
  • Status: offline
2009/06/11 09:41:13 (permalink)
0

DAC dsPIC33FJ64GP802!!!???

Hello all, I am not able to put to work the DAC of a dsPIC33F, when debugging is not working (with PICkit3), the flag is not activated (IFS4bits.DAC1RIF), there are not changes in the status bit (DAC1STATbits.RFULL), doesn't enter to the interrupt (_DAC1RInterrupt), please I need help.
#include "p33FJ64GP802.h"

//CONFIGURATION BITS
_FBS( BWRP_WRPROTECT_OFF & BSS_NO_FLASH & RBS_NO_RAM )
_FSS( RSS_NO_RAM & SSS_NO_FLASH & SWRP_WRPROTECT_OFF )
_FGS( GSS_OFF & GCP_OFF & GWRP_OFF )
_FOSCSEL(FNOSC_PRIPLL & IESO_ON); // Primary oscillator (XT, HS, EC) w/ PLL, Two-speed Oscillator Startup : Enabled
_FOSC(FCKSM_CSDCMD & IOL1WAY_OFF & OSCIOFNC_OFF & POSCMD_XT ); // Clock switching and clock monitor:Disabled & Single configuration for remappable I/O:Disabled & OSC2 is clock O/P & XT oscillator
_FWDT( FWDTEN_OFF & WINDIS_OFF )
_FPOR( ALTI2C_OFF & FPWRT_PWR128 )
_FICD( BKBUG_ON & COE_ON & JTAGEN_OFF & ICS_PGD1 )

void __attribute__((interrupt, no_auto_psv)) _DAC1RInterrupt(void);
void __attribute__((interrupt, no_auto_psv)) _DAC1RInterrupt(void)
{
IFS4bits.DAC1RIF = 0; // Clear Right Channel Interrupt Flag
}

unsigned int i = 0;

int main (void)
{
// Oscillator Special Function Control Registers
// Configure Oscillator to operate the device at 40MIPS
// Fosc= Fin*M/(N1*N2), Fcy=Fosc/2 (XT=10MHz)

PLLFBD = 30; // PLL Feedback Divisor bits (also denoted as "M", PLL multiplier) 30 = 32
CLKDIVbits.PLLPRE = 0; // PLL Phase Detector Input Divider bits (also denoted as "N1", PLL prescaler) 0 = 2
CLKDIVbits.PLLPOST = 0; // PLL VCO Output Divider Select bits (also denoted as "N2", PLL postscaler) 0 = 2
//CLKDIVbits.FRCDIV = 0; // Internal Fast RC Oscillator Postscaler bits
CLKDIVbits.DOZEN = 0; // DOZE Mode Enable bit 0 = Processor clock/peripheral clock ratio forced to 1:1
//CLKDIVbits.DOZE = 0; // Processor Clock Reduction Select bits = FCY/1
CLKDIVbits.ROI = 0; // Recover on Interrupt bit 0 = Interrupts have no effect on the DOZEN bit

OSCTUNbits.TUN = 0; // FRC Oscillator Tuning bits = Center frequency (7.37 MHz nominal)

ACLKCONbits.SELACLK = 0; // FRC w/ Pll as Clock Source
ACLKCONbits.AOSCMD = 0; // 0 = Auxiliary Oscillator Disabled
ACLKCONbits.APSTSCLR = 7; // Auxiliary Clock Output Divider 7 = /1
ACLKCONbits.ASRCSEL = 1; // Select Reference Clock Source for Auxiliary Clock 0 = AOSCCLK

DAC1STATbits.ROEN = 1; // 1 = Positive and negative DAC outputs are enabled.
DAC1STATbits.RMVOEN = 0; // 0 = Midpoint output is disabled.
DAC1STATbits.RITYPE = 0; // 0 = Interrupt if FIFO is NOT FULL.

DAC1CONbits.DACFDIV = 6; // DAC Clock Divider 3 = /4
DAC1CONbits.FORM = 0; // Data Format Select bit 0 = Unsigned integer
//DAC1CONbits.AMPON = 0; // 0 = Analog Output Amplifier is disabled during Sleep Mode/Stop-in Idle mode
//DAC1CONbits.DACSIDL = 0; // Stop in Ideal Mode bit 0 = Continue module operation in Idle mode.
DAC1CONbits.DACEN = 1; // DAC1 Enable bit 1 = Enables module

DAC1DFLT = 0x8000; // DAC DEFAULT DATA REGISTER

IFS4bits.DAC1RIF = 0; // DAC Right Channel Interrupt Flag Status bit 0 = not occurred
IPC19bits.DAC1RIP = 7; // 7 = Interrupt is priority 7 (highest priority interrupt)
IEC4bits.DAC1RIE = 1; // DAC Right Channel Interrupt Enable bit 1 = enabled

/* PLLCLK/SELACLK/DACFDIV = DACCLK
80 MHz/1/4 = 20 MHz
Fs = 78.125 KHz */

while (1)
{
if ((DAC1STATbits.RFULL == 0 ) && (i <= 65535))
{
DAC1RDAT = i;
if (i == 65535)
{
i = 0;
}
i++;
}
}
}

post edited by stai - 2009/06/11 14:45:52
#1

4 Replies Related Threads

    Neiwiertz
    Super Member
    • Total Posts : 2094
    • Reward points : 0
    • Joined: 2004/09/01 02:58:52
    • Status: offline
    RE: DAC dsPIC33FJ64GP802!!!??? 2009/06/11 14:00:46 (permalink)
    0
    This is "offtopic" but i just want to let know, have a browse here E16 MA330018  - dsPIC33FJ128MC804 PIM
    it can provide some help about DAC and check microchip code example's aswell.
    (I added yours at E16 gallery DAC related collection)

    Flying With --|Explorer 16|HardWare|SoftWare|-- Fav(s) Gallery Lists
    #2
    Vinicius
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2009/07/06 12:14:40
    • Location: 0
    • Status: offline
    RE: DAC dsPIC33FJ64GP802!!!??? 2009/07/07 12:38:35 (permalink)
    0
    Hi,
    I had a similar problem.
     
    By a unknowm reason the interrupts cicling isnt automatic, need to write to DAC1RDAT to iniciate the process...
     
    In my application I wrote a zero to DAC1RDAT just after enabling interrupts and begins to work.
     
    regards,
    Vinicius
    #3
    gckkk
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2009/05/20 04:55:32
    • Location: 0
    • Status: offline
    RE: DAC dsPIC33FJ64GP802!!!??? 2009/08/11 01:28:26 (permalink)
    0
    Hello,

    i have strange problem with DAC on dspic33fj128gp802. I can't write to the DAC1RDAT or DAC1LDAT registers. When i set the DAC1DFL to some value for the first time, it copies to the DAC1RDAT and DAC1LDAT, but then they immediately goes to zero value. Also the interrupts occurs properly. Please help. I'm using PicKit2 for debugging.
    #4
    bharath
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2009/05/17 10:12:07
    • Location: 0
    • Status: offline
    RE: DAC dsPIC33FJ64GP802!!!??? 2010/01/10 20:00:20 (permalink)
    0
    hi
    im also having the same problem
    is any body got the solution
    plz help me..............its very urgent.........

    thanking u all in advance
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5