文件名称:STM32 adc 例程
文件大小:466KB
文件格式:RAR
更新时间:2015-08-22 04:51:40
STM32
STM32 adc 例程 void adc_Init (void) { RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; //使能GPIO时钟 GPIOA->CRL &= ~0x00000000; //GPIO设置为模拟输入 GPIOA->CRH &= ~0x00000000; RCC->AHBENR |= (1<<0); // enable periperal clock for DMA//使能DMA时钟 DMA1_Channel1->CMAR = (u32)&ADC;_ConvertedValue;// set channel1 memory address //设置DMA地址,ADC转换结果直接放入该地址 DMA1_Channel1->CPAR = (u32)&(ADC1->DR); // set channel1 peripheral address DMA1_Channel1->CNDTR = 1; // transmit 1 word DMA1_Channel1->CCR = 0x00002520; // configure DMA channel DMA1_Channel1->CCR |= (1 << 0); // DMA Channel 1 enable //使能DMA通道 RCC->APB2ENR |= (1<<9); // enable periperal clock for ADC1 //使能ADC时钟 ADC1->SQR1 = 0x00000000; // only one conversion // 只有1个转换通道 ADC1->SMPR2 = 0x00000028; // set sample time channel1 (55,5 cycles)// (3bit)通道0采样周期55.5个时钟周期 ADC1->SQR3 = 0x00000000; // set channel1 as 1st conversion // (5bit)第1个转换通道是0通道 ADC1->CR1 = 0x00000100; // use independant mode, SCAN mode ADC1->CR2 = 0x000E0103; // use data align right,continuous conversion // EXTSEL = SWSTART // enable ADC, DMA mode, no external Trigger ADC1->CR2 |= 0x00500000; // start SW conversion }
【文件预览】:
实验13-ADC模数转换
----out()
--------ObjRAM()
--------LstFlash()
--------ObjFlash()
--------LstRAM()
----main()
--------STM32_Init.c(302KB)
--------Usart_RAM.dep(6KB)
--------Usart.Opt.bak(3KB)
--------Usart_Simulator.dep(6KB)
--------Usart.Uv2.bak(5KB)
--------Usart_Opt.Bak(3KB)
--------STM32_Init.c.bak(302KB)
--------JLinkLog.txt(180KB)
--------STM32_Init.h(1KB)
--------Retarget.c(2KB)
--------Usart.Uv2(5KB)
--------STM32_Reg.h(8KB)
--------STM32F10x.s(11KB)
--------Usart.c(4KB)
--------说明.txt(156B)
--------Usart_FLASH.dep(6KB)
--------RAM.ini(1KB)
--------Usart_Uv2.Bak(5KB)
--------Abstract.txt(872B)
--------Usart.Opt(3KB)