你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【STM32F429开发日志】(0)+示波器

[复制链接]
stentor 提问时间:2014-7-10 22:43 /
 自己之前做的一个示波器,只用了LCD的底层驱动,没用系统及GUI
将C文件替换到固件包的STM32F429I-Discovery_FW_V1.0.1\Projects\Template下,运行即可
代码贴上看看:
/**
  ******************************************************************************
  * @file    ADC_TripleModeInterleaved/main.c
  * @author  MCD Application Team
  * @version V1.0.1
  * @date    11-November-2013
  * @brief   This example provides a short description of how to use the ADC 
  *          peripheral to convert a regular channel in Triple interleaved mode 
  *          using DMA in mode 2 with 8.4Msps .
  ******************************************************************************
  * @attention
  *
  * © COPYRIGHT 2013 STMicroelectronics


  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        http://www.st.com/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */
 
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include
 
/** @addtogroup STM32F429I_DISCOVERY_Examples
  * @{
  */
 
/** @addtogroup ADC_TripleModeInterleaved
  * @{
  */
 
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/ 
  #define MESSAGE1   "  Triple ADC Interleaved      "
  #define MESSAGE1_1 "  DMA mode2 example           " 
  #define MESSAGE2   " ADC Ch13 Conv " 
  #define MESSAGE2_1 "    8.4Msps      "
  #define MESSAGE3   "Connect voltage "
  #define MESSAGE4   "to ADC Ch13   "
  #define MESSAGE5   " ADC1 = %d,%d V"
  #define MESSAGE6   " ADC2 = %d,%d V"
  #define MESSAGE7   " ADC3 = %d,%d V"
  #define LINENUM            0x15
  #define FONTSIZE         Font8x12
 
 
uint8_t aTextBuffer[50];       
int ADC_Value[4096];
int ADC_ValueSec[4096];
int i=0;
int Zero[8] = {0,0,0,0,0,0,0,0};
int ZeroFlag = 1;
 
 
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
__IO uint32_t uhADCTripleConvertedValue[3];
  
/* Private function prototypes -----------------------------------------------*/
 
 
#ifdef USE_LCD
static void Display_Init(void);
static void Display(void);
void gridon(void);
#endif /* USE_LCD */
 
 
 
 
void DAC_Ch1_Config(void)
{
        GPIO_InitTypeDef  GPIO_InitStructure;//
        DAC_InitTypeDef DAC_InitStructure;
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); //?? DCA ??
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; //DAC_OUT1=PA.4
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; //??? AN ??
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //??????
        GPIO_Init(GPIOA, &GPIO_InitStructure); // ? ? ? ? ? ?GPIOA
       
        DAC_InitStructure.DAC_Trigger = DAC_Trigger_Software ; //????
        DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; //?????
        DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude= DAC_TriangleAmplitude_2047;//???
        DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; //????
        DAC_Init(DAC_Channel_2, &DAC_InitStructure); // ?????? DAC1
        DAC_Cmd(DAC_Channel_2, ENABLE); // ?? DAC1 ??
       
        DAC_SetChannel2Data(DAC_Align_12b_R, 1000); //????? 0
        DAC_SoftwareTriggerCmd(DAC_Channel_2, ENABLE); ///??????
}
 
 
void DAC1_SET(unsigned int date)
{
        DAC_SetChannel2Data(DAC_Align_12b_R, date ); //????
        DAC_SoftwareTriggerCmd(DAC_Channel_2, ENABLE); //??????
}
/* Private functions ---------------------------------------------------------*/
 
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
 
 
/**
  * @brief  ADC configuration
  * @note   This function Configure the ADC peripheral  
            1) Enable peripheral clocks
            2) Configure ADC Channel 13 pin as analog input
            3) DMA2_Stream0 channel0 configuration
            4) Configure ADC1 Channel 13
            5) Configure ADC2 Channel 13
            6) Configure ADC3 Channel 13
  * @param  None
  * @retval None
  */
static void GPIO_Configuration(void)
  {                
  GPIO_InitTypeDef GPIO_InitStructure;        
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,ENABLE);        
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
}
 
void Gyro_ADC_Configuration(uint8_t ADC_SampleTime_Cycles)
{
          ADC_InitTypeDef       ADC_InitStructure;
          ADC_CommonInitTypeDef ADC_CommonInitStructure;                
          RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC2, ENABLE);        
        /* ADC Common Init **********************************************************/
          ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
          ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
          ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
          ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
          ADC_CommonInit(&ADC_CommonInitStructure);
 
        /* ADC2 Init ****************************************************************/
          ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
          ADC_InitStructure.ADC_ScanConvMode = ENABLE;
          ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
          ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
          ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
          ADC_InitStructure.ADC_NbrOfConversion = 1;
          ADC_Init(ADC2, &ADC_InitStructure);        
          ADC_ITConfig(ADC2, ADC_IT_EOC, ENABLE);
 
 
        ADC_RegularChannelConfig(ADC2, ADC_Channel_13, 1, ADC_SampleTime_Cycles);
        /* Enable ADC2 */
          ADC_Cmd(ADC2, ENABLE);
          /* Start ADC2 Software Conversion */ 
        ADC_SoftwareStartConv(ADC2);
 
 
}
/* Functions --------------------------------------------------------------------------------*/
 
void ADC_Config(uint8_t ADC_SampleTime_Cycles)
{
  GPIO_Configuration();
        Gyro_ADC_Configuration(ADC_SampleTime_Cycles);
}
 
 
uint16_t Get_ADC_Data(void)
{
   while(!(ADC_GetFlagStatus(ADC2, ADC_FLAG_EOC)==SET));
         return(ADC_GetConversionValue(ADC2));
}
#ifdef USE_LCD
/**
  * @brief  Display ADCs converted values on LCD
  * @param  None
  * @retval None
  */
static void Display(void)
{
        int delay = 20000,a=1000000000;
        int i=0,j=0;
       
        float ff = 150*4096/255;
       
       
        int tmpMax,tmpMin,cha,div,tmpMaxNum,tmpMinNum,offset,trigger,triggerflag = 0,temp1 = 0,temp2 = 0;
        int temp1flag = 0,temp2flag = 0;
        float Vpp;
       
       

                for(i=0;i
收藏 1 评论5 发布时间:2014-7-10 22:43

举报

5个回答
sssxs 回答时间:2015-6-23 10:59:25
源码没贴完整啊  请详细贴出源码 和操作方法 谢谢了
秋水时至 回答时间:2015-8-25 00:12:31
对啊,代码要贴完整才好嘛。。
JackieLaura 回答时间:2015-8-26 09:23:11
F429 discovery的示波器不错
stmcu.org.png
bigvan2012 回答时间:2015-8-27 10:07:58
顶一个,Good!
胤幻1988 回答时间:2018-11-1 12:39:47
就是个坑啊~
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32Cube扩展软件包
意法半导体边缘AI套件
ST - 理想汽车豪华SUV案例
ST意法半导体智能家居案例
STM32 ARM Cortex 32位微控制器
关注我们
st-img 微信公众号
st-img 手机版