<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ME05 ADC_STS标志清除时序问题与规避方案]]></title><description><![CDATA[<h1>1. 问题总结</h1>
<h2>1.1 核心结论</h2>
<p dir="auto">ADC 的 STS 寄存器中 EOS、SQ、SEQ 等标志位为写 1 清零。写 1 只发起清除请求，标志位需要  <strong>6 个 ADC 功能时钟</strong>（fADC） 才真正变为 0。</p>
<h2>1.2 问题表现</h2>
<p dir="auto">若清标志与下一次启动转换的间隔不足 6 个 fADC 周期，标志尚未清除即进入下一流程，FIFO 返回的仍是上一通道的采样结果，表现为通道错位。</p>
<h1>2. 问题机理</h1>
<h2>2.1 清除窗口为 6 个功能时钟</h2>
<p dir="auto">STS 标志的复位由 ADC 功能时钟域完成，软件写 1 与位真正翻转之间固定相差 6 个 fADC 周期。窗口期内回读 STS 仍返回 1，FIFO 也未按新一次转换刷新。两种时序的差异如下。<br />
<img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/27/403d43bf-246f-4564-8516-39e758cfef64.png" alt="3ff1ab59-49f2-4dbd-ade1-057e2427971e-image.png" class=" img-fluid img-markdown" /></p>
<h2>2.2 故障特征</h2>
<p dir="auto">该问题不带随机性，但极易被误判为通道配置错误，可按表 1 的三条特征交叉判断。<br />
<img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/27/31918502-3545-470d-a745-63773b7579ac.png" alt="1c308bb0-e67c-4a10-a423-7313407de6e8-image.png" class=" img-fluid img-markdown" /><br />
(清标志时序不足的典型表现。三条同时出现，基本可判定为时序问题。)</p>
<h1>3. 测试记录</h1>
<ol>
<li>一开始调试时没有在第10行加EOSEQ等待标志清零，测试发现ADC切换了通道后总是会错位；</li>
<li>之后在该处加了<strong>等待标志清零</strong>或<strong>加延时</strong>后，问题消失。</li>
</ol>
<pre><code>static uint16 BootCheck_ReadChannel(uint8 channel)
{
    volatile ADC_Type *adc = ADC0;
    uint16 raw;

    adc-&gt;CHSEL[0] = channel;
    /* 清序列结束标志 */
    adc-&gt;STS = ADC_STS_EOSEQ_MASK;
    /* 确认旧完成标志已清零，避免将其误判为本次转换完成。 */
    while (0U != (adc-&gt;STS &amp; ADC_STS_EOSEQ_MASK))
    {
    }
    /* 启动转换 */
    adc-&gt;CTRL |= ADC_CTRL_ADSTART_MASK;
    /* 等待序列转换完成 */
    while (0U == (adc-&gt;STS &amp; ADC_STS_EOSEQ_MASK))
    {
        /* 等待转换完成 */
    }
    raw = (uint16)(adc-&gt;FIFO &amp; ADC_FIFO_DATA_MASK);

    return raw;
}
</code></pre>
<p dir="auto"><img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/27/5bdb3f08-38ee-43a7-ae15-1a2f6ba58642.png" alt="18de63e4-b226-47ec-962e-bc32d31efce4-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.ytmicro.com/topic/2355/me05-adc_sts标志清除时序问题与规避方案</link><generator>RSS for Node</generator><lastBuildDate>Sat, 14 Nov 2026 02:17:00 GMT</lastBuildDate><atom:link href="https://forum.ytmicro.com/topic/2355.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 13 Nov 2026 07:02:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ME05 ADC_STS标志清除时序问题与规避方案 on Fri, 13 Nov 2026 07:19:28 GMT]]></title><description><![CDATA[<p dir="auto">规避方案仅供参考。建议加timeout，不要一直while</p>
]]></description><link>https://forum.ytmicro.com/post/10104</link><guid isPermaLink="true">https://forum.ytmicro.com/post/10104</guid><dc:creator><![CDATA[Frankie]]></dc:creator><pubDate>Fri, 13 Nov 2026 07:19:28 GMT</pubDate></item></channel></rss>