View previous topic :: View next topic |
Author |
Message |
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
SOLVED: dsPIC33CK64MP205 HSPWM |
Posted: Thu Mar 05, 2020 10:06 am |
|
|
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
|
|
Posted: Thu Mar 05, 2020 2:21 pm |
|
|
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
|
|
Posted: Fri Mar 06, 2020 1:09 am |
|
|
At last.
You have to either disable or setup the other hspwm units.
and add
Code: | PGxEVTL = 0b00001000; |
or call
when you have updated any registers. |
|
|
|