#include "stm32f4xx.h" #include "LCD2x16.c" int main () { unsigned int j; /* ADCx->SR = ; // Status Register ADCx->CR1 = ; // Control Register 1 ADCx->CR2 = ; // Control Register 2 ADCx->SMPR1 = ; // SaMPle time Register 1 ADCx->SMPR2 = ; // SaMPle time Register 2 ADCx->JOFR1 = ; // inJecter channel data OFset Register 1 ADCx->JOFR2 = ; // inJecter channel data OFset Register 2 ADCx->JOFR3 = ; // inJecter channel data OFset Register 3 ADCx->JOFR4 = ; // inJecter channel data OFset Register 4 ADCx->HTR = ; // watchdog Higher Threshold Register ADCx->LTR = ; // watchdog Lower Threshold Register ADCx->SQR1 = ; // regular SeQuence Register 1 ADCx->SQR2 = ; // regular SeQuence Register 2 ADCx->SQR3 = ; // regular SeQuence Register 3 ADCx->JSQR = ; // inJected SeQuence Register ADCx->JDR1 = ; // inJected Data Register 1 ADCx->JDR2 = ; // inJected Data Register 2 ADCx->JDR3 = ; // inJected Data Register 3 ADCx->JDR4 = ; // inJected Data Register 4 ADCx->DR = ; // Data Register ADC->CSR = ; // Common Status Register ADC->CCR = ; // Common Control Register ADC->CDR = ; // Common regular Data Register for dual and triple mode inputs are PA2 & PA3 -> these pins must be enabled for analog, PA must have clock! */ /*----------------------------------------------------------------------------------------*/ /* Software triggered, dual, simultaneous sampling */ /*----------------------------------------------------------------------------------------*/ RCC->APB2ENR |= 0x00000100 + 0x00000200; // Enable clock for ADC1 & ADC2 RCC->AHB1ENR |= 0x00000001 + 0x00000002; // Enable clock for GPIOA & GPIOB ADC->CCR = 0x00000006; // No DMA, Regular simultaneous mode only ADC1->CR2 = 0x00000001; // Control Register 2: ADC1 ON ADC1->SQR3 = 0x00000002; // regular SeQuence Register 3 ADC2->CR2 = 0x00000001; // Control Register 2: ADC2 ON ADC2->SQR3 = 0x00000003; // regular SeQuence Register 3 GPIOA->MODER |= 0x000000f0; // MODE Register -> PA2, PA3 are analog inputs LCD_init(); LCD_string("ADC1=", 0); LCD_string("ADC2=", 0x40); while (1) { ADC1->CR2 |= 0x40000000; // simultaneous Start Conversion for (j = 0; j<100; j++){}; // wait for conversion to complete LCD_Int16((int)ADC1->DR, 0x06, 1); // write result on LCD, 1st line LCD_Int16((int)ADC2->DR, 0x46, 1); // write result on LCD, 2nd line }; }