[PIC] Config FAULT PWM dsPIC33FJ06GS001

Status
Not open for further replies.

OrciBorg

Newbie
Joined
Jan 4, 2008
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,312
Hi folks,

I'm trying to set up the dsPIC33FJ06GS001 to generate a fault in PWM, when the voltage exceeds a limite the reference.

I'm using comparator 1 (CMP1A )

I do not know how to internally connect the output of the comparator in PWM fault.

See code below.

Alguém pode ajudar ?

Thanks

Code:
//==============================================================================
//                                                          Config COMPARATOR
//==============================================================================
 void init_CMP(void)
{

    CMPCON1bits.CMPON = 0;              // CMP1 Desabilitado p/ config

    CMPCON1bits.CMPSIDL = 1;            // Não funciona no modo IDLE
    
    CMPCON1bits.INSEL   =  11;           // Select CMP1A input
    CMPCON1bits.EXTREF  =  0;           // Choose internal reference
    CMPCON1bits.RANGE  =   1;           // referencia interna depende da
                                                      // configuração do registro abaixo

    CMPCON1bits.CMPPOL = 0;             // ativo em modo alto

                                                      // Tensao de ref de 1V
    CMPDAC1 = 630;                           // Choose comparator reference
         
                                                      // (CMREF (Avdd/2)/1024)
    CMPCON1bits.CMPON = 1;               // Habilita comparador

    }
 
 //=============================================================================
 //
 //=============================================================================
  void testePWM(void)
  {
    
    PTCONbits.PTEN = 0;
    
    IOCON1bits.PENH = 1;                /* PWM1 outputs controlled by PWM */
    IOCON1bits.PENL = 1;                /* module */

    IOCON1bits.PMOD = 0b10;               /* Choose Independent PWM mode */
    IOCON1bits.FLTDAT = 0;                /* Turn OFF both PWM1 outputs
                                           in case of a fault condition */

    IOCON1bits.POLL    = 0;                // PWM1L is active low
    IOCON1bits.POLH    = 0;                // PWM1H is active low


    PWMCON1bits.DTC = 2;                /* Dead time function disabled */


    PWMCON1bits.IUE      = 1;            // Atualizaçao instantanea do DUTY CYCLE

    FCLCON1bits.FLTSRC = 0; //1        /* Comparator  is Fault source */
    FCLCON1bits.FLTPOL = 0; //1          /* 0 = ativo em high, 1 = ativo em low */
   
    FCLCON1bits.FLTMOD =  0; //1          /* FLTDAT from IOCONx register
    FCLCON1bits.IFLTMOD = 0;
    FCLCON1bits.CLMOD = 1;
    IOCON1bits.FLTDAT = 0;                /* Turn OFF both PWM1 outputs
                                           in case of a fault condition */
     
     
     
    PTPER = 18900;                       /* PWM period of  */
                                                /* Period = PTPER*1.05nsec = 9.99us */
    PTCONbits.PTEN = 1;                 /* Turn ON PWM module */
  
  
  }
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…