AnsweredAssumed Answered

STM32F407 and STM32F4xx DSP and Standard Peripherals Library

Question asked by felix.reto on Aug 25, 2013
Latest reply on Aug 25, 2013 by felix.reto

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

Outcomes