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 CCS Technical Support

Cycle-By-Cycle current limit using dsPIC33EP16GS502

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



Joined: 18 Aug 2011
Posts: 8

View user's profile Send private message

Cycle-By-Cycle current limit using dsPIC33EP16GS502
PostPosted: Tue Nov 01, 2016 7:52 am     Reply with quote

Hello,
I am using the dsPIC33EP16GS502 to control a push-pull boost transformer.
The PWM signals or working. I want to use the internal comparator and DAC to cycle-by-cycle limit the primary current via current sense resistor.

I can't figure out how to map the comparator-1D output to the current limit function for the PWM1 channel. I have this working on the dsPIC33FJ16GS502 using the RPOR0 and RPINR12 to map this but the new device is different. Any suggestions?
Code:

SETUP_HSPWM_UNIT(1, HSPWM_ENABLE | HSPWM_PUSH_PULL|HSPWM_UPDATE_ARE_IMMEDIATE | HSPWM_CURRENT_LIMIT_INT_ENABLED |HSPWM_CURRENT_LIMIT_L0_H0 | HSPWM_CURRENT_LIMIT_SOURCE_COMP1 | HSPWM_CURRENT_LIMIT_MODE_ENABLED);

setup_comparator(1, COMP_DAC_CMPXD | COMP_OUTPUT_DAC);
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Tue Nov 01, 2016 3:07 pm     Reply with quote

Look at section 10-1, in the sheet 700000323.pdf
The comparator has to be routed to a pin, on chips that do not have direct routing. This one however supports direct routing. This is where the big difference appears.

Unless you want the interrupt on fault, you don't need the HSPWM_CURRENT_LIMIT_INT_ENABLED.

The fault controls are active high. Are you sure you have the comparator setup correctly to give this?. If not you'll need HSPWM_CURRENT_LIMIT_ACTIVE_LOW

The comparator is comparing input D (AN3), with the DAC. You are also outputting the DAC to the DACOUT pin. Is this giving the voltage you expect?.

Old question 'compiler version'?. Quite possible the compiler is setting something wrong. It basically looks as if it should work.
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