got a due now what
Topic: got a due now what
(Read 406 times)
got a due now what
Feb 27, 2017, 01:32 am
First a tip, my due did not work on external dc power supply only on USB. looking the pcb i´ve found that the mosfet that switches from usb to external power suppy had a bad solder on the gate pin, a touch with a solder iron solved the problem.
I´ve being working on a brushless driver (120v) project using a mega and it was kind of easy to find information on the net on how setup the MEGA and how it works. so i tought going a step further and make it a brushless servo driver only to find out that MEGA is slow when it comes to read encoders. then i found the wonderfull DUE with all that i need to read the encoders in high speed mode but wait... there is a catch as always, it is a pain to find information on how the due works, i´ve read the 2000+ pages on the SAM3x manual and i can´t figure out how to set the dead time on pwm. after 3 months working on it I´ve manage to get it working to maybe 90% of what i need getting bits of code from here and there and putting it all together.
I´ve found a code maybe from this group where the guy have setup the pwm with dead time but i can´t find information on how the dead time is set in HEX in the code bellow, looking at the sam3x manual is almost impossible for me to find out how it is set. (btw, I´m running it at 12 bit to get 20khz)
//Configure PWM channels 0,1,2,3 (PWML0,PWMH0,PWML1,PWMH1,PWML2,PWMH2,PWML3,PWMH3), (port C.2,C.3,C.4,C.5,C.6,C.7,C.8,C.9), (pins P34,P35,P36,P37,P38,P39,P40,P41)
REG_PIOC_PDR = 0x3FC; //B1111111100, PIO Disable Register
REG_PIOC_ABSR = REG_PIOC_ABSR | 0x3FCu; //B1111111100, Peripheral AB Select Register
REG_PMC_PCER1 = REG_PMC_PCER1 | 16; //Peripheral Clock Enable Register 1 (activate clock for PWM, id36, bit5 of PMC_PCSR1)
REG_PWM_ENA = REG_PWM_SR | B0111; //PWM Enable Register | PWM Status Register (activate channels 2,1,0=B0111 so 3 canais)
REG_PWM_CMR0 = 0x10000; //Channe0 Mode Register: Dead Time Enable DTE=1
REG_PWM_CMR1 = 0x10000; //Channe1 Mode Register: Dead Time Enable DTE=1
REG_PWM_CMR2 = 0x10000; //Channe2 Mode Register: Dead Time Enable DTE=1
REG_PWM_DT0 = 0x380038; // 0.67us PWM dead time
REG_PWM_DT1 = 0x380038; // 0.67us PWM dead time
REG_PWM_DT2 = 0x380038; // 0.67us PWM dead time
// REG_PWM_DT0 = 0xA800A8; //Channe0 Dead Time Register (168=2us for outputs PWML0,PWMH0)
// REG_PWM_DT1 = 0xA800A8; //Channe1 Dead Time Register (168=2us for outputs PWML1,PWMH1)
// REG_PWM_DT2 = 0xA800A8; //Channe2 Dead Time Register (168=2us for outputs PWML2,PWMH2)
REG_PWM_CPRD0 = 4096; //Channe0 Period Register (84mhz/4096=20.507khz)
REG_PWM_CPRD1 = 4096; //Channe1 Period Register (84mhz/4096=20.507khz)
REG_PWM_CPRD2 = 4096; //Channe2 Period Register (84mhz/4096=20.507khz)
I´ve changed the 0xA8000A8 to 0x380038 found that on another web page and my oscilloscope agree with 0.67us dead time (acctually 0.57us) but I would like to know how the hex works if i want to change it to another dead time setting.
when searching the net about 0xA8 it comes to 168 but what about the 00A8? it all comes to 168
why is that? can some explain the meaning of 0XA800A8
Also, how fast is the interrupt frequency on the DUE, i´ve my code running on 5 external interrupt pins
the step pulse interrupt should work at about 125khz and other 3 interrupts would come from hall sensors on the mortor that is running at 1000 rpm max.
I´ve got it working but i´m not shure if the interrupts is firing correctly. or if it is not missing any of the interrupts.
Strongly opinionated, but not official!
Re: got a due now what
Feb 27, 2017, 11:32 am
Did you see this thread? Same sort of issue.