CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

dspic30F3011.. Not Output PWM!!!!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ploveq
Guest







dspic30F3011.. Not Output PWM!!!!
PostPosted: Fri Mar 27, 2009 10:08 pm     Reply with quote

** PWM PORT : PWM1_H(PIN RE1)
PWM2_H(PIN RE3)
PWM3_H(PIN RE5)
** MCU : dspic30F3011
Code:

#include <30F3011.h>
#FUSES HS                       //High speed Osc (> 4mhz)
#FUSES FRC 
#FUSES NOPWMPIN
#FUSES PR                       //Promiary Oscillator
#FUSES PWMPIN
#FUSES HPOL_HIGH                //High-Side Transistors Polarity is Active-High (PWM 1,3,5 and 7)
  //PWM module high side output pins have active high output polarity
#FUSES NOPWMPIN                 //PWM outputs drive active state upon Reset

#use delay(clock=20000000)
#use rs232(baud=9600, UART2,stream=pc_host)

char pc_data[20];
int i;
int mun =0;
int LED_Flag;
int no_flag;
int bat;
int temp;
int delay_flag = 0;
int16 duty;
int16 OCR_2;
int16 OCRS_2;

#INT_RDA2
void rda_isr()
{
    pc_data[0] = fgetc(pc_host);
    if(pc_data[0]=='S')
   {
      pc_data[1] = getch(pc_host);
      pc_data[2] = getch(pc_host);
   } 
}


void main()
{


       delay_ms(1000);
       output_bit(pin_E1,1);         //GREEN
       delay_ms(100);
       output_bit(pin_E1,0);         //GREEN
       delay_ms(100);



        delay_ms(1);
        #use rs232(baud=19200, UART1A)
        printf("%c%c",0xa3,1);
        printf("%c%c%c",0xa1,0,0);
        printf("%c Roll Indy Check  %c",0xa2,0);


   output_bit(pin_E8,0);         //RS485 Enabled
   enable_interrupts(INT_RDA2);



//duty = 32768; // = 0.5 * 65536

  duty = 502768; // = 0.5 * 65536
  setup_timer3(TMR_INTERNAL | TMR_DIV_BY_1);
  set_pwm_duty(3, duty);
  setup_compare(3, COMPARE_PWM);
     
    while(true)
   {

       output_bit(pin_E8,0);         //RS485 Enabled

      if((pc_data[0]=='S') && (pc_data[1]=='L') && (pc_data[2]=='1')   )
       {
            output_bit(pin_E1,1);         //GREEN
            delay_ms(500);
            output_bit(pin_E1,0);         //GREEN
            delay_ms(500);
            pc_data[0] = 'A';

       }

      if((pc_data[0]=='S') && (pc_data[1]=='L') && (pc_data[2]=='2')   )
       {
            output_bit(pin_E3,1);         //GREEN
            delay_ms(500);
            output_bit(pin_E3,0);         //GREEN
            delay_ms(500);
            pc_data[0] = 'A';

       }
      if((pc_data[0]=='S') && (pc_data[1]=='L') && (pc_data[2]=='3')   )
       {
            output_bit(pin_E5,1);         //GREEN
            delay_ms(500);
            output_bit(pin_E5,0);         //GREEN
            delay_ms(500);
            pc_data[0] = 'A';

       }


        i++;

        #use rs232(baud=19200, UART1A)
        printf("%c%c%c",0xa1,0,1);
        printf("%c da= %c %c / %c / %c %c",0xa2,pc_data[0],pc_data[1],pc_data[2],i,0);
        delay_ms(100);
         
   }
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group