在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            10路AD驅(qū)動程序

            作者: 時間:2016-11-26 來源:網(wǎng)絡(luò) 收藏
            //Author:"淚與汗的纏綿"

            //Data:2011-11月

            本文引用地址:http://www.biyoush.com/article/201611/321621.htm

            //功能:10路AD驅(qū)動程序,TFT函數(shù)的配置


            #include "stm32f10x_lib.h"
            #include"stdio.h"
            #include "main.h"
            u8 Rx_Buffer[128*2];
            vu32 FLASH_ID = 0;
            #defineM25P64_FLASH_ID0x202017
            //u16 colors[]={
            //0xf800,0x07e0,0x001f,0xffe0,0x0000,0x07ff,0xf81f,0xffff ,0x7bef
            //};
            RCC_Init();
            ADC_configuration();
            DMA_Configuration();
            LCD_Display_Color(0xffe0);
            LCD_SetBackColor(0xffe0);
            LCD_SetTextColor(0x07e0);
            while (1)
            {
            for(cnt=0;cnt<10;cnt++)
            {
            AD_value=ADC_ConvertedValue[cnt];//返回最近一次 ADCx 規(guī)則組的轉(zhuǎn)換結(jié)果
            AD_value=AD_value/4095.0*3.3;
            readAD[cnt]=AD_value*1000.0;
            Display_variate(cnt*15,80,cnt);
            }
            for(cnt=0;cnt<10;cnt++)
            Display_variate(cnt*15,2,readAD[cnt]);
            }
            }
            void RCC_Init(void)
            {
            RCC_DeInit();


            RCC_HSEConfig(RCC_HSE_ON);


            HSEStartUpStatus = RCC_WaitForHSEStartUp();

            if(HSEStartUpStatus==SUCCESS)
            {

            FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);


            FLASH_SetLatency(FLASH_Latency_2);


            RCC_HCLKConfig(RCC_SYSCLK_Div1);


            RCC_PCLK2Config(RCC_HCLK_Div1);
            RCC_ADCCLKConfig(RCC_PCLK2_Div4);


            RCC_PCLK1Config(RCC_HCLK_Div2);


            RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);


            RCC_PLLCmd(ENABLE);


            while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
            {
            }

            RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

            while(RCC_GetSYSCLKSource() != 0x08)
            {
            }
            }

            RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_AFIO, ENABLE);
            RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
            RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
            STM3210B_LCD_Init();
            SPI_FLASH_Init();
            }
            void Delay(u32 t)// Delay Time about 1 ms;
            {
            u16 i;
            do
            {
            for(i=0; i<5000; i++);
            }
            while(t--);
            }
            voidADC_configuration()
            {
            ADC_InitTypeDefADC_InitStructure;
            ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
            ADC_InitStructure.ADC_ScanConvMode = ENABLE;
            ADC_InitStructure.ADC_ContinuousConvMode=ENABLE;
            ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
            ADC_InitStructure.ADC_NbrOfChannel=10;// 規(guī)定了順序進行規(guī)則轉(zhuǎn)換的 ADC 通道的數(shù)目。這個數(shù)目的取值范圍是 1 到16。
            ADC_Init(ADC1, &ADC_InitStructure);
            ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1, ADC_SampleTime_55Cycles5);
            ADC_RegularChannelConfig(ADC1, ADC_Channel_0,2, ADC_SampleTime_55Cycles5);
            ADC_RegularChannelConfig(ADC1, ADC_Channel_1,3, ADC_SampleTime_55Cycles5);
            ADC_RegularChannelConfig(ADC1, ADC_Channel_2,4, ADC_SampleTime_55Cycles5);
            ADC_RegularChannelConfig(ADC1, ADC_Channel_3,5, ADC_SampleTime_55Cycles5);
            ADC_RegularChannelConfig(ADC1, ADC_Channel_4,6, ADC_SampleTime_55Cycles5);
            ADC_RegularChannelConfig(ADC1, ADC_Channel_5,7, ADC_SampleTime_55Cycles5);
            ADC_RegularChannelConfig(ADC1, ADC_Channel_6,8, ADC_SampleTime_55Cycles5);
            ADC_RegularChannelConfig(ADC1, ADC_Channel_7,9, ADC_SampleTime_55Cycles5);
            ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 10, ADC_SampleTime_55Cycles5);

            ADC_Cmd(ADC1, ENABLE);
            ADC_ResetCalibration(ADC1);
            while(ADC_GetResetCalibrationStatus(ADC1));//等待ADC的校準寄存器被設(shè)置完畢
            ADC_StartCalibration(ADC1);
            while(ADC_GetCalibrationStatus(ADC1));
            ADC_SoftwareStartConvCmd(ADC1, ENABLE);
            ADC_DMACmd(ADC1, ENABLE);
            }
            void DMA_Configuration(void)
            {
            DMA_DeInit(DMA1_Channel1);
            DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)ADC1_DR_Address;//定義DMA外設(shè)基地址
            DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_ConvertedValue;// 定義DMA內(nèi)存基地址
            DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;//外設(shè)作為數(shù)據(jù)傳輸?shù)膩碓矗ㄍ庠O(shè)傳到內(nèi)存) DMA_DIR_PeripheralDST——內(nèi)存?zhèn)鞯酵庠O(shè)
            DMA_InitStructure.DMA_BufferSize =10;//連續(xù)轉(zhuǎn)化10個AD通道值
            DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //外設(shè)寄存器地址不變
            DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;//內(nèi)存寄存器地址遞增
            DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; //外設(shè)數(shù)據(jù)寬度32bit
            DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;//內(nèi)存數(shù)據(jù)寬度32bit
            DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;//DMA模式是循環(huán)
            DMA_InitStructure.DMA_Priority = DMA_Priority_High;//DMA優(yōu)先級
            DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;//DMA沒有設(shè)置內(nèi)存到內(nèi)存?zhèn)鬏?br />DMA_Init(DMA1_Channel1, &DMA_InitStructure);
            DMA_Cmd(DMA1_Channel1, ENABLE);
            }



            評論


            技術(shù)專區(qū)

            關(guān)閉