Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Tool chains For the STM32F4

Status
Not open for further replies.
I might quit this and use there Header file i found that all this stuff is defined but in the bottom half of header:
EX:
Code:
#define  RCC_AHB1RSTR_GPIOARST               ((uint32_t)0x00000001)
#define  RCC_AHB1RSTR_GPIOBRST               ((uint32_t)0x00000002)
#define  RCC_AHB1RSTR_GPIOCRST               ((uint32_t)0x00000004)
#define  RCC_AHB1RSTR_GPIODRST               ((uint32_t)0x00000008)
#define  RCC_AHB1RSTR_GPIOERST               ((uint32_t)0x00000010)
#define  RCC_AHB1RSTR_GPIOFRST               ((uint32_t)0x00000020)
#define  RCC_AHB1RSTR_GPIOGRST               ((uint32_t)0x00000040)
#define  RCC_AHB1RSTR_GPIOHRST               ((uint32_t)0x00000080)
#define  RCC_AHB1RSTR_GPIOIRST               ((uint32_t)0x00000100)
#define  RCC_AHB1RSTR_CRCRST                 ((uint32_t)0x00001000)
#define  RCC_AHB1RSTR_DMA1RST                ((uint32_t)0x00200000)
#define  RCC_AHB1RSTR_DMA2RST                ((uint32_t)0x00400000)
#define  RCC_AHB1RSTR_ETHMACRST              ((uint32_t)0x02000000)
#define  RCC_AHB1RSTR_OTGHRST                ((uint32_t)0x10000000)
 
Ok new code using there header:
Code:
#include "stm32f4xx.h"    //Include main header for MCU

#define LED1 0x1000
#define LED2 0x2000
#define LED3 0x4000
#define LED4 0x8000

void delay(int ticks);    //Used for delays

void main()
{
  //Bits 1:0 (01) HSE oscillator selected as system clock
  RCC->CFGR = RCC_CFGR_SW_HSE;

  //Bit 3 GPIODEN: IO port D clock enable (1: IO port D clock enabled)
  RCC->AHB1ENR = RCC_AHB1ENR_GPIODEN;
  
  //Bit 16 HSEON: HSE clock enable (1: HSE oscillator ON)
  RCC->CR |= RCC_CR_HSEON;
  
  //Bit 17 HSERDY: HSE clock ready flag (1: HSE oscillator ready)
  while((RCC->CR & RCC_CR_HSERDY)==0);

  //GPIO port mode register (all PORTD = 01: General purpose output mode)
  GPIOD->MODER   = GPIO_MODER_MODER12_0 | GPIO_MODER_MODER13_0 | GPIO_MODER_MODER14_0 | GPIO_MODER_MODER15_0; 
  
  //GPIO port speed reg. (all portd = 10: 50 MHz Fast speed)
  GPIOD->OSPEEDR = GPIO_OSPEEDER_OSPEEDR12_1 | GPIO_OSPEEDER_OSPEEDR13_1 | GPIO_OSPEEDER_OSPEEDR14_1 | GPIO_OSPEEDER_OSPEEDR15_1;

  while(1)
  {
    //My Crap Delay (~500,000 clks)
    delay(50000);
    
    //GPIO port output data register (ALL HIGH)
    GPIOD->ODR = LED1 | LED2 | LED3 | LED4;  

    //My Crap Delay (~500,000 clks)
    delay(50000);
    
    //GPIO port output data register (ALL LOW)
    GPIOD->ODR &= ~(LED1 | LED2 | LED3 | LED4);

  }
}

void delay(int ticks)
{
  while(ticks--);
}

side note mouser sells MCU only for $17 and EVAL for $16.35.... wow crazy... I will def get the board. But wont be in stock til 1/9/2012
 
Jason That code looks sweet thankes for posting it
.
 
Last edited:
Im working on getting the PLL stuff right so i can use this bad boy at full speed: 168MHz (1.25DMIP/mhz) = 210DMIP

There are so many setting for the clocks its crazy! I have PLL with correct values now i need RCC CFGR and RCC RC registers.
 
Last edited:
This is driving me crazy! I know the PLL and stuff is getting set but nothing seems to be working. Im trying this code for now. Im trying to debug and it keeps crashing!
Code:
void initDiscovery(void)
{
  RCC->CR &= 0xf0f0ff04;   //Clear Register without changing reserved bits or Calibration
  
  RCC->PLLCFGR &= 0xf0bc0000; //Clear Register without changing reserved bits
  RCC->PLLCFGR |= 0x7402a04;  // PLLQ:7, PLLSRC:HSE, PLLP:2, PLLN:168,PLLM:4

  RCC->CFGR &= 0x300;       //Clear Register without changing reserved bits
  RCC->CFGR |= 0xc0689402;  //MCO2:PLL, MCO1:PLL, RTCPRE:8, PPRE2:2, PPRE1:4, SW:PLL

  RCC->CR |= 0x1010000;    //PLL ON, HSE ON

  while((RCC->CR & 0x2020000)==0);  //Wait for HSE and PLL to stabilize
  
  RCC->AHB1ENR &= 0x818bee00;  //Clear Register without changing reserved bits
  RCC->AHB1ENR |= 0x1ff;       //IO port A:I clock enable
  
  GPIOA->MODER = 0x55555555;    // ALL GPO (General Purpose Output)
  GPIOA->OSPEEDR = 0xaaaaaaaa;  //50Mhz Speed
  GPIOA->PUPDR = 0;             //NO PULL UP/DOWN

  GPIOB->MODER = 0x55555555;    // ALL GPO (General Purpose Output)
  GPIOB->OSPEEDR = 0xaaaaaaaa;  //50Mhz Speed
  GPIOB->PUPDR = 0;             //NO PULL UP/DOWN

  GPIOC->MODER = 0x55555555;    // ALL GPO (General Purpose Output)
  GPIOC->OSPEEDR = 0xaaaaaaaa;  //50Mhz Speed
  GPIOC->PUPDR = 0;             //NO PULL UP/DOWN

  GPIOD->MODER = 0x55555555;    // ALL GPO (General Purpose Output)
  GPIOD->OSPEEDR = 0xaaaaaaaa;  //50Mhz Speed
  GPIOD->PUPDR = 0;             //NO PULL UP/DOWN

  GPIOE->MODER = 0x55555555;    // ALL GPO (General Purpose Output)
  GPIOE->OSPEEDR = 0xaaaaaaaa;  //50Mhz Speed
  GPIOE->PUPDR = 0;             //NO PULL UP/DOWN

  GPIOF->MODER = 0x55555555;    // ALL GPO (General Purpose Output)
  GPIOF->OSPEEDR = 0xaaaaaaaa;  //50Mhz Speed
  GPIOF->PUPDR = 0;             //NO PULL UP/DOWN

  GPIOG->MODER = 0x55555555;    // ALL GPO (General Purpose Output)
  GPIOG->OSPEEDR = 0xaaaaaaaa;  //50Mhz Speed
  GPIOG->PUPDR = 0;             //NO PULL UP/DOWN

  GPIOH->MODER = 0x55555555;    // ALL GPO (General Purpose Output)
  GPIOH->OSPEEDR = 0xaaaaaaaa;  //50Mhz Speed
  GPIOH->PUPDR = 0;             //NO PULL UP/DOWN

  GPIOI->MODER = 0x55555555;    // ALL GPO (General Purpose Output)
  GPIOI->OSPEEDR = 0xaaaaaaaa;  //50Mhz Speed
  GPIOI->PUPDR = 0;             //NO PULL UP/DOWN

}

I would have to unplug then re-plug the USB cord just to get it recognized again in crossworks.. this sucks :(
 
The system_stm32f4xx.c file attached to this forum post was built using the Clock Config Tool Spreadsheet and is supposed to be for 168 MHz operation (with 48 MHz for USB)...
 
Last edited:
Thanks again here is a sample of what i got towards delays... Almost PERFECT!

speedtest-jpg.58295
 

Attachments

  • SpeedTest.jpg
    SpeedTest.jpg
    374.9 KB · Views: 595
wow im a idiot. Im trying to get a LCD to work assuming all the pins broken out are free and they are not so i made a EXCEL Sheet (image for you people) of all the PORT pins and which ones are used up and free... Used are highlighted.......

stm32f4usage-jpg.58331
 

Attachments

  • STM32F4Usage.jpg
    STM32F4Usage.jpg
    92.4 KB · Views: 588
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top