2017-07-09 11:32 AM
Hello,
Was doing some tests with the ODR register for GPIO and noticed that when I load it with 0xFFFF some pins (13-15 for GPIOA &GPIOC) were still off. I have them initialized so I am unsure why they won't come on. Wondering why this happens and how to overcome this. Also might there be an easier/faster/less trivial way to initialize all pins to the same for GPIOA/B/C?
Source Code:
&sharpinclude 'stm32f10x_gpio.h'
&sharpinclude 'stm32f10x_rcc.h'GPIO_InitTypeDef GPIO_InitStructure;
int main(void){ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15; GPIO_Init(GPIOA,&GPIO_InitStructure); while(1) { GPIOA->ODR = 0xFFFF; }}#odr #gpio2017-07-09 02:25 PM
What do they connect to externally? PA13 and PA14 would nominally be used by the debug interface.
PC13,14 and 15 are typically in the low power domain, so don't have high current drive capabilities.
2017-07-09 06:07 PM
Just an LED which i was using to probe all outputs, I may have misunderstood this register, i thought it loaded all 16 bits to output of respective port.
2017-07-09 06:08 PM
By that i meant I am under the impression that:
GPIOA->ODR = 0xFFFF;
should make every port (0-15) in GPIOA high
2017-07-09 07:31 PM
It should, you'd want to read back the mode settings.
IDR should always reflect the pin state, ODR will drive those pin set as outputs. Potential for pins to clash with external circuitry, driving an alternate state, or pins shorted on the board.