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

About dspic33FJ128MC802

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



Joined: 05 Nov 2010
Posts: 6

View user's profile Send private message

About dspic33FJ128MC802
PostPosted: Fri Nov 05, 2010 2:26 pm     Reply with quote

Hello,

I'm starting with the dspic33FJ128MC802 but I can't use the PWM Crying or Very sad with this chip, I'm lost with this, I dont know if the 33FJ128MC802.h is complete or not?

Has anyone worked or is working with this chip?

Best regards,

Diego.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Nov 05, 2010 2:50 pm     Reply with quote

I don't use dsPIC33, but I noticed, that CCS provides a number of xxx_motor_pwm() built in functions for the MC (motor control) types. Did you check, if the functions are working for you?
megabytron



Joined: 05 Nov 2010
Posts: 6

View user's profile Send private message

PostPosted: Fri Nov 05, 2010 2:57 pm     Reply with quote

That's the problem, I think for this I can use the setup_motor_pwm(), but this instruction is an "Undefined Identifier" when I compile, so I don't know how can I fix this?

Thanks FvM,

Diego.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Nov 05, 2010 4:45 pm     Reply with quote

I see, that setup_motor_pwm() compiles with PCD V4.112. What's your PCD version, how you are using the function?
megabytron



Joined: 05 Nov 2010
Posts: 6

View user's profile Send private message

PostPosted: Fri Nov 05, 2010 4:56 pm     Reply with quote

My version is 4.088,

Now I'm trying with set_compare_time:
Code:

int16 OCR_2 = 0x1000;
int16 OCRS_2 = 0x5C4B;

set_compare_time(2, OCR_2, OCRS_2);
setup_compare(2, COMPARE_SINGLE_PULSE | COMPARE_TIMER3);

But I have 2 errors:

Invalid Parameters to built in function :: Invalid Pin
Invalid Parameters to built in function :: Invalid Pin

I don't understand why :S

Thx
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Nov 05, 2010 5:46 pm     Reply with quote

Quote:
My version is 4.088

That's a helpless case. The motor_pwm functions aren't supported before some 4.1xx PCD version. There are also other serious bugs involved with those early releases. Although some have been continued until today, 4.088 is definitely much worse. But it's working, though.

So the only option is to code the PWM register accesses yourself.
megabytron



Joined: 05 Nov 2010
Posts: 6

View user's profile Send private message

PostPosted: Fri Nov 05, 2010 8:41 pm     Reply with quote

Mr. FvM, you are right!

Now I compile in version 4.110, and is working!

my code is this:

Code:
setup_motor_pwm(1,MPWM_FREE_RUN | MPWM_SYNC_OVERRIDES, 50000); 
   set_motor_unit( 1,MPWM_ENABLE , MPWM_FORCE_L_1,MPWM_FAULT_NO_CHANGE,0);
   set_motor_pwm_duty(1,0,0x55);  //What is the effect of 0x55?
   set_motor_pwm_event(1,10000); //What is the effect of 10000?


and also use the #int_PWM1 and I can change the brightness of the LED but some one can explain me those functions? in the reference manual is not clear (for me).

For Example in setup_motor_pwm(pwm,options,prescale,postscale,timebase)

Pwm- Defines the pwm module used. --> Ok I used # 1
Options- The mode of the power PWM module. See the devices .h file for
all options --> Why MPWM_FREE_RUN | MPWM_SYNC_OVERRIDES ?
timebase- This parameter sets up the PWM time base pre-scale and post-scale. --> Why 50000?

If someone can explain this functions I'll appreciate it.

Best regards,

Diego P.
wangine



Joined: 07 Jul 2009
Posts: 98
Location: Curtea de Arges, Romania

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Fri Jun 17, 2011 4:17 pm     Reply with quote

I have the same problem but with another processor. dsPIC33FJ64GS406.
I just need two modules in PWM mode independently.
I tried microcontroller in C30 compiler and it works.
The problem is that I do not want to use it in C30 and CCS has a lot of features made in the compiler and besides it is also easier to use.
How can I set the PWM in CCS compiler? I hate C30.
For other microcontrollers 18F, 24F works but not on it.
Compiler version is 4.120.
Any function PWM motor control were to have compilation error.
There are built in functions and should work regardless of the processor?
Were wrong and have included some file somewhere?

My error :
Code:
   PLL();
  setup_compare(1,COMPARE_PWM | COMPARE_TIMER2 );
   setup_timer2(TMR_INTERNAL | TMR_DIV_BY_8,10 );

   setup_spi( FALSE );
setup_spi2( FALSE );

   setup_timer2(TMR_INTERNAL |TMR_DIV_BY_8 ,1200);
   setup_timer4(TMR_DISABLED |TMR_DIV_BY_1 ,0);
   setup_timer3(TMR_DISABLED |TMR_DIV_BY_1 ,0);
   setup_timer5(TMR_DISABLED |TMR_DIV_BY_1 ,0);


   setup_timer1(TMR_DISABLED|TMR_DIV_BY_1);


Code:
setup_motor_pwm(1,MPWM_FREE_RUN | MPWM_SYNC_OVERRIDES, 50000); 
   set_motor_unit( 1,MPWM_ENABLE , MPWM_FORCE_L_1,MPWM_FAULT_NO_CHANGE,0);
   set_motor_pwm_duty(1,0,0x55);


Code:
Executing: "C:\Program Files\PICC\Ccsc.exe" +FD "main.c" #__DEBUG=1 +ICD +DF +LN +T +A +M +Z +Y=9 +EA  #__dsPIC33FJ64GS406__=TRUE
*** Error 12 "main.c" Line 53(16,17): Undefined identifier  -- setup_motor_pwm
*** Error 12 "main.c" Line 54(20,21): Undefined identifier  -- set_motor_unit
*** Error 12 "main.c" Line 55(22,23): Undefined identifier  -- set_motor_pwm_duty
      3 Errors,  0 Warnings.

I searched the forum and I found no solution to this
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 17, 2011 4:51 pm     Reply with quote

Quote:
dspic33FJ128MC802

The original poster is using the MC verison of the PIC. "MC" stands
for "motor control". Look in the PCD compiler manual. It says:
Quote:

setup_motor_pwm( )

Availability: Devices that have the motor control PWM unit.


You are using the GS version, the dsPIC33FJ64GS406. It is
intended for Digital Power control applications. It does not have a
Motor Control PWM module. Therefore, the compiler doesn't support
the motor control functions for your PIC.
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