1. 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.
    Dismiss Notice

Tool chains For the STM32F4

Discussion in 'ARM' started by be80be, Oct 19, 2011.

  1. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    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 (text):

    #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)
     
     
  2. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Ok new code using there header:
    Code (text):

    #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
     
  3. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,642
    Likes:
    109
    Location:
    Michigan, USA
    Yeah, the "free offer" link disappeared sometime Thursday or Friday. Bummer!
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US

    Yeah thank goodness i cought it in time...

    Hey guys check this out: http://www.electro-tech-online.com/threads/ipad.122741/

    Did i post my feedback in the wrong section or something?
     
  6. .W4GNS

    .W4GNS New Member

    Joined:
    Oct 24, 2010
    Messages:
    22
    Likes:
    1
    Location:
    Virginia, USA
    DigiKey has the eval boards in stock now @ 19.50 + shipping

     
    Last edited: Oct 31, 2011
  7. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
  8. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,642
    Likes:
    109
    Location:
    Michigan, USA
    Thanks Jason (AtomSoft)...
     
  9. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US

    Your welcome!
     
  10. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,869
    Likes:
    144
    Location:
    morristown,tn
    Jason That code looks sweet thankes for posting it
    .
     
    Last edited: Nov 8, 2011
  11. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Your welcome as well!
     
  12. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    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: Nov 8, 2011
  13. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    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 (text):

    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 :(
     
  14. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,642
    Likes:
    109
    Location:
    Michigan, USA
    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: Nov 9, 2011
  15. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    What spreadsheet?
     
  16. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,642
    Likes:
    109
    Location:
    Michigan, USA
    Goto the Design support tab on the STM32F407VG web page and grab the AN3988 Clock Config Tool pdf file and the actual Clock Config Tool spreadsheet (near the bottom of the page)...

    Regards...
     
  17. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    WOW I NEVER SAW THAT LINK BEFORE! thanks a ton!
     
  18. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Thanks again here is a sample of what i got towards delays... Almost PERFECT!

    [​IMG]
     

    Attached Files:

  19. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    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.......

    [​IMG]
     

    Attached Files:

  20. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    New Version includes SIDE pins and legend :)
    [​IMG]
     

    Attached Files:

  21. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,642
    Likes:
    109
    Location:
    Michigan, USA
    Wow, that many pins are being used? That's a surprise...
     

Share This Page