HI there,
For one project i am using following pins.
#define RW_Pin GPIO_PIN_15
#define RW_GPIO_Port GPIOA
#define RS_Pin GPIO_PIN_12
#define RS_GPIO_Port GPIOA
#define EN_Pin GPIO_PIN_3
#define EN_GPIO_Port GPIOB
#define D7_Pin GPIO_PIN_7
#define D7_GPIO_Port GPIOB
#define D6_Pin GPIO_PIN_6
#define D6_GPIO_Port GPIOB
#define D5_Pin GPIO_PIN_5
#define D5_GPIO_Port GPIOB
#define D4_Pin GPIO_PIN_4
#define D4_GPIO_Port GPIOB
#define RELAY_1 GPIO_PIN_0
#define RELAY_2 GPIO_PIN_1
#define RELAY_PORT GPIOB
#define SW1 GPIO_PIN_8
#define SW2 GPIO_PIN_9
#define SW3 GPIO_PIN_10
#define SW4 GPIO_PIN_11
#define SW_PORT GPIOA
Sw’ are input GPIOs and above all others are Output for 4 bit lcd interface. also PA0(ADC0), PA1(Adc1) and PA2(ADC2) i am using to read analog inputs. the work is simple. i am reading analog inputs and showing on lcd and by using SW’s i am setting setpoints. all sw’s are pullups. I am using Keil mdk5 version. at first cpu worked fine . but after sometimes. Sw1 is getting drop in voltage causing to go in another function. also mcu was heating.
below is my init code. i checked same mcu stm32f030k6t6 found PA8 is conflicting with RCC and ADC0 is conflicting with SYS. please help.
GPIO_Config_T gpioConfig;
ADC_Config_T adcConfig;
/* Enable GPIOA clock */
RCM_EnableAHBPeriphClock(RCM_AHB_PERIPH_GPIOA | RCM_AHB_PERIPH_GPIOB );
gpioConfig.mode = GPIO_MODE_IN;
gpioConfig.pupd = GPIO_PUPD_PU;
gpioConfig.speed = GPIO_SPEED_2MHz;
gpioConfig.pin = SW1 | SW2 | SW3 | SW4;
GPIO_Config(GPIOA, &gpioConfig);
//D7
gpioConfig.pin = D7_Pin | EN_Pin | D6_Pin | D5_Pin | D4_Pin | RELAY_1 | RELAY_2;
gpioConfig.mode = GPIO_MODE_OUT;
gpioConfig.outtype = GPIO_OUT_TYPE_PP;
gpioConfig.speed = GPIO_SPEED_2MHz;
gpioConfig.pupd = GPIO_PUPD_NO;
GPIO_Config(GPIOB, &gpioConfig);
//D6\\\\\\\\\\\\\\\\\\
gpioConfig.pin = RW_Pin | RS_Pin ;
gpioConfig.mode = GPIO_MODE_OUT;
gpioConfig.outtype = GPIO_OUT_TYPE_PP;
gpioConfig.speed = GPIO_SPEED_2MHz;
gpioConfig.pupd = GPIO_PUPD_NO;
GPIO_Config(GPIOA, &gpioConfig);
/* ADC channel 0 configuration */
gpioConfig.mode = GPIO_MODE_AN;
gpioConfig.pupd = GPIO_PUPD_NO;
gpioConfig.pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 ;
GPIO_Config(GPIOA, &gpioConfig);
/* Enable ADC clock */
RCM_EnableAPB2PeriphClock(RCM_APB2_PERIPH_ADC1);
/* ADC configuration */
ADC_Reset();
ADC_ConfigStructInit(&adcConfig);
/* Set resolution*/
adcConfig.resolution = ADC_RESOLUTION_12B;
/* Set scanDir*/
adcConfig.scanDir = ADC_SCAN_DIR_UPWARD;
/* Set convMode continous*/
adcConfig.convMode = ADC_CONVERSION_CONTINUOUS;
/* Set dataAlign*/
adcConfig.dataAlign = ADC_DATA_ALIGN_RIGHT;
/* Set extTrigEdge*/
adcConfig.extTrigEdge = ADC_EXT_TRIG_EDGE_NONE;
/* Set extTrigConv*/
adcConfig.extTrigConv = ADC_EXT_TRIG_CONV_TRG0;
ADC_Config(&adcConfig);
/* ADC channel Convert configuration */
ADC_ConfigChannel(ADC_CHANNEL_0, ADC_SAMPLE_TIME_239_5);
ADC_ConfigChannel(ADC_CHANNEL_1, ADC_SAMPLE_TIME_239_5);
ADC_ConfigChannel(ADC_CHANNEL_2, ADC_SAMPLE_TIME_239_5);
// ADC_ConfigChannel(ADC_CHANNEL_3, ADC_SAMPLE_TIME_239_5);
/* Config DMA*/
DMA_Init();
/* Calibration */
ADC_ReadCalibrationFactor();
/* Enable ADC DMA*/
ADC_EnableDMA();
ADC_DMARequestMode(ADC_DMA_MODE_CIRCULAR);
/* Enable ADC */
ADC_Enable();