cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 and STM32F4xx DSP and Standard Peripherals Library

reto
Associate
Posted on August 25, 2013 at 14:46

I'm new on STM32F407 and STM32F4xx DSP and Standard Peripherals Library.

And now I've got some question.

1) GPIO timing

When I code

            GPIOF->BSRRH = 0x0100U;

            GPIOF->BSRRL = 0x0100U;

            GPIOF->BSRRH = 0x0100U;

            GPIOF->BSRRL = 0x0100U;

            GPIOF->BSRRH = 0x0100U;

            GPIOF->BSRRL = 0x0100U;

I didn't see the desired signal on pin PF8.

When I place some delay between every line it works.

What is the minimum required delay?

Is there another way to force the Output?

2) IS_GPIO_PIN() in stm32f4xx_gpio.h

In stm32f4xx_gpio.h is the macro IS_GPIO_PIN() defined.

#define IS_GPIO_PIN(PIN) ((((PIN) & (uint16_t)0x00) == 0x00) && ((PIN) != (uint16_t)0x00))

But I didn't understand (((PIN) & (uint16_t)0x00) == 0x00).

This is always evaluated to true.

Can somebody explain this condition?

3) assert in GPIO_SetBits(),GPIO_ResetBits()

I use PB0-7 as data bus to an old LCD module.

So I've got the following code

void LcdData(const unsigned char uiData)

{

            GPIO_ResetBits(GPIOF, 0x00FFU);          //Reset data bus

            GPIO_SetBits(GPIOF, uiData);                   //Set data bus

            GPIO_SetBits(  GPIOF, 0x0100U);             //Set chip select

            GPIO_ResetBits(GPIOF, 0x0100U);                       //Reset chip select

}

When I call LcdData(0x00U) I get an assert().

When I remove this assert it works fine.

Is there a reason that GPIO_SetBits() does not allowed 0x0000U as argument?

4) Not const prove function in Standard Peripherals Library

I try to initialize a port with the following code:

void init(void)

{

            static const GPIO_InitTypeDef        sInit =

            {

                        GPIO_Pin_0,             //            uint32_t GPIO_Pin;          

                        GPIO_Mode_OUT,   //            GPIOMode_TypeDef GPIO_Mode; 

                        GPIO_Speed_2MHz,//            GPIOSpeed_TypeDef GPIO_Speed;

                        GPIO_OType_PP,     //            GPIOOType_TypeDef GPIO_OType;

                        GPIO_PuPd_NOPULL//        GPIOPuPd_TypeDef GPIO_PuPd; 

            };

           

            GPIO_Init(GPIOF, &sInit);

}

But the compiler reports an incompatible with parameter

Is there a reason why GPIO_Init() is not declared with const?

void GPIO_Init(GPIO_TypeDef* const GPIOx, GPIO_InitTypeDef* const GPIO_InitStruct);

Many thanks for your answers

Reto Felix

2 REPLIES 2
Posted on August 25, 2013 at 18:40

1) That's odd, because such code should be able to generate high rate toggling. What compiler are you using, and what code is it generating for this? What bandwidth scope/probes are you using? What speed are the IO ports set too? 100 MHz?

4) Probably because the data structure is frequently not used in the const form, and instead manipulated and changed as part of typical initialization routines.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
reto
Associate
Posted on August 25, 2013 at 19:36