2013-09-02 04:14 AM
Posted on September 02, 2013 at 13:14
Hi Folks
I'm working with the 32F4 discovery board and I've been looking for some examples of mixed Input and output pins on the same port, however they seem a like hard to find!! I checked the Ref Manual and does seem possible to put input and output on the same port. I'm using the following setup code - is this the right way to go about it?? (the strut was declared earlier) - The outputs (3,4) seem to work fine, but I get no pull ups on the inputs....
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4;
GPIO_Init(GPIOE, &GPIO_InitStruct);
GPIO_SetBits(GPIOE, GPIO_Pin_4 );
GPIO_SetBits(GPIOE, GPIO_Pin_3 );
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN; // so change the strut to from Alt funct to GPIO (in)
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
GPIO_Init(GPIOE, &GPIO_InitStruct);
GPIO_SetBits(GPIOE, GPIO_Pin_0 );
GPIO_SetBits(GPIOE, GPIO_Pin_1 );
Thanks for the time folks
CS
2014-04-20 05:55 PM
:o now I have the same problem u.u.. I'm using a lot of pins and I need a port with mixed inputs and outputs... but I don't find the solution u.u
is it possible make it? maybe programming the register directly :Dthis is my code.GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;GPIO_Init(GPIOC, &GPIO_InitStructure);/* Configure in output pushpull mode */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;GPIO_Init(GPIOC, &GPIO_InitStructure);2014-04-20 06:15 PM
Yeah, I fail to understand the question/problem here, you can pick and choose how you configure any/all the 16 pins in a GPIO bank. A couple of GPIO C pins have specific characteristics because they are in the low power domain, and have limited current sink/source as a result.
If you run out of pins you pick a part that has more pins, or learn to multiplex the usage of the ones you have.2014-04-20 06:26 PM
well, mm.. my problem is... I need to use the GPIOC and 10 pins input and 6 in output. thats it.
is it possible?what is the way for that? only in the configuration.I have thought program directly the registers.thanks.2014-04-20 08:30 PM
well, mm.. my problem is... I need to use the GPIOC and 10 pins input and 6 in output. thats it.
is it possible?
what is the way for that? only in the configuration.
I have thought program directly the registers.Yes, use GPIO_Init().I'd probably use PC13,14,15 as inputs.You could use registers if you wish, I'd recommend reviewing the manuals, and data sheets.You don't need to have all the pins in the same bank. Outputting a data bus via a single bank does make sense.
2014-04-20 09:35 PM
Hello, well I need to be more specific...
I need the UART, PWM and GPIO in the code I configurate all in the same section or in diferent section depends or the module.. I have agreed my code in this message. the UART don't send any data any HELLO! :p and the inputs don't work as inputs u.u but all outputs work very well. Why is it? :S is necesary this configuration of the pins.. but if it is imossible.. well, I'll have to change my hardware and software u.u ________________ Attachments : code.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzyH&d=%2Fa%2F0X0000000bRb%2FpumnO2H_dWjBp8JV4pRIQeBAnCo43ddCGUFaE7iDHVA&asPdf=false2014-04-21 08:05 AM
You seem to be using PC0 for TWO purposes
To test the USART send a stream of 'U' characters, observe them on a scope and confirm the bit timings. Also observe the STM32 uses CMOS signalling, and is not directly compatible with RS232 signalling levels. Incorrect timing can occur if the PLL settings or HSE_VALUE don't match the hardware configuration.ST has it's Micro Xplorer app to help do pin allocation, their new CubeMX tools should extend this and generate code.I would generally favour enabling the clocks, and then configuring all the pins. You have flexibility in how you do this, I tend to do it a bank at a time, will a listed of enumerated pin functions, and then the code to set them up.What does ''u.u'' mean?2014-04-22 09:57 PM
sorry, PC0 don't still use that. but is a different channel for PWM. I tried to send 'U' and I don't have any response from stm32. I have an CP2102 RS232-USB conversor and I probed another programm with USART with 115200 in bauds with the configuration PLL and HSE 168MHz, I have using the programm but the code is very similar to mine.
do you favour first the clocks, How is it? for example clock GPIOA after the configuration GPIOA , clock GPIOB after the configuration GPIOB.I changed USART2 by USART1... nothing...sorry.... u.u = :( is a sad face, the habit of writing it.