 |
 |
View previous topic :: View next topic |
Author |
Message |
sezgin ozan
Joined: 05 Jan 2014 Posts: 13
|
DSPIC33CH256MP506 |
Posted: Thu Feb 20, 2025 2:36 am |
|
|
Hello everyone, I am using dspic33ch256mp506 for an 3 phase inverter project, but can not start the HSPWM module in slave core, slave core uses pwm1, pwm4 and pwm7 pairs. Before this project I used dspic33ep512mu810 and it works fine, I used similar setup function for the projects but HSPWM module does not start, ı think ı must enable the hspwm modules that slave will use , from master module but can not find the way, For pin that slave will use ı put "#fuse CPRA" for example, probably similar fuses must put for hspwm modules , can any know how to enable the module from master core
thanks |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19700
|
|
Posted: Thu Feb 20, 2025 6:01 am |
|
|
CPRA is not a single fuse. It is a 5 fuses, needing a 5 bit number. The syntax
is
#fuse CPRA=nn
where nn is the numeric value to control the fixe fuses. By default it is
set to 31, which means the main core owns all five bits. |
|
 |
sezgin ozan
Joined: 05 Jan 2014 Posts: 13
|
|
Posted: Thu Feb 20, 2025 7:56 am |
|
|
Hi Ttelmah, I have the pins that the slave core will use, but can not make the HSPWM module work, ı will post the set up code below
//! setup_hspwm_unit(1, HSPWM_ENABLE | HSPWM_H_POLAIRTY_HIGH | HSPWM_L_POLARITY_HIGH | HSPWM_COMPLEMENTARY | HSPWM_CENTER_ALIGN_MODE | HSPWM_PHASE_FROM_MPHASE_REG, dead_band, dead_band);
//! setup_hspwm_unit(4, HSPWM_ENABLE | HSPWM_H_POLAIRTY_HIGH | HSPWM_L_POLARITY_HIGH | HSPWM_COMPLEMENTARY | HSPWM_CENTER_ALIGN_MODE | HSPWM_PHASE_FROM_MPHASE_REG, dead_band, dead_band);
//! setup_hspwm_unit(7, HSPWM_ENABLE | HSPWM_H_POLAIRTY_HIGH | HSPWM_L_POLARITY_HIGH | HSPWM_COMPLEMENTARY | HSPWM_CENTER_ALIGN_MODE | HSPWM_PHASE_FROM_MPHASE_REG, dead_band, dead_band);
setup_hspwm_unit(1, HSPWM_ENABLE | HSPWM_USES_MASTER_CLOCK | HSPWM_H_POLAIRTY_HIGH | HSPWM_L_POLARITY_HIGH | HSPWM_COMPLEMENTARY | HSPWM_CENTER_ALIGN_MODE | HSPWM_PERIOD_FROM_MPER_REG, dead_band, dead_band);
setup_hspwm_unit(4, HSPWM_ENABLE | HSPWM_USES_MASTER_CLOCK | HSPWM_H_POLAIRTY_HIGH | HSPWM_L_POLARITY_HIGH | HSPWM_COMPLEMENTARY | HSPWM_CENTER_ALIGN_MODE | HSPWM_PERIOD_FROM_MPER_REG, dead_band, dead_band);
setup_hspwm_unit(7, HSPWM_ENABLE | HSPWM_USES_MASTER_CLOCK | HSPWM_H_POLAIRTY_HIGH | HSPWM_L_POLARITY_HIGH | HSPWM_COMPLEMENTARY | HSPWM_CENTER_ALIGN_MODE | HSPWM_PERIOD_FROM_MPER_REG, dead_band, dead_band);
setup_hspwm_unit(2, HSPWM_DISABLE);
setup_hspwm_unit(3, HSPWM_DISABLE);
setup_hspwm_unit(5, HSPWM_DISABLE);
setup_hspwm_unit(6, HSPWM_DISABLE);
setup_hspwm_unit(8, HSPWM_DISABLE);
uint16_t PwmPeriod = 2344/2; // 1200;//2344;//6000;
setup_hspwm(HSPWM_CLOCK_DIV_BY_2 , PwmPeriod);
// setup_hspwm(HSPWM_CLOCK_FPLLO | HSPWM_CLOCK_DIV_BY_2, pwmPeriod);
// setup_hspwm(HSPWM_CLOCK_AFPLLO | HSPWM_CLOCK_DIV_BY_2, pwmPeriod);
set_hspwm_period(1, 1150); // Set the frequency of the PWM signal
set_hspwm_period(4, 1150); // Set the frequency of the PWM signal
set_hspwm_period(7, 1150); // Set the frequency of the PWM signal.
//! set_hspwm_phase(1, 1150); // Set the frequency of the PWM signal
//! set_hspwm_phase(4, 1150); // Set the frequency of the PWM signal
//! set_hspwm_phase(7, 1150); //
set_hspwm_duty(1, 500);
set_hspwm_duty(4, 500);
set_hspwm_duty(7, 500);
I tried many things but can see pwm outputs, |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9403 Location: Greensville,Ontario
|
|
Posted: Thu Feb 20, 2025 10:16 am |
|
|
hmm.....
HSPWM_H_POLAIRTY_HIGH
pretty sure it should be 'POLARITY'........
I'm a lousy two finger typer...........but I saw this... |
|
 |
sezgin ozan
Joined: 05 Jan 2014 Posts: 13
|
|
Posted: Thu Feb 20, 2025 10:27 am |
|
|
Yes you are right but in definition it is like that , so I wrote as this |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19700
|
|
Posted: Thu Feb 20, 2025 10:47 am |
|
|
and your #pin selects? |
|
 |
sezgin ozan
Joined: 05 Jan 2014 Posts: 13
|
|
Posted: Thu Feb 20, 2025 12:31 pm |
|
|
Hi Ttelmah, I used pair 1, 4 and 7 and thought that it is ok, how can I select pins, they are D0, D1 , C10, C11, C14 and C15. In master core program I select them as pins wil be used in Salve core.
#fuses CPRC=0x33df
#fuses CPRD=0xfffc |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19700
|
|
Posted: Fri Feb 21, 2025 4:38 am |
|
|
Critical question.
What compiler version?????.
There were some significant register fixes done on this family a couple of
versions ago. |
|
 |
sezgin ozan
Joined: 05 Jan 2014 Posts: 13
|
|
Posted: Fri Feb 21, 2025 7:49 am |
|
|
Hi, version 5.118 |
|
 |
|
|
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
|