【GD32450I-EVAL】简易示波演示
<p>淘了一块便宜的函数发生器回来,通过电阻分压后测算电压。通过液晶屏显示。</p><p>本来弄了个前置放大电路板子,可我模电水平实在不行,弄来弄去弄不好,只能直接分压了。</p>
<p>此时使用的是PA4引脚,ADC0通道4</p>
<p> </p>
<p>1-使用计时器每100ms进行一次连续转换</p>
<div aria-label="代码段 小部件" contenteditable="false" role="region" tabindex="-1">
<pre data-widget="codesnippet">
<code class="hljs"> timer_initpara.prescaler = 9999;
timer_initpara.period = 999;
timer_init(TIMER2,&timer_initpara);
timer_interrupt_enable(TIMER2, TIMER_INT_UP);
timer_interrupt_flag_clear(TIMER2, TIMER_INT_FLAG_UP);
// timer_interrupt_flag_clear(TIMER2, TIMER_INT_FLAG_CH1);
// dbg_periph_enable(DBG_TIMER2_HOLD);
nvic_irq_enable(TIMER2_IRQn, 1U, 0U);
/* enable TIMER2 */
timer_enable(TIMER2);</code></pre>
<img src="data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==" /><span style="background: url("https://bbs.eeworld.com.cn/static/editor/plugins/widget/images/handle.png") rgba(220, 220, 220, 0.5); top: -15px; left: 0px; display: block;"><img height="15" role="presentation" src="data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==" title="点击并拖拽以移动" width="15" /></span></div>
<p>2-定时器中断服务函数</p>
<div aria-label="代码段 小部件" contenteditable="false" role="region" tabindex="-1">
<pre data-widget="codesnippet">
<code class="hljs language-cpp"><span class="hljs-keyword">void</span> TIMER2_IRQHandler(<span class="hljs-keyword">void</span>)
{
<span class="hljs-keyword">if</span>(timer_interrupt_flag_get(TIMER2, TIMER_INT_FLAG_UP)==SET)
{
adc_special_function_config(ADC0, ADC_CONTINUOUS_MODE, ENABLE);
adc_software_trigger_enable(ADC0, ADC_REGULAR_CHANNEL);
timer_interrupt_flag_clear(TIMER2, TIMER_INT_FLAG_UP);
}
}</code></pre>
<img src="data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==" /><span style="background: url("https://bbs.eeworld.com.cn/static/editor/plugins/widget/images/handle.png") rgba(220, 220, 220, 0.5); top: -15px; left: 0px; display: block;"><img height="15" role="presentation" src="data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==" title="点击并拖拽以移动" width="15" /></span></div>
<p>3-ADC每次测试完480个点(刚好屏幕跨度像素)停止转换</p>
<pre>
<code class="language-cpp">void ADC_IRQHandler(void)
{
uint16_t i=0;
char t_char = "";
static int s_counter=0;
static uint16_t s_recorder;
uint16_t *t_displaySize;
if(adc_interrupt_flag_get(ADC0, ADC_INT_FLAG_EOC)==SET)
{
s_recorder = adc_regular_data_read(ADC0);
adc_counter++;
s_counter++;
if(s_counter>=480){
s_counter = 0;
adc_special_function_config(ADC0, ADC_CONTINUOUS_MODE, DISABLE);
t_displaySize = EXT_BUFFER0_ADDR;
memset((void *)EXT_BUFFER0_ADDR, 0, LCD_WIDTH * LCD_HEIGHT * LCD_FB_BYTE_PER_PIXEL * 2);
for (i = 0; i < 480; i++)
t_displaySize*272/0xFFF*480 + i] = 0xAAAA;
}
adc_interrupt_flag_clear(ADC0, ADC_INT_FLAG_EOC);
}
}</code></pre>
<p>4-其中,停止转换的时候将点写入到显示缓存</p>
<pre>
<code class="language-cpp"> for (i = 0; i < 480; i++)
t_displaySize*272/0xFFF*480 + i] = 0xAAAA;</code></pre>
<p> </p>
<p> </p>
<p>调整频率时的显示效果:</p>
<p></p>
<p>做得不错,给力</p>
<p><a href="https://bbs.eeworld.com.cn/thread-1140981-1-1.html" target="_blank">兆易GD32450I-EVAL</a></p>
<p>汇总贴:<a href="https://bbs.eeworld.com.cn/thread-1140981-1-1.html">https://bbs.eeworld.com.cn/thread-1140981-1-1.html</a></p>
<p>响应看起来挺快</p>
<p>感觉还不错,就是屏幕的UI设计的不太美观哈,功能挺不错的,但是这个个示波器的频率应该不会太高,可以简单的测量一些频率较低的波形,不过能做到这里非常厉害啦~点个赞!!!</p>
w494143467 发表于 2020-10-12 14:32
感觉还不错,就是屏幕的UI设计的不太美观哈,功能挺不错的,但是这个个示波器的频率应该不会太高,可以简单 ...
<p>其实一开始是想用 littlevgl 来显示,那就漂亮了,可是看着看着忽然发现用 littlevgl 的图标刷新率太感人了……那个刷新率做出来也没意义</p>
<p>楼主,有QQ么加一下,有偿请教您问题</p>
张少兵 发表于 2020-11-6 16:11
楼主,有QQ么加一下,有偿请教您问题
<p>什么问题先直接说一下吧,能在论坛里说清楚就直接论坛里搞定了</p>
页:
[1]