Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stm32f10x.h"
- #include "evbLib.h"
- #include <stdio.h>
- int x=0,y=0;
- void czysc() {
- lcdGoTo(0,0); lcdWrite(" "); //16
- lcdGoTo(1,0); lcdWrite(" "); //16
- lcdGoTo(x,y);
- }
- int main(void) {
- int ADC_value;
- float napiece_ADC;
- char odczyt[5];
- int i;
- ADC_InitTypeDef ADC_InitStruct;
- // wlaczenie taktowania zegara dla przetwornika ADC1
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);
- //konfigurowanie przetwornika ADC
- ADC_InitStruct.ADC_Mode=ADC_Mode_Independent;
- ADC_InitStruct.ADC_ScanConvMode=DISABLE;
- ADC_InitStruct.ADC_ContinuousConvMode=ENABLE;
- ADC_InitStruct.ADC_ExternalTrigConv=ADC_ExternalTrigConv_None;
- ADC_InitStruct.ADC_DataAlign=ADC_DataAlign_Right;
- ADC_InitStruct.ADC_NbrOfChannel=1;
- ADC_Init(ADC1, &ADC_InitStruct);
- ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1, ADC_SampleTime_71Cycles5);
- //wlaczenie ADC
- ADC_Cmd(ADC1, ENABLE);
- ADC_SoftwareStartConvCmd(ADC1, ENABLE);
- while(1) {
- ADC_value= ADC_GetConversionValue(ADC1);
- napiece_ADC=ADC_value*0.0008056640625; // bitowa rozdzielczosc przetwarzania 3,3V/4096 = 0.0008056640625
- sprintf(odczyt,"%.2f V", napiece_ADC); // .2 okresla 2 miejsca po przecinku
- lcdWrite(odczyt);
- lcdGoTo(1,0);
- for(i=0;i<16;i++) {
- if(napiece_ADC>3.3*i/16) { lcdWrite("-"); }
- }
- delayMs(2000);
- czysc();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement