2021-04-10 06:09 AM
I am only able to use 2 GPIO pins with an STM32F767ZI on a Nucleo-144 board. The issue doesn't appear to be with any specific pins, it's just that only 2 pins seem to output any voltage at all.
Take this code for example:
main.c
#include "./headers/stm32f767xx.h"
#include <stdint.h>
int main(void)
{
initMotor(0);
initMotor(1);
initMotor(2);
uint32_t a = 0;
while (1)
{
if (a >= 25000)
{
stepMotor(0);
stepMotor(1);
stepMotor(2);
a = 0;
}
a++;
}
}
./drivers/motor.c
#include "../headers/stm32f767xx.h"
void initMotor(int step_pin)
{
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOGEN;
GPIOG->MODER |= (0b01 << (step_pin * 2));
GPIOG->OTYPER &= ~(0b1 << step_pin);
GPIOG->ODR &= ~(0b1 << step_pin);
}
void stepMotor(int step_pin)
{
GPIOG->ODR ^= (0b1 << step_pin);
}
Using this code, only 2 of the 3 GPIO ports give out a voltage as I would expect them to. If main.c is modified to remove any of the three motors/pins, the other two will work (they give out a voltage which changes from HIGH to LOW every time period).
This issue extends even when adding LEDs which are already on the board.
Only a maximum of 2 GPIO pins (regardless of whether it is GPIOA, GPIOB, etc.) ever seem to work.
I am very unsure of the cause of this, and would appreciate any direction that people can point me in.
Solved! Go to Solution.
2021-04-13 06:55 AM
the peripheral clock had already been enabled though, would OR'ing the register (as if enabling it again, but essentially a useless operation) really make a difference?
2021-04-13 08:59 AM
Also, it hardly explains that some of the bits are set, others are not.
In 'F7, AFAIK, GPIO is on AHB which runs at the same clock as the Cotex(sic!) core.
JW
2021-04-14 07:58 AM
Hello All,
Thanks @Community member , for reporting this typo (Cotex). I raised it internally for fix in the coming release of RM0410.
I will have a look on this reported issue regarding GPIOG register and I will take the necessary action.
Thanks
Imen
2021-04-14 02:43 PM
Thanks, Imen.
Jan
@Imen DAHMEN