这里是lib3.40的DAC例子,并且用了DMA,其中只有一个通道.
为什么我COPY下来就不能用了呢????
没有输出波形,哪个做出来,给说一说,我哪里坐错了...
谢谢!!!!!!!!!!!!!
以下是例子程序!!!!!!!!!!!!!
#include "stm32f10x.h"
#define DAC_DHR8R1_Address 0x40007410
DAC_InitTypeDef DAC_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
const uint8_t Escalator8bit[6] = {0x0, 0x33, 0x66, 0x99, 0xCC, 0xFF};
RCC_Configuration(void);
void GPIO_Configuration(void);
void Delay(__IO uint32_t nCount);
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
TIM_PrescalerConfig(TIM6, 0xF, TIM_PSCReloadMode_Update);
TIM_SetAutoreload(TIM6, 0xFF);
TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);
DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
DMA_DeInit(DMA2_Channel3);
DMA_InitStructure.DMA_PeripheralBaseAddr = DAC_DHR8R1_Address;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&Escalator8bit;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 6;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = MA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA2_Channel3, &DMA_InitStructure);
DMA_Cmd(DMA2_Channel3, ENABLE);
DAC_Cmd(DAC_Channel_1, ENABLE);
DAC_DMACmd(DAC_Channel_1, ENABLE);
TIM_Cmd(TIM6, ENABLE);
while(1)
{
}
} |