Looking to do some simple pin manipulation here and getting confused by the many 100's of examples that all do things in a different manner. I'm use to the PINB BBRB paradigm... Trying to get an idea of how this works on arm.
for reference I'm working with the stm32f205 using uvision.
Main, issues are 1) Type def is missing this BRR I get no member in GPIO_Type_Def 2) Won't = (1<<7); set all pins to clear but PB8 ? 3) Is PIOB->BSRR |= (1<<7); now a better approach? 4) Will PIOB->BSRR &= ~(1<<7); no undo the above? 5) is MODER simulator to DDR and PUPDR to PORT, if so what is OTYPERI(push pull ) for?
GPIOB->MODER |= GPIO_MODER_MODER7_0;//output GPIOB->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR7;//set max speed GPIOB->OTYPER &= ~GPIO_OTYPER_OT_7;//push pull mode GPIOB->PUPDR &= ~GPIO_OTYPER_OT_7 ;//disable pull up down.
while (1) {
GPIOB->BSRR = (1<<7); osDelay(1000U); GPIOB->BRR = (1<<7); osDelay(1000U); }
This page helped a lot hertaville.com/stm32f0-gpio-tutorial-part-1.html
so, 1 unanswered
2 answered 3 answered 4 answered
since I do not have brr, I learned I could do this.
GPIOB->MODER |= GPIO_MODER_MODER7_0;//output
GPIOB->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR7;//set max speed
GPIOB->OTYPER &= ~GPIO_OTYPER_OT_7;//push pull mode
GPIOB->PUPDR &= ~GPIO_OTYPER_OT_7 ;//disable pull up down.
while (1)
{
GPIOB->BSRR = (1<<7);
osDelay(1000U);
GPIOB->BSRR = (1<<23);
}
Though the code still is not blinking the LED.
GPIOB->PUPDR &= ~GPIO_OTYPER_OT_7 ;//disable pull up down. ???!
~GPIO_PUPDR_PUPDR7 ?
thx, good catch, still no luck.
ok added this
__GPIOC_CLK_ENABLE();
After that the debug session works but not when flashed to device. To be clear, the physical LED is going on at line. GPIOC->BSRR = (1<<8); and off at line GPIOC->BSRR = (1<<24); when I step, but not if flashed?
power cycling the system made it work.