我爱下载 发表于 2020-12-5 12:09

【AutoChips AC7801x电机demo板测评】+关键外设测试-HALL采集

本帖最后由 我爱下载 于 2020-12-5 12:15 编辑

<p class="MsoTitle" style="text-align:center; margin-top:16px; margin-bottom:4px"><span style="font-size:16pt"><span style="font-family:Cambria,serif"><span style="font-weight:bold"><span style="font-family:宋体">关键外设测试</span></span></span></span></p>

<p style="text-align: center;"><span style="font-size:16pt"><span style="line-height:130%"><span style="font-family:Cambria,serif"><span style="font-weight:bold"><span style="font-family:宋体">&mdash;&mdash;</span>HALL<span style="font-family:宋体">接口的测试</span></span></span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp;</p>

<ol>
        <li><span style="font-size:16pt"><span style="line-height:150%"><span style="font-family:宋体"><span style="font-weight:normal">硬件接口</span></span></span></span></li>
</ol>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">如前述所描述,系统主板集成了一个</span>HALL<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">接口,允许输入电机的位置传感器信号。</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="margin-bottom:13px"></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">根据数据手册和原理图中的描述,可以知道,线路板采用</span>PWDT1<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">作为霍尔元件的输出采集端,连接到</span>PC6<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">、</span>PC7<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">、</span>PC8<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">三个引脚。当然,还有</span>5V<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">电源和地。</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<ol start="2">
        <li><span style="font-size:16pt"><span style="line-height:150%"><span style="font-family:宋体"><span style="font-weight:normal">软件设置</span></span></span></span>&nbsp; &nbsp;&nbsp;</li>
</ol>

<ul>
        <li><span style="font-size:14pt"><span style="line-height:150%"><span style="font-family:宋体"><span style="font-weight:normal">PWDT模块</span></span></span></span></li>
</ul>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">AC7801x<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">控制器内部集成了</span>PWDT<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">外设,可以用来采集霍尔信号的输入,可以输出霍尔状态,霍尔输入信号高低电平的时间,从而求出霍尔信号的频率,占空比等信号。</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PWDT<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">的机构框图</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="margin-bottom:13px"></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 霍尔测量模式</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;两种常见的</span>Hall<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">安装方式</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<ul>
        <li><span style="font-size:14pt"><span style="line-height:150%"><span style="font-family:宋体"><span style="font-weight:normal">配置PWDT模块</span></span></span></span></li>
</ul>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="margin-bottom:13px"></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<ul>
        <li><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp; &nbsp; &nbsp;<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">生成的初始化代码</span></span></span></li>
</ul>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">/* PWDT1 init function */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">static void ATC_PWDT1_Init(void)</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">{</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; /* USER CODE BEGIN PWDT1_Init 0 */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; /* USER CODE END PWDT1_Init 0 */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; PWDT_ConfigType pwdtConfig;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; /* USER CODE BEGIN PWDT1_Init 1 */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; /* USER CODE END PWDT1_Init 1 */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; MSP_PWDT_Init(PWDT1);</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.clkPsc = PWDT_CLK_PRESCALER_1;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.edgeType = PWDT_RISING_START_CAPTURE_ALL;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.channel = PWDT_INPUT_CH_0;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.overflowInterruptEn = ENABLE;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.readyInterruptEn = ENABLE;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.interruptEn = ENABLE;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.cmpModeEn = DISABLE;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.mode = PWDT_MEASURE_MODE;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.hallModeEn = ENABLE;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.filterPsc = PWDT_FILTER_PRESCALER_1;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.filterValue = 10;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.filterEn = ENABLE;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; pwdtConfig.callBack = PWDT1_IRQHandler_Callback;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp; PWDT_Init(PWDT1, &amp;pwdtConfig);</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; /* USER CODE BEGIN PWDT1_Init 2 */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; /* USER CODE END PWDT1_Init 2 */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">}</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">生成的中断处理函数</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">/**</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">* <a href="home.php?mod=space&amp;uid=159083" target="_blank">@brief</a> This function handle PWDT1 interrupt.</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">* @param device: PWDT_Type pointer</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">* @param wpara: callback parameter</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">* @param lpara: callback parameter</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">* <a href="home.php?mod=space&amp;uid=784970" target="_blank">@return</a> none</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">*/</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">void PWDT1_IRQHandler_Callback(void *device, uint32_t wpara, uint32_t lpara)</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">{</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; if (wpara &amp; PWDT_INIT0_OVF_Msk)</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; {</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* USER CODE BEGIN OVERFLOW INTERRUPT */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* USER CODE END OVERFLOW INTERRUPT */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; }</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; if (wpara &amp; PWM_STR_CHSF_Msk)</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp; &nbsp;{</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* USER CODE BEGIN PLUSE PLUSE EFFECTIVE */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* USER CODE END PLUSE PLUSE EFFECTIVE */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; }</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; /* USER CODE BEGIN PWDT1_IRQHandler_Callback */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp; /* USER CODE END PWDT1_IRQHandler_Callback */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">}</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp;</p>

<ul>
        <li><span style="font-size:14pt"><span style="line-height:150%"><span style="font-family:宋体"><span style="font-weight:normal">处理函数</span></span></span></span></li>
</ul>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* USER CODE BEGIN PLUSE PLUSE EFFECTIVE */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_hallStatus = PWDT_GetHallStatus(PWDT) &amp; 0x07;</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_positvePulse = PWDT_GetPositivePulseWidth(PWDT); //<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">获取正脉宽计数值</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_negativePulse = PWDT_GetNegativePulseWidth(PWDT); //<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">获取负脉宽计数值</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (0 != (g_positvePulse + g_negativePulse))</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">计算频率和占空比</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">频率</span> = PWDT<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">时钟源</span> / PWDT<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">时钟分频</span> / <span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">正</span>+<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">负脉宽计数值</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">占空比</span> = <span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">正脉宽计数值</span> / <span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">正</span>+<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">负脉宽计数值</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_freq = PWDT_CLK / (g_positvePulse + g_negativePulse);</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_duty = ((g_positvePulse * 100)/ (g_positvePulse + g_negativePulse)); </span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* USER CODE END PLUSE PLUSE EFFECTIVE */</span></span>&nbsp; &nbsp; &nbsp; &nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<ol start="3"><br />
        <li><span style="font-size:16pt"><span style="line-height:150%"><span style="font-family:宋体"><span style="font-weight:normal">效果展示</span></span></span></span></li>
</ol>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">电机霍尔线的硬件连接图</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="margin-bottom:13px"></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="margin-left:28px; margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">利用</span>uart<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">端口将霍尔信号</span> <span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">的输入状态打印到串口终端中。通过终端打印可以清晰的看到霍尔信号的变化过程为</span>1-5-4-6-2-3<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">。</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">结论,通过对于特定电机及预想的电机转速测量范围,可以进一步调整</span>PWDT<span style="font-family:&quot;微软雅黑&quot;,&quot;sans-serif&quot;">的预分频系数,来保证转速测量范围。</span></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="margin-bottom:13px">&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

w494143467 发表于 2020-12-5 13:34

<p>还不错,知识点讲的挺好,就喜欢这种分享知识和代码的帖子!</p>

我爱下载 发表于 2020-12-5 15:44

w494143467 发表于 2020-12-5 13:34
还不错,知识点讲的挺好,就喜欢这种分享知识和代码的帖子!

<p>谢谢鼓励,继续努力,共同学习</p>

freebsder 发表于 2020-12-6 22:29

<p>谢谢分享</p>

专业PCB 发表于 2020-12-9 10:00

<p>谢谢分享</p>
页: [1]
查看完整版本: 【AutoChips AC7801x电机demo板测评】+关键外设测试-HALL采集