完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我使用PIC32 MX795F512L MCU 100引脚TQFP,MPLAB IDE V890和MPLAB COMPILMRPLAB C32 C编译器V2.02PIC工具包- 3与内部电源…我正在定制硬件,并尝试闪烁LED。目标检测。设备ID修订= 5350553编程…编程/验证完成。我面临以下问题。在发布模式下的问题已经运行(附加代码)和LED闪烁程序以前在相同的硬件上工作良好。但是使用相同的代码编程/验证完成,但是现在不能闪烁LED。调试模式中的问题已经启用调试模式。配置位设置,但仍然低于错误。编程…PK3Err4040:目标设备没有准备好调试。请检查你的配置位设置并在继续之前对设备进行编程。
以上来自于百度翻译 以下为原文 Hi, I am using PIC32MX795F512L MCU 100 Pin TQFP,MPLAB IDE v8.90 and MPLAB Compiler MPLAB C32 C Complier v2.02PIC Kit -3 with internal power supply.. I am working on Customize Hardware and Trying be blink LEDs. Target Detected.Device ID Revision = 54300053Programming... Programming/Verify complete. I am facing below issue.. Problem at Release ModeI have run (attached code) and LEDs Blinking program was working fine previously on Same hardware . But with same code Programming/Verify complete but unable to Blink LEDs Now. Problem at Debug ModeI have enabled DEBUG mode in configuration bits setting.
#pragma config DEBUG = ON //
But still getting below error.Programming... PK3Err0040:The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding. Any Guess .. --Karan123 Attachment(s) |
|
相关推荐
3个回答
|
|
不要手动设置该位。关闭它,让调试工具控制它。(1)你的振荡器不工作。你选择HS模式。有没有外部晶体连接正确?或(2)您连接到错误的调试引脚。您选择了“ICSUPGX2”。
以上来自于百度翻译 以下为原文 Do NOT manually set that bit. Leave it off and let the debug tool control it. Either: [1] your oscillator is not working. You selected HS mode. Do you have an external crystal connected correctly? or [2] you are connected to the wrong debug pins. You have selected "ICS_PGx2". |
|
|
|
谢谢更新。(1)是的,硬件上有8MHz的外部晶体振荡器。编辑:与内部振荡器一起工作。〔2〕我使用了单片机的PIN号26和27。用于调试和编程。编辑:调试工作也很好——卡兰
以上来自于百度翻译 以下为原文 Thanks for update.. [1] Yes, I have External Crystal Oscillator of 8MHz on by Hardware. Edited : Worked with Internal Oscillator. [2] I have used Pin Number 26 and 27 of MCU. For Debugging and Programming. Edited : Debugging Also Working Fine -- Karan |
|
|
|
此代码是如何配置和选择系统时钟频率的示例,而不使用任何微芯片库函数。请理解,该代码显示了所需的所有步骤。微芯片“隐藏”在微芯片库中的开发人员需要做的一些棘手的事情。LyBrar函数的源代码与编译器一起安装,但是如果没有Microchip库函数,就需要安装PIC32所需的一切。
以上来自于百度翻译 以下为原文 This code is an example of how to configure and select the system clock frequency without using any Microchip library functions. /* * File: main.c * Target: PIC32MX795F512L * Compiler: C32 v2.02, XC16 v1.44 * * Description: * Blink LEDs on PORTF bits RF2, RF4, RF8 * * Notes: * Define symbol USE_XTAL to use an external 8.0MHz crystal. * Define symbol USE_PLL to enable the PLL and set clock to 80MHz. * Does not use the PLIB library so should build with any Microchip compiler for PIC32. * When building with XC16 v1.44 MPLAB v8.92 asserts an error dialog box. */ /* * Configuration words */ #pragma config FSRSSEL = PRIORITY_7 /* SRS Select (SRS Priority 7) */ #pragma config FMIIEN = OFF /* Ethernet RMII/MII Enable (RMII Enabled) */ #pragma config FETHIO = OFF /* Ethernet I/O Pin Select (Alternate Ethernet I/O) */ #pragma config FCANIO = OFF /* CAN I/O Pin Select (Alternate CAN I/O) */ #pragma config FUSBIDIO = OFF /* USB USID Selection (Controlled by Port Function) */ #pragma config FVBUSONIO = OFF /* USB VBUS ON Selection (Controlled by Port Function) */ #pragma config FPLLIDIV = DIV_2 /* PLL Input Divider (2x Divider) */ #pragma config FPLLMUL = MUL_20 /* PLL Multiplier (20x Multiplier) */ #pragma config UPLLIDIV = DIV_2 /* USB PLL Input Divider (2x Divider) */ #pragma config UPLLEN = OFF /* USB PLL Enable (Disabled and Bypassed) */ #pragma config FPLLODIV = DIV_1 /* System PLL Output Clock Divider (PLL Divide by 1) */ #pragma config FSOSCEN = OFF /* Secondary Oscillator Enable (Disabled) */ #pragma config IESO = OFF /* Internal/External Switch Over (Disabled) */ #pragma config OSCIOFNC = OFF /* CLKO Output Signal Active on the OSCO Pin (Disabled) */ #pragma config FPBDIV = DIV_1 /* Peripheral Clock Divisor (Pb_Clk is Sys_Clk/1) */ #pragma config WDTPS = PS1 /* Watchdog Timer Postscaler (1:1) */ #pragma config FWDTEN = OFF /* Watchdog Timer Enable (WDT Disabled (SWDTEN Bit Controls)) */ #pragma config ICESEL = ICS_PGx2 /* ICE/ICD Comm Channel Select (ICE EMUC2/EMUD2 pins shared with PGC2/PGD2) */ #pragma config PWP = OFF /* Program Flash Write Protect (Disable) */ #pragma config BWP = OFF /* Boot Flash Write Protect bit (Protection Disabled) */ #pragma config CP = OFF /* Code Protect (Protection Disabled) */ #pragma config FNOSC = FRC /* Oscillator Selection Bits (Fast RC Osc) */ #pragma config FCKSM = CSECMD /* Clock Switching and Monitor Selection (Clock Switch Enable, FSCM Disabled) */ #if defined(USE_XTAL) #pragma config POSCMOD = XT /* Primary Oscillator Configuration (XT osc mode) */ #define OSC_FREQUENCY (8000000ul) /* External crystal frequency */ #define PLL_INPUT_DIVIDER (2ul) #define PLL_MULTIPLIER (20ul) #if defined(USE_PLL) #define OSC_SELECTOR (0b011) /* Use Primary Oscillator + PLL*/ #else #define OSC_SELECTOR (0b010) /* Use Primary Oscillator */ #endif #else #pragma config POSCMOD = OFF /* Primary Oscillator Configuration (Primary osc disabled) */ #define OSC_FREQUENCY (8000000ul) /* Internal Fast RC oscillator frequency */ #define PLL_INPUT_DIVIDER (2ul) #define PLL_MULTIPLIER (20ul) #if defined(USE_PLL) #define OSC_SELECTOR (0b001) /* Use FRC + PLL */ #else #define OSC_SELECTOR (0b000) /* Use FRC */ #endif #endif #if defined(__XC32) #include #elif defined(__C32__) #include #else #error "Unknown PIC32 compiler" #endif #if defined(USE_PLL) #define GetSystemClock() ((OSC_FREQUENCY/PLL_INPUT_DIVIDER)*PLL_MULTIPLIER) #define PB_CLOCK_DIVIDER (1ul) #else #define GetSystemClock() (OSC_FREQUENCY) #define PB_CLOCK_DIVIDER (1ul) #endif #define GetPeripheralClock() (GetSystemClock()/PB_CLOCK_DIVIDER) #define GetInstructionClock() (GetSystemClock()) #define FLASH_SPEED_HZ 30000000ul //Max Flash speed #define PB_BUS_MAX_FREQ_HZ 80000000ul //Max Peripheral bus speed /*************************************************************** * * * Flash Prefetch option - Values are mutually exclusive ************************************************************** */ #define CHE_CONF_PF_DISABLE (0 << _CHECON_PREFEN_POSITION) #define CHE_CONF_PF_C (1 << _CHECON_PREFEN_POSITION ) #define CHE_CONF_PF_NC (2 << _CHECON_PREFEN_POSITION) #define CHE_CONF_PF_ALL (3 << _CHECON_PREFEN_POSITION) /* Initialize this PIC */ void __attribute__ ((nomips16)) PIC_Init(void) { // Configure the device for maximum performance, // This function will change the program Flash wait states, // RAM wait state and enable prefetch cache // The PBDIV value must be already set via the pragma FPBDIV option in configuration words. unsigned int sys_clock; unsigned int pb_clock; unsigned int int_status; unsigned int wait_states; register unsigned long cache_tmp; register unsigned long clock_switch_timeout; sys_clock = GetSystemClock(); /* Save current interrupt enable state and disable interrupts */ asm volatile("di %0" : "=r"(int_status)); /* Check that we can change the system clock frequency */ if(!OSCCONbits.CLKLOCK) { /* swich system clock to FRC, no PLL */ SYSKEY = 0, SYSKEY = 0xAA996655, SYSKEY = 0x556699AA; OSCCONbits.NOSC = 0b000; /* select FRC as system oscillator */ OSCCONbits.OSWEN = 1; /* start a clock switch */ SYSKEY = 0x33333333; for(clock_switch_timeout=80000; clock_switch_timeout; clock_switch_timeout--) { if(!OSCCONbits.OSWEN) break; } } /* Disable the JTAG interface */ DDPCONbits.JTAGEN = 0; /* Disable the JTAG TDO output */ DDPCONbits.TDOEN = 0; /* Disable the TRACE interface */ DDPCONbits.TROEN = 0; /* Set RAM to use MAX wait states */ BMXCONCLR = _BMXCON_BMXWSDRM_MASK; /* Set FLASH wait states for desired system clock */ wait_states = 0; while(sys_clock > (FLASH_SPEED_HZ * (wait_states + 1))) { wait_states++; } /* turn on cache and set FLASH wate states */ CHECON = CHE_CONF_PF_ALL | wait_states; /* Select Kseg0 coherency algorithm as 3, cacheable. */ asm("mfc0 %0,$16,0" : "=r"(cache_tmp)); cache_tmp = (cache_tmp & ~7) | 3; asm("mtc0 %0,$16,0" :: "r" (cache_tmp)); /* compute peripherial bus clock frequency from sys_clock */ pb_clock = (sys_clock >> OSCCONbits.PBDIV); if(!OSCCONbits.CLKLOCK) { /* swich system clock to Primary oscillation amplifier with PLL */ SYSKEY = 0, SYSKEY = 0xAA996655, SYSKEY = 0x556699AA; #if (PLL_INPUT_DIVIDER == 1) OSCCONbits.FRCDIV =0b000; #elif (PLL_INPUT_DIVIDER == 2) OSCCONbits.FRCDIV =0b001; #elif (PLL_INPUT_DIVIDER == 4) OSCCONbits.FRCDIV =0b010; #elif (PLL_INPUT_DIVIDER == 8) OSCCONbits.FRCDIV =0b011; #elif (PLL_INPUT_DIVIDER == 16) OSCCONbits.FRCDIV =0b100; #elif (PLL_INPUT_DIVIDER == 32) OSCCONbits.FRCDIV =0b101; #elif (PLL_INPUT_DIVIDER == 64) OSCCONbits.FRCDIV =0b110; #elif (PLL_INPUT_DIVIDER == 256) OSCCONbits.FRCDIV =0b111; #else #error PLL input divider has bad value #endif #if (PLL_MULTIPLIER == 15) OSCCONbits.PLLMULT =0b000; #elif (PLL_MULTIPLIER == 16) OSCCONbits.PLLMULT =0b001; #elif (PLL_MULTIPLIER == 17) OSCCONbits.PLLMULT =0b010; #elif (PLL_MULTIPLIER == 18) OSCCONbits.PLLMULT =0b011; #elif (PLL_MULTIPLIER == 19) OSCCONbits.PLLMULT =0b100; #elif (PLL_MULTIPLIER == 20) OSCCONbits.PLLMULT =0b101; #elif (PLL_MULTIPLIER == 21) OSCCONbits.PLLMULT =0b110; #elif (PLL_MULTIPLIER == 24) OSCCONbits.PLLMULT =0b111; #else #error PLL multiplier has bad value #endif OSCCONbits.PLLODIV = 0b000; /* set PLL output divider to 1:1 */ OSCCONbits.NOSC = OSC_SELECTOR; OSCCONbits.OSWEN = 1; /* start a clock switch */ SYSKEY = 0x33333333; for(clock_switch_timeout=80000; clock_switch_timeout; clock_switch_timeout--) { if(!OSCCONbits.OSWEN) break; } } /* set GPIO pins for digital I/O */ AD1PCFG = 0xFFFFUL; /* Restore interrupt state */ if(int_status & 0x00000001) { asm volatile("ei %0" : "=r"(int_status)); } /* * At this point the values for sys_clock and pb_clock * should be assigned. */ } /* * */ void DelayMS( unsigned long Delay ) { #define TICKS_IN_ONE_MILLISECOND (GetSystemClock() / 2000ul) unsigned long Time0, Time1; Time0 = _CP0_GET_COUNT(); /* 2 system clocks per count */ if (Delay < (unsigned long)(0xFFFFFFFF) / TICKS_IN_ONE_MILLISECOND) Delay = Delay * TICKS_IN_ONE_MILLISECOND; else Delay = (unsigned long)(0xFFFFFFFF); for(;;) { Time1 = _CP0_GET_COUNT(); Time1 = Time1 - Time0; /* Get cycle from start of spin */ if (Time1 >= Delay) break; } } /* * Main application */ #define LED_D1 LATFbits.LATF2 #define LED_D2 LATFbits.LATF8 #define LED_D3 LATFbits.LATF4 #define LED_D1_DIR TRISFbits.TRISF2 #define LED_D2_DIR TRISFbits.TRISF8 #define LED_D3_DIR TRISFbits.TRISF4 void main(void) { int i ; PIC_Init(); DelayMS(1000); LED_D1_DIR = 0; LED_D2_DIR = 0; LED_D3_DIR = 0; DelayMS(1000); while(1) { LED_D1 = 0; LED_D2 = 1; LED_D3 = 0; DelayMS(1000); LED_D1 = 1; LED_D2 = 0; LED_D3 = 1; DelayMS(1000); } } Please understand that this code shows all of the steps required. There are several tricky things that must be done that Microchip "hides" from the developer in the Microchip library functions. The source code for the library functions are installed along with the compiler but it can be painful to find everything you need to setup a PIC32 without the Microchip library functions. |
|
|
|
只有小组成员才能发言,加入小组>>
5248 浏览 9 评论
2036 浏览 8 评论
1956 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3218 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2264 浏览 5 评论
787浏览 1评论
678浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
604浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
685浏览 0评论
582浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-27 14:59 , Processed in 1.293865 second(s), Total 81, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号