Page 1 of 1

Problem with demo without OS

Posted: Tue Dec 08, 2015 11:28 am
by MiDWalkeR
Hello.
I made a simple "hello world" project(blinking LED on PB2), using stm32l4discovery board.
For the first time i didn't use OS.

Code: Select all

#include "ch.h"
#include "hal.h"
#include "test.h"

int main(void)
{
   halInit();
   palSetPadMode(GPIOB, 2, PAL_MODE_OUTPUT_PUSHPULL);

   while(1) {
      for(volatile int32_t i = 0; i < 300000; i++);
      GPIOB->ODR ^= 1 << 2;
   }
}

everything was OK.
After that i wrote the following:

Code: Select all

#include "ch.h"
#include "hal.h"
#include "test.h"

int main(void)
{
   halInit();
   RCC->AHB2ENR |= RCC_AHB2ENR_GPIOBEN;
   GPIOB->MODER |= GPIO_MODER_MODER2_0;

   while(1) {
      for(volatile int32_t i = 0; i < 300000; i++);
      GPIOB->ODR ^= 1 << 2;
   }
}

Nothing happened:(
Registers PUPDR, OTYPER, OSPEEDR i didn't use, because config. bits for that registers have the same values as in the reset state.
Can someone help me? What is a difference?

Thanks

Re: Problem with demo without OS

Posted: Tue Dec 08, 2015 11:38 am
by Giovanni
Hi,

Please don't post in random places, I had to split the topic.

I suggest to study what palSetPadMode() does internally, the difference is all there.

Giovanni