在线时间6 小时
UID62323
ST金币0
蝴蝶豆0
注册时间2008-7-29
初级会员
- 最后登录
- 2018-9-8
|
a0a.1 0b0c
兄弟用ST LIB3.40的库, SMT32F103RET6.
DAC+DMA的例子,不知道为什么就是不对.
没有波形出来.............
请问这是为什么啊??????????????
请大家指点一二..................
00001 /**
00002 ******************************************************************************
00003 * @file DAC/OneChannelDMA_Escalator/main.c
00004 * @author MCD Application Team
00005 * @version V3.4.0
00006 * @date 10/15/2010
00007 * @brief Main program body.
00008 ******************************************************************************
00009 * @copy
00010 *
00011 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00012 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00013 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00014 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00015 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00016 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00017 *
00018 * © COPYRIGHT 2010 STMicroelectronics
00019 */
00020
00021 /* Includes ------------------------------------------------------------------*/
00022 #include "[url=mkMSITStore:F:\StudyST\STM32\stm32f10x_stdperiph_lib3.40\STM32F10x_StdPeriph_Lib_V3.4.0\stm32f10x_stdperiph_lib_um.chm::/stm32f10x_8h.html]stm32f10x.h[/url]"
00023
00024 /** @addtogroup STM32F10x_StdPeriph_Examples
00025 * @{
00026 */
00027
00028 /** @addtogroup DAC_OneChannelDMA_Escalator
00029 * @{
00030 */
00031
00032 /* Private typedef -----------------------------------------------------------*/
00033 /* Private define ------------------------------------------------------------*/
[url=mkMSITStore:F:\StudyST\STM32\stm32f10x_stdperiph_lib3.40\STM32F10x_StdPeriph_Lib_V3.4.0\stm32f10x_stdperiph_lib_um.chm::/group__DAC__OneChannelDMA__Escalator.html#ga4e2356d33008f4f2f62ea7192a837b20]00034[/url] #define DAC_DHR8R1_Address 0x40007410
00035
00036 /* Init Structure definition */
[url=mkMSITStore:F:\StudyST\STM32\stm32f10x_stdperiph_lib3.40\STM32F10x_StdPeriph_Lib_V3.4.0\stm32f10x_stdperiph_lib_um.chm::/group__DAC__OneChannelDMA__Escalator.html#ga9f54bfd3711229dd98a67fd037b07be1]00037[/url] [url=mkMSITStore:F:\StudyST\STM32\stm32f10x_stdperiph_lib3.40\STM32F10x_StdPeriph_Lib_V3.4.0\stm32f10x_stdperiph_lib_um.chm::/structDAC__InitTypeDef.html]DAC_InitTypeDef[/url] [url=mkMSITStore:F:\StudyST\STM32\stm32f10x_stdperiph_lib3.40\STM32F10x_StdPeriph_Lib_V3.4.0\stm32f10x_stdperiph_lib_um.chm::/group__DAC__DualModeDMA__SineWave.html#ga9f54bfd3711229dd98a67fd037b07be1]DAC_InitStructure[/url];
[url=mkMSITStore:F:\StudyST\STM32\stm32f10x_stdperiph_lib3.40\STM32F10x_StdPeriph_Lib_V3.4.0\stm32f10x_stdperiph_lib_um.chm::/group__DAC__OneChannelDMA__Escalator.html#gae0d08750e73250f6a9953cd0724658a3]00038[/url] [url=mkMSITStore:F:\StudyST\STM32\stm32f10x_stdperiph_lib3.40\STM32F10x_StdPeriph_Lib_V3.4.0\stm32f10x_stdperiph_lib_um.chm::/structDMA__InitTypeDef.html]DMA_InitTypeDef[/url] [url=mkMSITStore:F:\StudyST\STM32\stm32f10x_stdperiph_lib3.40\STM32F10x_StdPeriph_Lib_V3.4.0\stm32f10x_stdperiph_lib_um.chm::/group__ADC__3ADCs__DMA.html#gae0d08750e73250f6a9953cd0724658a3]DMA_InitStructure[/url];
00039
00040 /* Private macro -------------------------------------------------------------*/
00041 /* Private variables ---------------------------------------------------------*/
[url=mkMSITStore:F:\StudyST\STM32\stm32f10x_stdperiph_lib3.40\STM32F10x_StdPeriph_Lib_V3.4.0\stm32f10x_stdperiph_lib_um.chm::/group__DAC__OneChannelDMA__Escalator.html#ga588f3c9b10d203056c55e23e7c6d7ea4]00042[/url] const uint8_t [url=mkMSITStore:F:\StudyST\STM32\stm32f10x_stdperiph_lib3.40\STM32F10x_StdPeriph_Lib_V3.4.0\stm32f10x_stdperiph_lib_um.chm::/group__DAC__OneChannelDMA__Escalator.html#ga588f3c9b10d203056c55e23e7c6d7ea4]Escalator8bit[/url][6] = {0x0, 0x33, 0x66, 0x99, 0xCC, 0xFF};
00043
00044 /* Private function prototypes -----------------------------------------------*/
00045 void RCC_Configuration(void);
00046 void GPIO_Configuration(void);
00047 void Delay(__IO uint32_t nCount);
00048
00049 /* Private functions ---------------------------------------------------------*/
00050
00051 /**
00052 * @brief Main program.
00053 * @param None
00054 * @retval None
00055 */
00056 int main(void)
00057 {
00058 /*!< At this stage the microcontroller clock setting is already configured,
00059 this is done through SystemInit() function which is called from startup
00060 file (startup_stm32f10x_xx.s) before to branch to application main.
00061 To reconfigure the default setting of SystemInit() function, refer to
00062 system_stm32f10x.c file
00063 */
00064
00065 /* System Clocks Configuration */
00066 RCC_Configuration();
00067
00068 /* Once the DAC channel is enabled, the corresponding GPIO pin is automatically
00069 connected to the DAC converter. In order to avoid parasitic consumption,
00070 the GPIO pin should be configured in analog */
00071 GPIO_Configuration();
00072
00073 /* TIM6 Configuration */
00074 TIM_PrescalerConfig(TIM6, 0xF, TIM_PSCReloadMode_Update);
00075 TIM_SetAutoreload(TIM6, 0xFF);
00076 /* TIM6 TRGO selection */
00077 TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);
00078
00079 /* DAC channel1 Configuration */
00080 DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO;
00081 DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
00082 DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
00083 DAC_Init(DAC_Channel_1, &DAC_InitStructure);
00084
00085 #if !defined STM32F10X_LD_VL && !defined STM32F10X_MD_VL
00086 /* DMA2 channel3 configuration */
00087 DMA_DeInit(DMA2_Channel3);
00088 #else
00089 /* DMA1 channel3 configuration */
00090 DMA_DeInit(DMA1_Channel3);
00091 #endif
00092
00093 DMA_InitStructure.DMA_PeripheralBaseAddr = DAC_DHR8R1_Address;
00094 DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&Escalator8bit;
00095 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
00096 DMA_InitStructure.DMA_BufferSize = 6;
00097 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
00098 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
00099 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
00100 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
00101 DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
00102 DMA_InitStructure.DMA_Priority = DMA_Priority_High;
00103 DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
00104
00105 #if !defined STM32F10X_LD_VL && !defined STM32F10X_MD_VL
00106 DMA_Init(DMA2_Channel3, &DMA_InitStructure);
00107 /* Enable DMA2 Channel3 */
00108 DMA_Cmd(DMA2_Channel3, ENABLE);
00109 #else
00110 DMA_Init(DMA1_Channel3, &DMA_InitStructure);
00111 /* Enable DMA1 Channel3 */
00112 DMA_Cmd( |
|