AnsweredAssumed Answered

STM32 runın at 16 mhz

Question asked by uzun.fatih on Dec 14, 2013
Latest reply on Dec 16, 2013 by Andrew Neil
I wrote 1 sn delay code for stm32 and ı used 168 mhz system clock.My delay cycle ıs 16000 for each ms and ıt work led blınk 1 sn.It dıdn't work when ıt was 168000 shouldn't it have worked at 168000 cycle.my code ıs

**
**  File        : main.c
**
**  Abstract    : main function.
**
**  Functions   : main
**
**  Environment : Atollic TrueSTUDIO(R)
**                STMicroelectronics STM32F4xx Standard Peripherals Library
**
**  Distribution: The file is distributed “as is,” without any warranty
**                of any kind.
**
**  (c)Copyright Atollic AB.
**  You may use this file as-is or modify it according to the needs of your
**  project. This file may only be built (assembled or compiled and linked)
**  using the Atollic TrueSTUDIO(R) product. The use of this file together
**  with other tools than Atollic TrueSTUDIO(R) is not permitted.
**
*****************************************************************************
*/


/* Includes */
#include "stm32f4xx.h"




/* Private macro */
/* Private variables */
/* Private function prototypes */
/* Private functions */


/**
**===========================================================================
**
**  Abstract: main program
**
**===========================================================================
*/
void delay_ms(int delay1)
{
     delay1 = delay1*16000;
     while (--delay1)
     {
     }
}
int main(void)
{






     GPIO_InitTypeDef GPIO_InitStruct;




          RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);




          GPIO_InitStruct.GPIO_Pin = GPIO_Pin_15 | GPIO_Pin_14 | GPIO_Pin_13 | GPIO_Pin_12; // we want to configure all LED GPIO pins
          GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;           // we want the pins to be an output
          GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz;      // this sets the GPIO modules clock speed
          GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;      // this sets the pin type to push / pull (as opposed to open drain)
          GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;      // this sets the pullup / pulldown resistors to be inactive
          GPIO_Init(GPIOD, &GPIO_InitStruct);                  // this passes the configuration to the Init function which takes care of the low level stuff




  /* Infinite loop */
  while (1)
  {
      // if(1 == GPIO_ReadInputDataBit( GPIOA,GPIO_Pin_0))
      // {
           // while(1 == GPIO_ReadInputDataBit( GPIOA,GPIO_Pin_0));


            GPIO_SetBits ( GPIOD, GPIO_Pin_14) ;
            delay_ms(1000);
            GPIO_ResetBits (GPIOD, GPIO_Pin_14) ;
            delay_ms(1000);




      // }
  }
}




/*
 * Callback used by stm32f4_discovery_audio_codec.c.
 * Refer to stm32f4_discovery_audio_codec.h for more info.
 */
void EVAL_AUDIO_TransferComplete_CallBack(uint32_t pBuffer, uint32_t Size){
  /* TODO, implement your code here */
  return;
}


/*
 * Callback used by stm324xg_eval_audio_codec.c.
 * Refer to stm324xg_eval_audio_codec.h for more info.
 */
uint16_t EVAL_AUDIO_GetSampleCallBack(void){
  /* TODO, implement your code here */
  return -1;
}

Outcomes