野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 15591|回复: 2

液晶显示英文和adc超级终端显示电压两个程序合并

[复制链接]
发表于 2014-8-19 11:29:30 | 显示全部楼层 |阅读模式
本帖最后由 3050271923 于 2014-8-19 11:30 编辑

小弟想把液晶显示英文和adc超级终端显示电压两个程序合并,使之在液晶上显示出电压,从dma读数据给fsmc显示出来的数字却是好几千,如果单纯显示数字又是可以的,求大师解答!以下是我修改的主函数
#include "stm32f10x.h"
#include "bsp_usart1.h"
#include "bsp_adc.h"
#include "bsp_ili9341_lcd.h"
extern void Lcd_Delay(__IO uint32_t nCount);

// ADC1×a»»μÄμçÑ1Öμí¨1yMDA·½ê½′«μ½SRAM
extern __IO uint16_t ADC_ConvertedValue;

// ¾Ö2¿±äá¿£¬óÃóú±£′æ×a»»¼ÆËãoóμÄμçÑ1Öμ          
float ADC_ConvertedValueLocal;        

// èí¼tÑóê±
void Delay(__IO uint32_t nCount)
{
  for(; nCount != 0; nCount--);
}
uint16_t n,h;
/**
  * @brief  Ö÷oˉêy
  * @param  ÎT
  * @retval ÎT
  */
int main(void)
{       
        /* USART1 config */
        //USART1_Config();
        /* enable adc1 and config adc1 to dma mode */

        LCD_Init();       

        LCD_Clear(0, 0, 240, 320, BACKGROUND);       

        LCD_DispChar(40, 40, 'A', RED);
        LCD_DispStr(10, 10, (uint8_t *)"This is a vcc zhang lei display asci", RED);       
       
        LCD_DispStr(40, 100, (uint8_t *)"count:", RED);
                ADC1_Init();
       
        //printf("\r\n ----ÕaêÇò»¸öADCêμÑé(DMA′«êä)----\r\n");
       
while (1)
        {
               
                ADC_ConvertedValueLocal =(float) ADC_ConvertedValue/4096*3.3;  // ¶áè¡×a»»μÄADÖμ
       
    n=(uint16_t)ADC_ConvertedValue;
          h=(uint16_t)(1000*(ADC_ConvertedValueLocal-n));
          LCD_DisNum(100, 100, n, RED);
    LCD_DisNum(130, 100, h, RED);
                Lcd_Delay(0xAFFf>>4);
       
       
        //        printf("\r\n The current AD value = 0x%04X \r\n", ADC_ConvertedValue);
                //printf("\r\n The current AD value = %f V \r\n",ADC_ConvertedValueLocal);

                Delay(0xffffee);  
        }
               
}
回复

使用道具 举报

发表于 2014-8-19 11:42:43 | 显示全部楼层
把adc采样得的数字变量使用sprintf函数,转化成字符串,然后调用程序里的字符串显示函数来显示
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-22 10:55:33 | 显示全部楼层
有具体代码吗?学stm32我感觉真的好蒙;
回复 支持 反对

使用道具 举报

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

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-6-28 20:40 , Processed in 0.047188 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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