7 years, 3 months ago.

STM32F767 (and simmilar) raw GPIO use

Hi

For a project I'm doing I need to get the full speed of the GPIO and I need to write the entire word to the gpio port. DigitalWrite and such functions are too slow for what I need, but they do work. I am looking for a way to write the content of the port by accessing the port registers directly. I have the Nucleo144 board, and a good portion of the PORTD is exposed to the existing pin headers, so I'm trying to access that one. I found plenty of examples and docs regarding this topic, but none of them compile in the mbed online editor.

This tutorial looks like it could work, but some of the registers are not recognizable, even if I change the header file. http://hertaville.com/stm32f0-gpio-tutorial-part-1.html

Which one doesn't work? It seems pretty standard C++ register notation, and they should be recognized by the compiler as that header file is included.

posted by Erik - 03 Jan 2017

Only the GPIOD->ODR and GPIOD->BSRR are recognized, while all the other configuration registers give me a syntax error. By themselves they don't seem to work, seems I need to setup clock sources to get it working, but those registers are not recognized. What library do I have to include for the 767 to have it working properly? Are the register names different from what that example shows? Where can I find a documentation/manual(except datasheet) about such things for the STM32F767?

posted by D Labinac 03 Jan 2017

They need to be clocked yes, some are by default, others are not. Besides manually setting registers to clock it, you can also make a single DigitalOut on port D, then Port D will be enabled. When you set your requirements for Port D you simply overwrite the settings done by that DigitalOut, but it will still be enabled.

However I have used direct register access all the time, not on an F7 yet, but also on F4s for example, and that works fine. On the STM site you can find the reference manual, that includes all registers and what they do.

But can you show a simple single line program which gives you the syntax error?

posted by Erik - 05 Jan 2017

1 Answer

7 years, 3 months ago.

From the source attached, seems no reason that compiler could only recognize part of the definition unless the below did not included; Since mentioned "syntax error" but not "segment error" means it is not register address issue.

Could you please provide more information about your code and error log?

typedef struct 396 { ... }GPIO_TypeDef;

line 708

  1. define GPIOA_BASE (AHB2PERIPH_BASE + 0x00000000)
  2. define GPIOB_BASE (AHB2PERIPH_BASE + 0x00000400)
  3. define GPIOC_BASE (AHB2PERIPH_BASE + 0x00000800)
  4. define GPIOD_BASE (AHB2PERIPH_BASE + 0x00000C00)
  5. define GPIOF_BASE (AHB2PERIPH_BASE + 0x00001400)

line 762

  1. define GPIOA ((GPIO_TypeDef *) GPIOA_BASE)
  2. define GPIOB ((GPIO_TypeDef *) GPIOB_BASE)
  3. define GPIOC ((GPIO_TypeDef *) GPIOC_BASE)
  4. define GPIOD ((GPIO_TypeDef *) GPIOD_BASE)
  5. define GPIOF ((GPIO_TypeDef *) GPIOF_BASE)

Yes, those are recognised, but the one for setting clocks and other are not RCC->AHBENR |= RCC_AHBENR_GPIOCEN; When I try this simple code nothing happens:

int main() { unsigned int i=0; GPIOD->ODR = 0xFFFFFFFF; while (1) { GPIOD->BSRR = i++; } }

Even if I made an error here somewhere, the question remains how to set clocks, and how to adjust port speed, pullups, etc...

posted by D Labinac 05 Jan 2017

Solution found with the eevblog forum, problem was with the AHBENR, the 767 has multiple buses, so this is what needs to be used instead: RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN;

posted by D Labinac 08 Jan 2017