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

SOLVED: dsPIC33CK64MP205 HSPWM

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



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

SOLVED: dsPIC33CK64MP205 HSPWM
PostPosted: Thu Mar 05, 2020 10:06 am     Reply with quote

Good day.
Battling to get the high speed PWM to work on this chip.
I get no output on the pin, it stays low.
It is probably something stupid I am missing, but I am out of ideas.

Code:
#include <33CK64MP205.h>
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOPROTECT

#use delay(internal=80MHz)

void main(void) {

  setup_hspwm(HSPWM_CLOCK_FOSC | HSPWM_CLOCK_DIV_BY_16, 5000);
  setup_hspwm_unit(5, HSPWM_ENABLE | HSPWM_COMPLEMENTARY | HSPWM_USES_MASTER_CLOCK);
  set_hspwm_period(5,5000);
  set_hspwm_duty(5, 1250);
  while (TRUE) {
    output_toggle(PIN_B8);  //running at correct speed
    delay_ms(250);
  }
}


Last edited by alan on Fri Mar 06, 2020 1:09 am; edited 1 time in total
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Thu Mar 05, 2020 2:21 pm     Reply with quote

Ok got it to at least output a PWM.
However you have to disable and then re-enable the HSPWM unit after a duty cycle change. So still looking to what are wrong in the setup.
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Fri Mar 06, 2020 1:09 am     Reply with quote

At last.
You have to either disable or setup the other hspwm units.
and add
Code:
PGxEVTL   = 0b00001000;

or call
Code:
hspwm_update(x);

when you have updated any registers.
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