1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我已经在SPDIC33 EP512MU810 PWM工作精细探索16开发和我的定制板。但当我尝试端口toDSPIC33 EP256MC506相同的代码不工作不能产生PWM。我使用相同的8MHz振荡器。其他外围设备,如LED,开关,定时器工作良好。即使在代码中没有任何错误。请更新…如果任何人都有一些想法…编辑:我已经看到例子16-1:PWMX写保护寄存器解锁序列可能是这是失踪的FordSpEP3EP256MC506in矿山代码TS9
以上来自于百度翻译 以下为原文 Hello, I have worked on dsPIC33EP512MU810 PWM working Fine on Explore 16 Development and my customized board. But When I am trying to Port to dsPIC33EP256MC506 same code does Not worked Not able to generate PWM . I am using Same 8MHz Oscillator . Other peripherals such as LEDs, Switches, timers are working Fine. Even Not getting any error in Code.. // FGS #pragma config GWRP = OFF // General Segment Write-Protect bit (General Segment may be written) //#pragma config GSS = OFF // General Segment Code-Protect bit (General Segment Code protect is disabled) //#pragma config GSSK = OFF // General Segment Key bits (General Segment Write Protection and Code Protection is Disabled) // FOSCSEL #pragma config FNOSC = PRI // Initial Oscillator Source Selection Bits (Primary Oscillator (XT, HS, EC) with PLL) #pragma config IESO = ON // Two-speed Oscillator Start-up Enable bit (Start up device with FRC, then switch to user-selected oscillator source) // FOSC #pragma config POSCMD = HS // Primary Oscillator Mode Select bits (HS Crystal Oscillator Mode) #pragma config OSCIOFNC = OFF // OSC2 Pin Function bit (OSC2 is clock output) #pragma config IOL1WAY = OFF // Peripheral pin select configuration (Allow multiple reconfigurations) #pragma config FCKSM = CSECMD // Clock Switching Mode bits (Both Clock switching and Fail-safe Clock Monitor are disabled) // FWDT #pragma config WDTPOST = PS32768 // Watchdog Timer Postscaler Bits (1:32,768) #pragma config WDTPRE = PR128 // Watchdog Timer Prescaler bit (1:128) #pragma config PLLKEN = ON // PLL Lock Wait Enable bit (Clock switch to PLL source will wait until the PLL lock signal is valid.) #pragma config WINDIS = OFF // Watchdog Timer Window Enable bit (Watchdog Timer in Non-Window mode) #pragma config FWDTEN = OFF // Watchdog Timer Enable bit (Watchdog timer enabled/disabled by user software) // FPOR //#pragma config FPWRT = PWR128 // Power-on Reset Timer Value Select bits (128ms) //#pragma config BOREN = OFF // Brown-out Reset (BOR) Detection Enable bit (BOR is disabled) #pragma config ALTI2C1 = OFF // Alternate I2C pins for I2C1 (SDA1/SCK1 pins are selected as the I/O pins for I2C1) #pragma config ALTI2C2 = OFF // Alternate I2C pins for I2C2 (SDA2/SCK2 pins are selected as the I/O pins for I2C2) // FICD #pragma config ICS = PGD2 // ICD Communication Channel Select bits (Communicate on PGEC2 and PGED2) //#pragma config RSTPRI = PF // Reset Target Vector Select bit (Device will obtain reset instruction from Primary flash) #pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled) // FAS //#pragma config AWRP = OFF // Auxiliary Segment Write-protect bit (Auxiliary program memory is not write-protected) //#pragma config APL = OFF // Auxiliary Segment Code-protect bit (Aux Flash Code protect is disabled) //#pragma config APLK = OFF // Auxiliary Segment Key bits (Aux Flash Write Protection and Code Protection is Disabled) #define Fosc 120000000.0 #define FOSC 120000000.0 #define FCY 60000000.0 #include //PWM Mode of Operation. Choose only one. #define MODE_COMPLEMENTARY // #define MODE_REDUNDANT // #define MODE_PUSHPULL // #define MODE_TRUE_INDEPENDENT_PWM //PWM Configuration // #define USE_FIXED_PRIMARY_PERIOD //If uncommented, PWM uses Fixed SECONDARY PERIOD(STPER) // #define VARIABLE_PHASE_FIXED_PERIOD //If uncommented, PWM uses PHASEx as PERIOD REGISTER with NO PHASE SHIFT // #define INDEPENDENT_DUTYCYCLE //If uncommented, it uses MDC as DUTYCYCLE Register #define CENTER_ALIGNED_MODE #ifdef CENTER_ALIGNED_MODE #define mPWM_PHASE1 (10000.0 * 2.0) #define mPWM_PHASE2 (10000.0 * 2.0) #define mPWM_PHASE3 (10000.0 * 2.0) #define mPWM (10000.0 * 2.0) #define mPDC1 10.0 #define mPDC2 10.0 #define mPDC3 10.0 //#else // If Edge Aligned Mode #define PWM 20000.0 #define mMDC 70.0 //Duty Cycle for Fixed Frequence(PTPER)) #endif volatile int ArrayCount=0,PWM_ARRAY[10]; void SystemInitialize(void); void OSCInit(void); void IOInit(void); void HSPWMInit(void); int main(void) { __delay_ms(10) ; SystemInitialize(); while(1); return 0; } void SystemInitialize(void) { OSCInit() ; //Initialize Oscillator IOInit() ; //Initialize IO Ports HSPWMInit() ; //Initialize High Speed PWM } void HSPWMInit(void) { PTCON2bits.PCLKDIV = 0; //PreScaler (Divided by 1) //ALDTRx, DTRx = Fosc x (Desired Dead Time / PreScaler) /* Set Dead Time Values */ DTR1 = DTR2 = DTR3 = 25; ALTDTR1 = ALTDTR2 = ALTDTR3 = 25; #ifdef MODE_COMPLEMENTARY IOCON1bits.PMOD = IOCON2bits.PMOD = IOCON3bits.PMOD = 0b00; #endif #ifdef CENTER_ALIGNED_MODE // Check HSPWM Referennce Maunal for that Page 12 PWMCON1bits.ITB = 1 ; // PHASEx/SPHASEx registers provide timebase period for this PWM generator PWMCON2bits.ITB = 1 ; // PHASEx/SPHASEx registers provide timebase period for this PWM generator PWMCON3bits.ITB = 1; // PHASEx/SPHASEx registers provide timebase period for this PWM generator PWMCON1bits.CAM = 1 ; // PWM1 - Center Aligend Mode 1 PWMCON2bits.CAM = 1 ; // PWM2 - Center Aligend Mode 1 PWMCON3bits.CAM = 1 ; // PWM2 - Center Aligend Mode 1 PHASE1 = Fosc / mPWM_PHASE1; PHASE2 = Fosc / mPWM_PHASE2; PHASE3 = Fosc / mPWM_PHASE3; #else // Egde Aligned MOode PWMCON1bits.ITB = PWMCON2bits.ITB = PWMCON3bits.ITB = 0; PHASE1 = 0; PHASE2 = 0; PHASE3 = 0; //PWM = 20kHz //PTPER,PHASEx,SPHASEx = Fosc / (PWM x PreScaler) =120Mhz / (20kHz x 1) = 6000 PTPER =Fosc / PWM; #endif // MDC,PDCx,SDCx = Fosc / (PWM x PreScaler) x Desired Duty Cycle // We are using PDCx. Mandataory for Center Aligned Mode PWMCON1bits.MDCS = PWMCON2bits.MDCS = PWMCON3bits.MDCS = 0; /* PDCx/SDCx provides duty cycle value */ PDC1 = Fosc / (mPWM_PHASE1) * mPDC1/100; // Set Duty Cycles PDC2 = Fosc / (mPWM_PHASE2) * mPDC2/100; // Set Duty Cycles PDC3 = Fosc / (mPWM_PHASE3) * mPDC3/100; // Set Duty Cycles /////////// PDC3 = 5400; IOCON1 |= 0xC000; IOCON2 |= 0xC000; IOCON3 |= 0xC000; /* Configure Faults */ FCLCON1 = FCLCON2 = FCLCON3 = 0x0000; /* 1:1 Prescaler */ PTCON2 = 0x0000; //Trigger TRIG1 = TRIG2 = TRIG3 = 1000; //3000; TRGCON1bits.TRGDIV = 15; TRGCON1bits.TRGSTRT = 15; //PWMCON1bits.IUE = 1; PWMCON1bits.TRGSTAT = 0; //PWMCON1bits.TRGIEN = 1; while(PWMCON1bits.TRGSTAT); IEC5bits.PWM1IE = 1; //INTCON2bits.GIE = 1; /* Enable PWM Module */ //PTCON = 0x8000; PTCONbits.PTEN = 1; } void OSCInit(void) { // Configure PLL prescaler, PLL postscaler, PLL divisor // ((8Mhz / N1) x 60) / N2 = 120Mhz // FOSC = 120Mhz // Fcy = 120Mhz/2 = 60Mhz = 60MIPS PLLFBD = 58; // M=60 CLKDIVbits.PLLPOST=0; // N2=2 CLKDIVbits.PLLPRE=0; // N1=2 // Initiate Clock Switch to Primary Oscillator with PLL (NOSC=0b011) __builtin_write_OSCCONH(0x03); __builtin_write_OSCCONL(OSCCON | 0x01); // Wait for Clock switch to occur while (OSCCONbits.COSC!= 0b011); // Wait for PLL to lock while (OSCCONbits.LOCK!= 1); } Please Update .. If any body have some idea.. Edited : I have seen EXAMPLE 16-1: PWMx WRITE-PROTECTED REGISTER UNLOCK SEQUENCE May be this is missing for dsPIC33EP256MC506 in Mine Code -- TS9 |
|
相关推荐
4个回答
|
|
|
|
|
|
尝试告诉我们“……不工作[Sc]不产生PWM……”实际上意味着。我假设“……在代码中没有任何错误”意味着编译器不会产生任何错误。你对旧的MCU和你使用的PWM模块之间的差异做了哪些研究?在新的使用?苏珊
以上来自于百度翻译 以下为原文 Try telling us what "...does not worked[sic] does not generate PWM..." actually means. I assume that "...not getting any error in code" means that the compiler does not generate any errors. What research have you done into the differences between the PWM module you use in the old MCU and the one you use in the new? Susan |
|
|
|
在从DSPIC33 EP512MU810到DSPIC33 EP256MC506单片机的代码端口上,我看不到DSO上的PWM波形。
以上来自于百度翻译 以下为原文 I am unable see PWM Waveform on DSO while port the code from dsPIC33EP512MU810 to Dspic33ep256mc506 MCU |
|
|
|
您是否考虑过衍生工具之间的PPS/端口设置的最终差异?6X和100针之间有显著性差异。
以上来自于百度翻译 以下为原文 Did you consider eventual differences in the PPS/port setup between the derivatives? There is a significant difference between 6x and 100 pins. |
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2028 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3204 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
777浏览 1评论
666浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
595浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
676浏览 0评论
576浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 02:20 , Processed in 1.542260 second(s), Total 83, Slave 67 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号