cancel
Showing results for 
Search instead for 
Did you mean: 

Pin PA8 configured as OUTPUT

guigui
Associate II
Posted on January 29, 2016 at 16:30

Hello,

I'm trying

for several

days

to set up the

pin

PA8

(

STM32F4

) as

output

but

I do not see

anything with

an oscilloscope.

Here is the

code I use

to configure the

pin

:


#define PORT_IO_A_8 ((Uint32)0)


GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;


Uint32 port_a_mask =

(PORT_IO_A_0 << 0 ) |

(PORT_IO_A_1 << 1 ) |

(PORT_IO_A_2 << 2 ) |

(PORT_IO_A_3 << 3 ) |

(PORT_IO_A_4 << 4 ) |

(PORT_IO_A_5 << 5 ) |

(PORT_IO_A_6 << 6 ) |

(PORT_IO_A_7 << 7 ) |

(PORT_IO_A_8 << 8 ) |

(PORT_IO_A_9 << 9 ) |

(PORT_IO_A_10 << 10) |

(PORT_IO_A_11 << 11) |

(PORT_IO_A_12 << 12) |

(PORT_IO_A_13 << 13) |

(PORT_IO_A_14 << 14) |

(PORT_IO_A_15 << 15);

GPIO_InitStructure.GPIO_Pin = ((uint32_t)port_a_mask) & 0xFFFF9FFF; 
//JTMS-SWDIO, JTCK-SWCLK

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = (~((uint32_t)port_a_mask)) & 0xFFFF9FFF; 
//JTMS-SWDIO, JTCK-SWCLK

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

GPIO_Init(GPIOA, &GPIO_InitStructure);

I use

the following function

to switch between

high or low level

.

1.
GPIO_WriteBit(GPIOA,GPIO_Pin_8, Bit_RESET);
2.
//GPIO_WriteBit(GPIOA,GPIO_Pin_8, Bit_SET);

The pin is

always

at the low level

.

I tested

with

another pin

as

PA0

or

PA1

and

it works

well

.

I hope you can help me.

Cordially

Guillaume #gpio #!stm32f4discovery-!fsmc
5 REPLIES 5
Posted on January 29, 2016 at 16:52

> 
#define PORT_IO_A_8 ((Uint32)0)

Eh? ---- Do you have a debugger? Connect to the mcu, stop it, reset, go to the peripheral registers window, now - in RCC->AHB1ENR set GPIOAEN to 1 - in GPIOA->MODER, set MODER8 to 01 (i.e. whole MODER will become 0xA8010000) - in GPIOA->ODR, write to ODR8 1 then 0 repeatedly - and watch the output toggling JW
guigui
Associate II
Posted on January 29, 2016 at 17:26

Thank you for your response.

I use system workbench for stm32.

Your

procedure

works well.

But I do

not see why

my code

does not work on

the

PA8

pin

while it

works on

other pins

.

Posted on January 29, 2016 at 17:53

Your code is so muddled, and unnecessary convoluted. I'd ask for complete code, but I'm afraid to wade deeper.

Just enable the pin and set it

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_WriteBit(GPIOA,GPIO_Pin_8, Bit_RESET);
//GPIO_WriteBit(GPIOA,GPIO_Pin_8, Bit_SET);

Quit with the masking stuff, you are passing a pin vector of the ONES you want to configure, it is not going to change your other pins, and you can call the GPIO_Init() function separately for each group of pin(s) you want to use. Now if this doesn't work perhaps you can provide some more details about your specific board, or you can refer to the schematic, and check for other connectivity or solder bridges being used on PA8.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
guigui
Associate II
Posted on January 29, 2016 at 18:21

I just

identify the problem.

I use the

USB

host

library

.

In

this library

the mode of

PA8

pin is

changed. (usb_bsp.c)

/* Configure SOF VBUS ID DM DP Pins */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 |
GPIO_Pin_9 |
GPIO_Pin_11 |
GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_OTG1_FS) ;

Can I

still use

the

PA8

pin

?

Posted on January 29, 2016 at 19:53

Can I

still use

the

PA8

pin

?

What is it being used for in this code, and what is it being used for in your board design?

The ''board support'' needs to match the board it's being applied too. If PA8 isn't being used for USB (SOF), then you need to strip that stuff out, right?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..