完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
本帖最后由 一只耳朵怪 于 2018-6-13 15:23 编辑
为什么我连仿真器下载程序后第一次运行没有问题,每次拔下仿真器重新上电后老是丢失系统时钟,进入limp mode 时钟配置代码: while(SysCtrlRegs.PLLSTS.bit.MCLKSTS != 0) [ DelayUs(20); SysCtrlRegs.PLLSTS.bit.MCLKCLR = 1; ] // Make sure the PLL is not running in limp mode if (SysCtrlRegs.PLLSTS.bit.MCLKSTS != 1) [ // PLL is not running in limp mode SysCtrlRegs.PLLSTS.bit.MCLKOFF = 1; // Turn off missing clock detect before changing PLLCR SysCtrlRegs.PLLSTS.bit.DIVSEL = 0; // DIVSEL must be 0 or 1 (/4 CLKIN mode) before changing PLLCR SysCtrlRegs.PLLCR.bit.DIV = 0x000A; // PLLx10/4 (because DIVSEL is /4) // Wait for PLL to lock. // During this time the CPU will run at OSCCLK/2 until the PLL is stable. // Once the PLL is stable the CPU will automatically switch to the new PLL value. // Code is not required to sit and wait for the PLL to lock. However, // if the code does anything that is timing critical (e.g. something that // relies on the CPU clock frequency to be at speed), then it is best to wait // until PLL lock is complete. The watchdog should be disabled before this loop // (e.g., as was done above), or fed within the loop. while(SysCtrlRegs.PLLSTS.bit.PLLLOCKS != 1) // Wait for PLLLOCKS bit to set [ //SysCtrlRegs.WDKEY = 0x0055; // Service the watchdog while waiting //SysCtrlRegs.WDKEY = 0x00AA; // in case the user enabled it. ] // After the PLL has locked, we are running in PLLx10/4 mode (since DIVSEL is /4). // We can now enable the missing clock detect circuitry, and also change DIVSEL // to /2. In this example, I will wait a bit of time to let inrush currents settle, // and then change DIVSEL from /4 to /2. This is only an example. The amount of // time you need to wait depends on the power supply feeding the DSP (i.e., how much // voltage droop occurs due to the inrush currents, and how long it takes the // voltage regulators to recover). SysCtrlRegs.PLLSTS.bit.MCLKOFF = 0; // Enable missing clock detect circuitry DelayUs(20/2); // Wait 20 us (just an example). Remember we're running // at half-speed here, so divide function argument by 2. SysCtrlRegs.PLLSTS.bit.DIVSEL = 0x2; // Change to /2 mode ] else [ // PLL is running in limp mode // User should replace the below with a call to an appropriate function, // for example shutdown the system (since something is very wrong!). asm(" ESTOP0"); ] |
|
相关推荐
8个回答
|
|
|
|
|
|
|
|
|
Eric 1.我在datasheet上没有找到配置时钟源的寄存器 是不是PLLSTS[OSCOFF] = 0是外部时钟源,PLLSTS[OSCOFF] = 1是内部时钟源 2.我用的是外部时钟源,如果配置成内部时钟源,是不是等时钟稳定后在配置成外部时钟源? |
|
|
|
|
testd27 发表于 2018-6-13 08:37 xiangjun, 你需要到芯片主页那儿去找 system control and interrupts user guide,里面才有所有详细的手册,datasheet只是一些参数而已。 系统上电启动默认是先用内部时钟,在main的最开始会进行系统初始化,sysctrlinit, 在DSP2803x_SysCtrl.c这个源文件。你在这里面切换到外部晶振就可以了。都是有相关函数给你切换的,不用你自己去配置寄存器。 下载controlSUITE。 Eric - ERIC |
|
|
|
|
guigui_7044 发表于 2018-6-13 08:50 如果是main之前启用内部时钟的话 那还需要我配置吗?我用的就是void InitSysCtrl(void)函数 在TMS320x2833x, 2823x System Control and Interrupts Reference Guide里面查的资料 |
|
|
|
|
|
楼主的配置程序中都没用ELLOW和EDIS的?这样是改变不了受保护的寄存器的值的,如
EALLOW; // Before setting PLLCR turn off missing clock detect logic SysCtrlRegs.PLLSTS.bit.MCLKOFF = 1; SysCtrlRegs.PLLCR.bit.DIV = val; EDIS; 建议参考controlsuite里面的F2803X的DSP2803X_SysCtrl.c。 |
|
|
|
|
广陵云峰 发表于 2018-6-13 09:08 Martin Yu 这是配置源代码: void InitSysCtrl(void) [ volatile Uint16 i; // General purpose Uint16 volatile int16 dummy; // General purpose volatile int16 DisableDog(); asm(" EALLOW"); // Enable EALLOW protected register access //#ifdef 1 //--- Memory Protection Configuration DevEmuRegs.PROTSTART = 0x0100; // 写默认值来保护开始寄存器Write default value to protection start register DevEmuRegs.PROTRANGE = 0x00FF; // 写默认值来保护类型寄存器Write default value to protection range register //--- Configure the PLL // Note: The DSP/BIOS configuration tool can also be used to initialize the PLL // instead of doing the initialization here. while(SysCtrlRegs.PLLSTS.bit.MCLKSTS != 0) [ DelayUs(20); SysCtrlRegs.PLLSTS.bit.MCLKCLR = 1; ] // Make sure the PLL is not running in limp mode if (SysCtrlRegs.PLLSTS.bit.MCLKSTS != 1) [ // PLL is not running in limp mode SysCtrlRegs.PLLSTS.bit.MCLKOFF = 1; // Turn off missing clock detect before changing PLLCR SysCtrlRegs.PLLSTS.bit.DIVSEL = 0; // DIVSEL must be 0 or 1 (/4 CLKIN mode) before changing PLLCR SysCtrlRegs.PLLCR.bit.DIV = 0x000A; // PLLx10/4 (because DIVSEL is /4) // Wait for PLL to lock. // During this time the CPU will run at OSCCLK/2 until the PLL is stable. // Once the PLL is stable the CPU will automatically switch to the new PLL value. // Code is not required to sit and wait for the PLL to lock. However, // if the code does anything that is timing critical (e.g. something that // relies on the CPU clock frequency to be at speed), then it is best to wait // until PLL lock is complete. The watchdog should be disabled before this loop // (e.g., as was done above), or fed within the loop. while(SysCtrlRegs.PLLSTS.bit.PLLLOCKS != 1) // Wait for PLLLOCKS bit to set [ //SysCtrlRegs.WDKEY = 0x0055; // Service the watchdog while waiting //SysCtrlRegs.WDKEY = 0x00AA; // in case the user enabled it. ] // After the PLL has locked, we are running in PLLx10/4 mode (since DIVSEL is /4). // We can now enable the missing clock detect circuitry, and also change DIVSEL // to /2. In this example, I will wait a bit of time to let inrush currents settle, // and then change DIVSEL from /4 to /2. This is only an example. The amount of // time you need to wait depends on the power supply feeding the DSP (i.e., how much // voltage droop occurs due to the inrush currents, and how long it takes the // voltage regulators to recover). SysCtrlRegs.PLLSTS.bit.MCLKOFF = 0; // Enable missing clock detect circuitry DelayUs(20/2); // Wait 20 us (just an example). Remember we're running // at half-speed here, so divide function argument by 2. SysCtrlRegs.PLLSTS.bit.DIVSEL = 0x2; // Change to /2 mode ] else [ // PLL is running in limp mode // User should replace the below with a call to an appropriate function, // for example shutdown the system (since something is very wrong!). asm(" ESTOP0"); ] //#endif // Initialize the PLL control: PLLCR and DIVSEL // DSP28_PLLCR and DSP28_DIVSEL are defined in DSP2833x_Examples.h //InitPll(DSP28_PLLCR,DSP28_DIVSEL); //--- Configure the clocks SysCtrlRegs.HISPCP.all = 0x0000; // Hi-speed periph clock prescaler, HSPCLK=SYSCLKOUT/1 SysCtrlRegs.LOSPCP.all = 0x0000; // Lo-speed periph clock prescaler, LOSPCLK=SYSCLKOUT/1 SysCtrlRegs.PCLKCR3.bit.GPIOINENCLK = 1; // GPIO input module is clocked SysCtrlRegs.PCLKCR3.bit.XINTFENCLK = 1; // XINTF module is clocked SysCtrlRegs.PCLKCR3.bit.DMAENCLK = 1; // SYSCLKOUT to DMA enabled SysCtrlRegs.PCLKCR3.bit.CPUTIMER2ENCLK = 1; // SYSCLKOUT to CPU Timer2 enabled SysCtrlRegs.PCLKCR3.bit.CPUTIMER1ENCLK = 1; // SYSCLKOUT to CPU Timer1 enabled SysCtrlRegs.PCLKCR3.bit.CPUTIMER0ENCLK = 1; // SYSCLKOUT to CPU Timer0 enabled SysCtrlRegs.PCLKCR1.bit.EQEP2ENCLK = 1; // SYSCLKOUT to eQEP2 enabled SysCtrlRegs.PCLKCR1.bit.EQEP1ENCLK = 1; // SYSCLKOUT to eQEP1 enabled SysCtrlRegs.PCLKCR1.bit.ECAP6ENCLK = 1; // SYSCLKOUT to eCAP6 enabled SysCtrlRegs.PCLKCR1.bit.ECAP5ENCLK = 1; // SYSCLKOUT to eCAP5 enabled SysCtrlRegs.PCLKCR1.bit.ECAP4ENCLK = 1; // SYSCLKOUT to eCAP4 enabled SysCtrlRegs.PCLKCR1.bit.ECAP3ENCLK = 1; // SYSCLKOUT to eCAP3 enabled SysCtrlRegs.PCLKCR1.bit.ECAP2ENCLK = 1; // SYSCLKOUT to eCAP2 enabled SysCtrlRegs.PCLKCR1.bit.ECAP1ENCLK = 1; // SYSCLKOUT to eCAP1 enabled SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 1; // SYSCLKOUT to ePWM6 enabled SysCtrlRegs.PCLKCR1.bit.EPWM5ENCLK = 1; // SYSCLKOUT to ePWM5 enabled SysCtrlRegs.PCLKCR1.bit.EPWM4ENCLK = 1; // SYSCLKOUT to ePWM4 enabled SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 1; // SYSCLKOUT to ePWM3 enabled SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 1; // SYSCLKOUT to ePWM2 enabled SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1; // SYSCLKOUT to ePWM1 enabled SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // Enable TBCLK within the ePWM SysCtrlRegs.PCLKCR0.bit.ECANBENCLK = 1; // SYSCLKOUT/2 to eCAN-B enabled SysCtrlRegs.PCLKCR0.bit.ECANAENCLK = 1; // SYSCLKOUT/2 to eCAN-A enabled SysCtrlRegs.PCLKCR0.bit.MCBSPAENCLK = 1; // LSPCLK to McBSP-A enabled SysCtrlRegs.PCLKCR0.bit.MCBSPBENCLK = 1; // LSPCLK to McBSP-B enabled SysCtrlRegs.PCLKCR0.bit.SCIBENCLK = 1; // LSPCLK to SCI-B enabled SysCtrlRegs.PCLKCR0.bit.SCIAENCLK = 1; // LSPCLK to SCI-A enabled SysCtrlRegs.PCLKCR0.bit.SPIAENCLK = 1; // LSPCLK to SPI-A enabled SysCtrlRegs.PCLKCR0.bit.SCICENCLK = 1; // LSPCLK to SCI-C enabled SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1; // LSPCLK to I2C-A enabled SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; // HSPCLK to ADC enabled // The PCLKCR0.TBCLKSYNC bit is handled separately in InitEPwm() since // it affects synchronization of the ePWM counters. //--- Configure the low-power modes SysCtrlRegs.LPMCR0.all = 0x00FC; // LPMCR0 set to default value //--- Finish up asm(" EDIS"); // Disable EALLOW protected register access ] // end InitSysCtrl() 寄存器肯定是写进去了,就是重新上电后SysCtrlRegs.PLLSTS.bit.MCLKSTS会置为1 导致无法在配置时钟 不知道为什么 quan |
|
|
|
|
|
|
|
|
|
|
|
Xiangjun, 根据你的描述(仿真模式下正常),建议可以先检查下硬件方面,主要用示波器看下复位电路和晶振的信号是否正常。谢谢! |
|
|
|
|
只有小组成员才能发言,加入小组>>
600 浏览 0 评论
1653 浏览 0 评论
2095 浏览 0 评论
为啥BQ7693003DBTR芯片在和BQ769X0盒子通讯时收不到信号?
1542 浏览 0 评论
DSP 28027F 开发板 XDS100v2调试探针诊断日志显示了 Error -150 (SC_ERR_FTDI_FAIL)如何解决
1385 浏览 0 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
1794浏览 29评论
2820浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
1748浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
1666浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
1680浏览 13评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-14 11:07 , Processed in 0.932711 second(s), Total 89, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2503