Hello Folks,
I tear my hair out over this. I have a STM32F0 Discovery board here and
i would like to get all 16 bits of PORTC high. Most of the pins do what
i expect them to do, but PC1 and PC2 dont. They stay low out of what
ever reason. I am a bloody newbie in this , so please dear gurus, give
me some code that will get pin1 and pin 2 in the high state. I am not
sure what is wrong here.
In some data sheet of the board is found that these 2 pins are also used
for external interrupts but i am not sure if that is the reason and how
to disable that alternative function to get these 2 pins into a usable
state.
Any help would be deeply appreciated, I am chewing on this problem
already since a week and ready to give up on it.
1 | #include "stm32f0xx.h"
|
2 | #include "stm32f0xx_rcc.h"
|
3 | #include <stm32f0xx_conf.h>
|
4 | #include "stm32f0xx_gpio.h"
|
5 | #include "diag/Trace.h"
|
6 | //#include <stdio.h>
|
7 |
|
8 |
|
9 |
|
10 | int main()
|
11 | {
|
12 |
|
13 | GPIO_InitTypeDef GPIO_InitDef;
|
14 | RCC->AHBENR |= RCC_AHBENR_GPIOCEN;
|
15 | GPIO_InitDef.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5\
|
16 | | GPIO_Pin_6 | GPIO_Pin_7| GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 \
|
17 | | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15 ;
|
18 | GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT;
|
19 | GPIO_InitDef.GPIO_OType = GPIO_OType_PP;
|
20 | GPIO_InitDef.GPIO_PuPd = 0x01;
|
21 | GPIO_InitDef.GPIO_Speed = GPIO_Speed_2MHz;
|
22 | //Initialize pins
|
23 | GPIO_Init(GPIOC, &GPIO_InitDef);
|
24 |
|
25 |
|
26 | GPIOC->ODR =0xFFFF;
|