打印

高分求解~~如何判断时钟是同步还是异步的??

[复制链接]
7603|14
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
hwk612167|  楼主 | 2012-3-5 09:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 hwk612167 于 2012-3-5 14:35 编辑

例如ALCK用外部32KHz,主时钟通过FLL倍频而来,那么MCLK和ACLK算异步时钟了???具体怎么判别,网上没搜到相关资料,太简单了么?

附图中说timer未停止的情况下读TAR有可能出现错误的数据,写TAR立即生效,那么timer不停止情况下会不会写错呢???

note.JPG (68.41 KB )

note.JPG

相关帖子

沙发
hwk612167|  楼主 | 2012-3-5 09:51 | 只看该作者
本帖最后由 hwk612167 于 2012-3-5 13:49 编辑

NULL

使用特权

评论回复
板凳
hwk612167|  楼主 | 2012-3-5 11:49 | 只看该作者
2小时 0回复  继续顶~

使用特权

评论回复
地板
hwk612167|  楼主 | 2012-3-5 13:19 | 只看该作者
本帖最后由 hwk612167 于 2012-3-5 13:49 编辑

:handshake

使用特权

评论回复
5
jamie-ma| | 2012-3-5 14:01 | 只看该作者
偶路过,不清楚,帮LZ顶一下哈。:D

使用特权

评论回复
6
小鸡| | 2012-3-5 14:13 | 只看该作者
没人回答吗,帮lz顶起哈

使用特权

评论回复
7
hwk612167|  楼主 | 2012-3-5 16:35 | 只看该作者
顶起。。。晚上才人多么

使用特权

评论回复
8
hwk612167|  楼主 | 2012-3-6 09:07 | 只看该作者
:(

使用特权

评论回复
9
TI_MCU| | 2012-3-7 10:01 | 只看该作者
是不会写错的,但是建议不要这样操作,因为运行中修改寄存器值可能会让Timer进入未知的错误状态

使用特权

评论回复
10
modernthink| | 2012-3-7 18:41 | 只看该作者
这是一个典型对异步时钟操作的问题,总结起来说,Timer的TAR操作。
若是写操作,一定要让Timer先Halt,完成写操作再重新启动。
而读操作,考虑到会读到错误的数值,推荐可以连续读3次或者5次,然后用投票的方式得到TAR的数值。

使用特权

评论回复
11
永远的不知| | 2012-3-7 21:01 | 只看该作者
这个是异步操作,所谓的异步,只要不是同一个时钟,哪怕频率一样,都属于异步;
最好不要异步对定时器操作;我原来CPU跑在MCLK使用1M频率,定时器使用ACLK,使用“mov.w &TAR,R1;" 读TAR中的值,后来发现有时候读出来的值很奇怪,导致逻辑错误;在430的user guide中有描述”When the TACLK is asynchronous to the CPU clock, any read from TAR should occur while the timer is not operating or the results may be unpredictable.“

使用特权

评论回复
12
永远的不知| | 2012-3-7 21:24 | 只看该作者
本帖最后由 永远的不知 于 2012-3-7 21:28 编辑

11# modernthink
基于我楼上所说,最好不要直接异步读定时器。以下引用N年前,TI的Vincent给我的答复,很专业。

There is a possible problem with the software code in this line:
                  mov.w &TAR,rComTemp;         //记录进入中断时间
    Please refer to the diagram below:

    见图1
    The Timer Clock is your 455KHz TAR input clock.
    Our TAR counter is a ripple counter.
  
    The MCU is run using DCO clock, this clock is asynchronous with the Timer Clock.

    So when you try to capture the TAR value by reading the TAR register, it is similar to the CCI event above.

    The actual read may happen between the value
n-1 and n when the internal counter bits are changing.

    As a result you may read a wrong number which is not n nor n-1. This number can be very wrong.
    This can upset your timing offset calculation.

   
    The best way to deal with this is to use the hardware provided by Timer_A.
    Use the Timer_A capture mode with the SCS bit set to enable Synchronous Capture Mode.
    Setting the SCS bit will synchronize the capture with the next timer clock as shown below.

    见图2

    Now the captured value is always safe.

    Attached are example codes in C and assembly for UART TX/RX which demonstrate this feature.

    Please note this line which enables the synchronous mode:

SetupRX     mov.w   #CM1+CCIS0+SCS+OUTMOD0+CAP+CCIE,&CCTL0; Neg Edge,Sync,cap

    Additional information can be found in our Users Guide 11.2.4 Capture/Compare Blocks





    I notice that you are using I/O port for your interrupt.
    In which case your are not using th built in hardware of Timer_A and you need to use a software check.

    In C it looks like this:

unsigned int a,b,c;

  do
    {
    a=TAR;
    b=TAR;
    c=b-a;
    }
    while(abs(c)>10);

    This function tries to catch an erroneous read from TAR. It only finishes when two TAR reads are within a small difference.
    The value 10 is arbitrary and you can adjust it to suit your program.

    Obviously I would recommend you to use the hardware provided by the Timer_A since this gives you the best solution.

1.jpg (11.5 KB )

1.jpg

2.jpg (16.82 KB )

2.jpg

使用特权

评论回复
13
modernthink| | 2012-3-8 16:52 | 只看该作者
呵呵,Vincent大神的回复。能用capture模式来做当然最安全。其实这个问题在很久以前讨论的挺多的,那时候430器件Timer资源比较少,很多时候,CCRx资源用完了,而又要软件来计算一个一段时间的延时时,就只能靠直接读取TAR这种方法了。

使用特权

评论回复
14
peter_zheng| | 2012-3-8 21:26 | 只看该作者
异步就是时钟源不一样。aclk如果来自外部晶振,mclk如果不是来源于由外部晶振倍频的那么就是异步的

使用特权

评论回复
15
lianshumou| | 2012-3-9 08:48 | 只看该作者
判断是不是异步时钟,就看这两个或是多个时钟是不是一个妈生的.  如果不是一个妈生的,那肯定是异步的,但如果是一个妈生的, 除非个例,其本就算同步时钟了

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:前进 前进 前进

20

主题

511

帖子

3

粉丝