2014-09-01 02:00 PM
#include ''stm32f4xx_gpio.h''
GPIO_InitTypeDef GPIO_InitStructure;
// in main():
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
That last line that enables the peripheral clock is causing the following errors:
error: use of undeclared identifier 'RCC_AHB1Periph_GPIOD'
warning: implicit declaration of function 'RCC_AHB1PeriphClockCmd' is invalid in C99
I've tried searching, but I haven't found an explanation and solution to this. What am I doing wrong?
----
As a second question, when I'm setting the project runtime environment, I see two different options for GPIO:
1. Device\GPIO
2. Device\StdPeriph Drivers\GPIO
What's the difference between the two and which one do I want?
#gpio #know-your-tools
2014-09-01 02:16 PM
''I have an STM32F4 Discovery board, which I am relatively new to''
Sounds like you must also be quite new to 'C' programming in general - yes?error: use of undeclared identifier 'RCC_AHB1Periph_GPIOD'warning: implicit declaration of function 'RCC_AHB1PeriphClockCmd' is invalid in C99
The
#include ''stm32f4xx_gpio.h''
just gives you the GPIO_... stuff - you also need the header for the RCC_... stuff.
Take a look at ST's examples...2014-09-01 02:41 PM
>
> From: neil.andrew > > Sounds like you must also be quite new to 'C' programming in general - yes? > I'm on the beginning side of intermediate, however it's been a while since I've had to code in C, so I'm definitely rusty. > The #include ''stm32f4xx_gpio.h'' just gives you the GPIO_... stuff - you > also need the header for the RCC_... stuff. > Ah, that would definitely do it. I added the relevant Include directive and the error went away. Thank you! Can you shed any light on the second question regarding which GPIO driver to use?2014-09-01 05:52 PM
Ok, you need to create a project that points to the appropriate library files and include directories. You also want to pay attention to the defines the library passes via the compilers command line.
Nominally you'd pull in stm32f4xx.h, OR stm32f4_discovery.h, and it in turn would pull in other include files you need via a project specific stm32f4xx_conf.h You really need to get your own copy of the library, and not Keil's, and then familiarize yourself with the project templates and their structure/form. STM32F4-Discovery_FW_V1.1.0\Project\Peripheral_Examples\IO_Toggle STM32F4-Discovery_FW_V1.1.0\Project\Peripheral_Examples\IO_Toggle\MDK-ARM\IO_Toggle.uvproj STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Templates\MDK-ARM\Project.uvproj2014-09-01 05:55 PM
/* GPIOD Periph clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
/* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
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(GPIOD, &GPIO_InitStructure);
/* PD12 to be toggled */
GPIO_SetBits(GPIOD, GPIO_Pin_12);
/* PD13 to be toggled */
GPIO_SetBits(GPIOD, GPIO_Pin_13);
/* PD14 to be toggled */
GPIO_SetBits(GPIOD, GPIO_Pin_14);
/* PD15 to be toggled */
GPIO_SetBits(GPIOD, GPIO_Pin_15);
GPIO_ResetBits(GPIOD, GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);
2014-09-01 11:48 PM
''You really need to get your own copy of the library, and not Keil's''
Absolutely!Keil's copies of the library are notoriously out-of-date.''then familiarize yourself with the project templates and their structure/form''And look at the provided examples.2014-09-21 03:14 PM
> From: neil.andrew
> Posted: Tuesday, September 02, 2014 8:48 AM > Subject: Newbie looking for help with GPIO > > ''You really need to get your own copy of the library, and not Keil's'' > > Absolutely! > > Keil's copies of the library are notoriously out-of-date. > > ''then familiarize yourself with the project templates and their > structure/form'' > > And look at the provided examples. This is definitely news to me. Especially since Keil's Pack Installer lists different versions and periodically comes out with updates, this is absolutely the first I'm hearing about this. Alright then, I'm grabbing STM32CubeF4 1.3.0 right now. Here's the thing - all the tutorials I've been using are Keil specific (which is reasonable, since that's the IDE I'm working with). Are there any write-ups or tutorials which show how to use Keil, specifically, with the seperately downloaded CubeF4 drivers and files?