查看: 3056|回复: 0

[MQX] MCF51AC128 MQX时钟设置函数

[复制链接]

该用户从未签到

3

主题

13

帖子

0

新手上路

Rank: 1

积分
23
最后登录
1970-1-1
发表于 2012-10-4 18:34:20 | 显示全部楼层 |阅读模式
 static void _mqx_clock_init_20MHz()      
{
    VMCF51AC_MCG_STRUCT_PTR mcg_ptr =
        (VMCF51AC_MCG_STRUCT_PTR)&(((VMCF51AC_STRUCT_PTR)BSP_IPSBAR)->MCG);
 
 
  /* Configure MCG to run in PEE Mode */
  /* 20MHz bus clock from a 4MHz external crystal */
 
  /* set up external oscillator */
  mcg_ptr->MCGC2 = 0x26; /* RANGE = 1; HGO = 0; ERCLKEN=1; EREFS = 1; BDIV = 00 (/1); */
  
  /* wait for oscillator to initialize - poll on OSCINIT bit of MCGSC*/
  while (!(mcg_ptr->MCGSC & 0x02)){}
 
  /* Configure MCGC3 to access the proper RDIV values */
  mcg_ptr->MCGC3 = 0x10; /* DIV32 = 1; */
   
  /* Select Clock Mode and Reference Divider */
  mcg_ptr->MCGC1 = 0x90; /* CLKS = 10; RDIV = 2 (/4, /128 with DIV32=1); IREFS = 0; */

  /* wait for Reference Status bit to update - poll on IREFST bit*/
  while (mcg_ptr->MCGSC & 0x10){}
 
  /* Wait for clock status bits to update */
  while (((mcg_ptr->MCGSC & 0x0C)>>2) != 0b10){}       
 
  /* Configure MCGC3 to select PLL and VDIV */
  mcg_ptr->MCGC3 = 0x5A; /* PLLS =1; DIV32 = 1; VDIV = 1010 (x40) */
 
   /* wait for PLL status bit to update - poll on PLLST bit*/
  while (!(mcg_ptr->MCGSC & 0x20)){}
 
   /* Wait for LOCK bit to set - poll on LOCK bit*/
  while (!(mcg_ptr->MCGSC & 0x40)){}   //调试时候程序一直执行这里

  /* Now running PBE Mode */
 
  /* Transition into PEE */
  mcg_ptr->MCGC1 = 0x10; /* CLKS = 00; RDIV = 2 (/4 with PLLS=1); IREFS = 0; */

  /* Wait for clock status bits to update */
  while (((mcg_ptr->MCGSC & 0x0C)>>2) != 0b11){};          

  /* Now running PEE Mode */

    return;
}
查询下MCGSC 的第6位作用是判断PLL与FLL是否锁定,mcg_ptr->MCGSC & 0x40)的含义应该是已经锁定了,难道是这个库写错了???有没有人遇到一样的问题
我知道答案 目前已有0人回答
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条

Archiver|手机版|小黑屋|恩智浦技术社区

GMT+8, 2025-7-20 22:55 , Processed in 0.080951 second(s), 20 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表