Arduino Forum

Using Arduino => Microcontrollers => Topic started by: Resinator on May 19, 2012, 12:26 pm

Title: STM32F4
Post by: Resinator on May 19, 2012, 12:26 pm
I got one of the discovery development boards for the princely sum of £9!!

I have been reading and searching and reading some  more about how to program the thing and its left my head hurting!!

STLINK V2, CN3 jumpers? WTF???

Can anyone hold my hand and explain in laymens terms how to get started with this very powerful piece of kit

I have lots of questions I just want to test the waters here to see whos actually using one!

Thanks in advance
Title: Re: STM32F4
Post by: robtillaart on May 19, 2012, 12:34 pm
Quote
discovery development boards


Do you have a link ?
Title: Re: STM32F4
Post by: Resinator on May 19, 2012, 12:41 pm
http://uk.farnell.com/jsp/displayProduct.jsp?sku=2009276&CMP=KNC-GUK-FUK-GEN-LISTINGS&gross_price=true

Its this little baby

Basically my questions are many, but I just want to know what compiler I should use and how on earth do i get started according to the literature its really easy to get going but not in my experience
Title: Re: STM32F4
Post by: westfw on May 19, 2012, 11:59 pm
Quote
and it's left my head hurting!

Yeah, that's one of the nice things about Arduino.  Start blinking LEDs without having to first understand a complicated IDE and programming environment...
Title: Re: STM32F4
Post by: cyclegadget on May 20, 2012, 03:01 am

  The best free IDE I have found for the discovery board is Atollic light, I tried others with less luck. http://www.atollic.com/index.php/download/truestudio-for-arm

You also need to download nearly all these PDFs. http://www.st.com/internet/evalboard/product/252419.jsp

You need to start reading, it will take some work.

Arduino is a lot easier in my  opinion, but STM32 has massive speed and possibilities.
Title: Re: STM32F4
Post by: Resinator on May 20, 2012, 05:11 am
Thanks for the replies

I was trying with CooCox CoIde but its left me bewildered

I already have the PDF's (courtesy of work!) and I have been reading them (all day!) but like you point out its pretty hard work

Hard work I am ok with, I am downloading attolic now, I dont suppose you have any test codes? blink LED hello world anything! I am a total noob
Title: Re: STM32F4
Post by: maniacbug on May 20, 2012, 05:14 am
You can also check out leaflabs.com.  They are working on the Maple Native II using this chip, so there might be something there you can use.
Title: Re: STM32F4
Post by: Resinator on May 20, 2012, 05:23 am
I had seen the maple IDE (looks exactly like Arduino IDE!)

But the tech speak really scared me off!, I just want something I can learn with relatively easily
Title: Re: STM32F4
Post by: maniacbug on May 20, 2012, 06:23 am
Oh goodness..  If Maple scares you off, I don't think there's much ARM stuff out there that will be palatable.  You could TRY Simple Cortex http://hackaday.com/2012/03/25/simplecortex-for-when-an-arduino-is-too-wimpy/ Although that is a completely different chip.

Anyway, I think it's safe to say that "easy" and "STM32F4" don't really go together right now.
Title: Re: STM32F4
Post by: cyclegadget on May 20, 2012, 02:51 pm

I dont suppose you have any test codes? blink LED hello world anything! I am a total noob


Sorry, so far I have only got as far as changing the loaded program with one that makes the leds come on and stay on. I still have plenty to learn about the language for Atollic and STM32.

Some people on LeafLabs forum have made a Maple IDE port to the STM32F4 discovery but, I have not figured out how to use it. The Maple IDE is a based on Arduino IDE but, the hardware makes programming a little different in some cases.
Title: Re: STM32F4
Post by: Resinator on May 23, 2012, 10:05 am

Oh goodness..  If Maple scares you off, I don't think there's much ARM stuff out there that will be palatable.  You could TRY Simple Cortex http://hackaday.com/2012/03/25/simplecortex-for-when-an-arduino-is-too-wimpy/ Although that is a completely different chip.

Anyway, I think it's safe to say that "easy" and "STM32F4" don't really go together right now.


What scared me off was all the multitude of problems people have! like remapping the peripherals etc etc! but my main argument is I want to learn how to program properley, Arduino IDE is really good for getting started but its so simplified and I think the Maple IDE is just the same good for beginners but a lot more to learn


Sorry, so far I have only got as far as changing the loaded program with one that makes the leds come on and stay on. I still have plenty to learn about the language for Atollic and STM32.

Some people on LeafLabs forum have made a Maple IDE port to the STM32F4 discovery but, I have not figured out how to use it. The Maple IDE is a based on Arduino IDE but, the hardware makes programming a little different in some cases.


Well I have not given up!, I have tried Coocox CoIDE with no luck but I have had some success with Attolic True Studio, pretty straight forward process once you know what options to set etc.

So I first started uploading a program that just turned the four LEDs on and after lots of messing about I have this very basic program


Code: [Select]
#include "stm32f4_discovery.h"
int T=1000000;

GPIO_InitTypeDef  GPIO_InitStructure;

void Delay(__IO uint32_t nCount);

int main(void)
{


  /* GPIOD Periph clock enable */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

  /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOD, &GPIO_InitStructure);

  while (1)
  {
    /* PD12 to be toggled */
    GPIO_SetBits(GPIOD, GPIO_Pin_12);
   
    /* Insert delay */
    Delay(T);
   
    /* PD13 to be toggled */
    GPIO_SetBits(GPIOD, GPIO_Pin_13);
   
    /* Insert delay */
    Delay(T);
 
    /* PD14 to be toggled */
    GPIO_SetBits(GPIOD, GPIO_Pin_14);
   
    /* Insert delay */
    Delay(T);
   
    /* PD15 to be toggled */
    GPIO_SetBits(GPIOD, GPIO_Pin_15);
   
    /* Insert delay */
    Delay(T);
   
    GPIO_ResetBits(GPIOD, GPIO_Pin_12);
    Delay(T);

    GPIO_ResetBits(GPIOD, GPIO_Pin_13);
    Delay(T);
       
    GPIO_ResetBits(GPIOD, GPIO_Pin_14);
    Delay(T);
   
    GPIO_ResetBits(GPIOD, GPIO_Pin_15);
    Delay(T);

    GPIO_SetBits(GPIOD, GPIO_Pin_15);
    Delay(T);

    GPIO_SetBits(GPIOD, GPIO_Pin_14);
    Delay(T);

    GPIO_SetBits(GPIOD, GPIO_Pin_13);
    Delay(T);

    GPIO_SetBits(GPIOD, GPIO_Pin_12);
    Delay(T);

    GPIO_ResetBits(GPIOD, GPIO_Pin_15);
    Delay(T);

    GPIO_ResetBits(GPIOD, GPIO_Pin_14);
    Delay(T);
     
    GPIO_ResetBits(GPIOD, GPIO_Pin_13);
    Delay(T);
                           
    GPIO_ResetBits(GPIOD, GPIO_Pin_12);
    Delay(T);
  }
}


void Delay(__IO uint32_t nCount)
{
  while(nCount--)
  {
  }
}


I can upload the code and alter the delay value T, the great thing with attolic is I can debug the program and single step through which is a massive help for me to learn how a C program runs in fact this has learnt me a lot

Any other noobs need help getting this going just drop me a message and I will do my best to help, its taken me about 5 days reading and playing

I have lots of questions


Code: [Select]
void Delay(__IO uint32_t nCount)
{
  while(nCount--)
  {
  }
}


Can anyone explain what this part does?

uint32_t is an unsigned 32 bit Int, I know what a while loop does but I dont get what that does in the code


Code: [Select]

GPIO_InitTypeDef  GPIO_InitStructure;


What about this one any explanations?


Finally for today

Code: [Select]
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;

I see this a lot | its the Or command yeah?, whats it do in the above line?


Many thanks for looking




Title: Re: STM32F4
Post by: robtillaart on May 23, 2012, 05:28 pm
Quote
I see this a lot | its the Or command yeah?, whats it do in the above line?


it is the bitwise OR (as opposed to the logical or boolean OR) and it "adds up" bittpatterns

The rules are

0 or 0 = 0
0 or 1 = 1
1 or 0 = 1
1 or 1 = 1

so if you have 2 bytes A=00001111 and B=00111100 then C= A|B = 00111111  it is bitwised or-ed

This technique is used often to set registers and masks, more see - http://www.arduino.cc/playground/Code/BitMath


Title: Re: STM32F4
Post by: Resinator on Jun 05, 2012, 01:12 pm
Thanks for that Rob, I had actually read that before!

Well I have been working a lot on this STM32F4 and it hasn't been easy but nothing in life worth doing ever is

I have so far managed to:

Set up ports and blink LED's

Do some hardcore maths (well power series!, and it is pretty quick)

Use a timer to count and generate an interrupt

Use the ADC (this is something I am currently working on as the reading seems to saturate at 3V????) its pretty complex with all the settings

Got much better with Attolic and C programming and learnt to debug (ish)


So much more to learn not least with C

For instance what the hell does the typedef do to a structure??


Code: [Select]
typedef struct
{
 uint32_t ADC_Resolution;                /*!< Configures the ADC resolution dual mode.
                                              This parameter can be a value of @ref ADC_resolution */                                  
 FunctionalState ADC_ScanConvMode;       /*!< Specifies whether the conversion
                                              is performed in Scan (multichannels)
                                              or Single (one channel) mode.
                                              This parameter can be set to ENABLE or DISABLE */
 FunctionalState ADC_ContinuousConvMode; /*!< Specifies whether the conversion
                                              is performed in Continuous or Single mode.
                                              This parameter can be set to ENABLE or DISABLE. */
 uint32_t ADC_ExternalTrigConvEdge;      /*!< Select the external trigger edge and
                                              enable the trigger of a regular group.
                                              This parameter can be a value of
                                              @ref ADC_external_trigger_edge_for_regular_channels_conversion */
 uint32_t ADC_ExternalTrigConv;          /*!< Select the external event used to trigger
                                              the start of conversion of a regular group.
                                              This parameter can be a value of
                                              @ref ADC_extrenal_trigger_sources_for_regular_channels_conversion */
 uint32_t ADC_DataAlign;                 /*!< Specifies whether the ADC data  alignment
                                              is left or right. This parameter can be
                                              a value of @ref ADC_data_align */
 uint8_t  ADC_NbrOfConversion;           /*!< Specifies the number of ADC conversions
                                              that will be done using the sequencer for
                                              regular channel group.
                                              This parameter must range from 1 to 16. */
}ADC_InitTypeDef;




which is a structure so that when I type the below

Code: [Select]

ADC_InitTypeDef ADC_InitStructure;

 ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
 ADC_InitStructure.ADC_ScanConvMode = ENABLE;
 ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
 ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
 ADC_InitStructure.ADC_ExternalTrigConv=0x00000000;
 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
 ADC_InitStructure.ADC_NbrOfConversion = 2;
 ADC_Init(ADC1, &ADC_InitStructure);


A structure is created called ADC_InitStructure which is identical to the structure ADC_Init

The different members are populated then the program uses

ADC_Init(ADC1, &ADC_InitStructure);

To go to the ACD_INIT structure with the variable ADC1 and the address of the ADC_InitStructure

I also see uint32_t/uint16_t etc now its obviously an unsigned 32/16 bit int but whats the difference with just the unsigned int data type?


Now thats my understanding and I am wrong a lot please explain/discuss

these STM32F4 boards are really really good fun
Title: Re: STM32F4
Post by: westfw on Jun 05, 2012, 06:34 pm
Quote
I also see uint32_t/uint16_t etc now its obviously an unsigned 32/16 bit int but whats the difference with just the unsigned int data type?

Types are defined that are are explictitly 16 or 32 bits long.  The normal C data types (int, long) are not defined to be of a particular size (and an "int" is 16 bits on an AVR, but 32bits on an ARM, for example.)
Title: Re: STM32F4
Post by: Resinator on Jun 05, 2012, 11:05 pm
so an int is 32bit on an ARM I can understand the uint16_t is different to an int as its half the length

So am I right that a uint32_t is identical to an Int i.e both 32 bits long so no difference at all

What does Typedef do to a structure and why is it sometimes a capital T?

Questions questions questions
Title: Re: STM32F4
Post by: wanderson on Jun 05, 2012, 11:38 pm
a uint32_t is the same as an unsigned long (not long) on the arduino...  Other platforms may not have the same equivalence. 

The captital in the typedef above is simply a means of using the term typedef as part of the variable name, when the keyword typedef is use in c/c++ it is a way of assigning a synonym to an existing data type.
Title: Re: STM32F4
Post by: westfw on Jun 05, 2012, 11:49 pm
Quote
So am I right that a uint32_t is identical to an Int i.e both 32 bits long so no difference at all

On an ARM, yes.  On an AVR, they would be different sizes.  If you wanted to hold something like an IP address (32bits for v4), you could use an "int" on an ARM, but you'd have to use a "long" on an AVR: an incompatibility.  Instead, your program should use "uint32_t" for the IP address, and it would run on both AVR and ARM (assuming all other architectural dependencies are fixed as well.)

"typedef" defines a name that acts like a type (ie like "int" or "long"); it's a shorthand convenience, especially when you get to more complex structures (containing other structures, etc.)

So someplace in an AVR include file there is likely to be a line that looks like:
typedef unsigned long uint32_t; that means "treat the name "uint32_t" as a variable type, that is the same as "unsigned long".  The similar file on an ARM might contain "typedef unsigned int uint32_t;"
Code: [Select]
typedef uint32_t ip_addr_t;

typedef struct ip_pheader {ip_addr_t phdr_ip;
uint16_t phdr_sourceport;
uint16_t phdr_destport;} ip_pheader_t;

typedef struct socket {ip_pheader_t socket_local;
ip_pheader_t socket_remote;
uint32_t socket_timestamp;
// etc
} socket_t;

int open_socket (socket_t *s) {
  // code
}

is somewhat clearer than having to having to include the "struct xxx yyy" at each point.

I don't know anything about "Typedef" with a capital T.  As wanderson noted, there are all sorts of (local) conventions to indentifying a type as such, and coming up with a name that is easy to understand.
Title: Re: STM32F4
Post by: wanderson on Jun 06, 2012, 12:31 am

Quote
So am I right that a uint32_t is identical to an Int i.e both 32 bits long so no difference at all

On an ARM, yes.  On an AVR, they would be different sizes.  


Even on the ARM wouldn't uint32_t be an unsigned value, int be a signed value?  So while they would have the same physical size and could be cast to one another with no loss, they would be interpreted differently by the compiler, correct?
Title: Re: STM32F4
Post by: Resinator on Jun 06, 2012, 01:33 am
Quote
On an ARM, yes.  On an AVR, they would be different sizes.  If you wanted to hold something like an IP address (32bits for v4), you could use an "int" on an ARM, but you'd have to use a "long" on an AVR: an incompatibility.  Instead, your program should use "uint32_t" for the IP address, and it would run on both AVR and ARM (assuming all other architectural dependencies are fixed as well.


Thats clear thanks
Quote

"typedef" defines a name that acts like a type (ie like "int" or "long"); it's a shorthand convenience, especially when you get to more complex structures (containing other structures, etc.)

So someplace in an AVR include file there is likely to be a line that looks like:
typedef unsigned long uint32_t; that means "treat the name "uint32_t" as a variable type, that is the same as "unsigned long".  The similar file on an ARM might contain "typedef unsigned int uint32_t;"


Not so clear!

Its the code that confuses me

Heres the form for the STM32F4, the name appears after the closing }


//
Code: [Select]
In a header file//
typedef struct
{
        Hours_Spent;                
                               
        Hairs_Pulled_Out;  

}Learning_CTypeDef; //Capital T


Learning_CTypeDef Resinators_Learning_C;

 Resinators_Learning_C.Hours_Spent = 999;
 Resinators_Learning_C.Hairs_Pulled_Out = LOTS;




Code: [Select]
Learning_CTypeDef Resinators_Learning_C;


This makes a structure called Resinators_Learning_C which identical to the Learning_C

Code: [Select]
Resinators_Learning_C.Hours_Spent = 999;
 Resinators_Learning_C.Hairs_Pulled_Out = LOTS;


This populates the structure with the values

What I dont get is the typedef it appears twice once at start with no capital and at the end where I name the structure



Title: Re: STM32F4
Post by: wanderson on Jun 06, 2012, 02:04 am
Where it appears at the end with the Capital the word Typedef is being used as part of the name used to indicate that particular structure.  For instance it could have been created like so, and would still perform the same function

Code: [Select]

typedef struct
{
         Hours_Spent;               
                                 
         Hairs_Pulled_Out;   

} ArbitraryName; //Capital T


ArbitraryName Resinators_Learning_C;

  Resinators_Learning_C.Hours_Spent = 999;
  Resinators_Learning_C.Hairs_Pulled_Out = LOTS;
Title: Re: STM32F4
Post by: Resinator on Jun 06, 2012, 01:58 pm
Thanks its really clear, the Typedef was just there in the name to remind me its a structure

But what if it wasnt a structure and it was an enum?.... then what is the difference?

Code: [Select]


typedef enum {
         Hours_Spent;               
                                 
         Hairs_Pulled_Out;   

} ArbitraryName;
Title: Re: STM32F4
Post by: Resinator on Jun 06, 2012, 02:07 pm
Also sometimes they dont put the name after the structure

Usually looks like

Code: [Select]
typedef struct{
         Hours_Spent;               
                                 
         Hairs_Pulled_Out;   

} ArbitraryName;


Sometimes

Code: [Select]
typedef struct ArbitraryName{
         Hours_Spent;               
                                 
         Hairs_Pulled_Out;   

}


The difference is???
Title: Re: STM32F4
Post by: wanderson on Jun 06, 2012, 03:18 pm
These links may help:

http://www.cplusplus.com/doc/tutorial/other_data_types/ (http://www.cplusplus.com/doc/tutorial/other_data_types/)
http://stackoverflow.com/questions/612328/difference-between-struct-and-typedef-struct-in-c (http://stackoverflow.com/questions/612328/difference-between-struct-and-typedef-struct-in-c)
http://www.functionx.com/cpp/keywords/typedef.htm (http://www.functionx.com/cpp/keywords/typedef.htm)
http://stackoverflow.com/questions/385023/why-do-you-use-typedef-when-declaring-an-enum-in-c (http://stackoverflow.com/questions/385023/why-do-you-use-typedef-when-declaring-an-enum-in-c)
http://bcook.cs.georgiasouthern.edu/windowsce/mobile.htm (http://bcook.cs.georgiasouthern.edu/windowsce/mobile.htm)
Title: Re: STM32F4
Post by: westfw on Jun 06, 2012, 10:52 pm
Code: [Select]
typedef struct ArbitraryName{
         Hours_Spent;                           
         Hairs_Pulled_Out;   
}

No semicolon; perhaps the defined type name is on a subsequent line.
Without a name, gcc gives me a warning:
"foo.c:3: warning: useless storage class specifier in empty declaration"
(It still defines "struct ArbitraryName"...)
Title: Re: STM32F4
Post by: Docedison on Jun 07, 2012, 12:48 am
Wow what a Bunch of GOOD STUFF!. I own an STM32 Eval kit (bought it for $14.+ from Newark at the same time I paid for my Raspberry Pi) and frankly it scared the Hell out of me. I am comfortable with ANY phase of electronics but know perhaps enough to engrave legibly on the head of a small pin, my total knowledge of 'C' and reading this thread has caused me to want to re-evaluate that board... Just as soon as I can find time... or a roundtoit... either one will work just fine...   IMO...

Doc
Title: Re: STM32F4
Post by: UnaClocker on Jun 07, 2012, 04:34 am
It's a shame it's not as simple as simply adapting the Arduino environment/compiler to work on the STM32 boards.. I got the F4 back when it was free, and recently scored an F0 freebie as well.
Title: Re: STM32F4
Post by: Resinator on Jun 07, 2012, 07:30 am
Wanderson great links thanks



Code: [Select]
typedef struct ArbitraryName{
         Hours_Spent;                           
         Hairs_Pulled_Out;   
}

No semicolon; perhaps the defined type name is on a subsequent line.
Without a name, gcc gives me a warning:
"foo.c:3: warning: useless storage class specifier in empty declaration"
(It still defines "struct ArbitraryName"...)



Sorry mate, that code doesn't make sense I must of made a mistake when I copied it!


Wow what a Bunch of GOOD STUFF!. I own an STM32 Eval kit (bought it for $14.+ from Newark at the same time I paid for my Raspberry Pi) and frankly it scared the Hell out of me. I am comfortable with ANY phase of electronics but know perhaps enough to engrave legibly on the head of a small pin, my total knowledge of 'C' and reading this thread has caused me to want to re-evaluate that board... Just as soon as I can find time... or a roundtoit... either one will work just fine...   IMO...

Doc


The board is an amazing piece of kit, I am not very good with the C language myself but I know far more than I did two weeks ago just think how much I could know in two months!



It's a shame it's not as simple as simply adapting the Arduino environment/compiler to work on the STM32 boards.. I got the F4 back when it was free, and recently scored an F0 freebie as well.


Its in no way as simple as the Arduino IDE and will never be, however the added complexity offers many advantages to whats possible

Its actually not that bad  if I can do it anyone can, get Attolic and it has a good embedded C project template it takes a couple of days to get familiar with that

I will write a template program tonight if anyones interested, just a simple blinky program and by using the STLink debugger we can single step through and really see what happens, in essence its just a load of 1 and 0's that need to be written to certain registers

I personally love the stm32f4
Title: Re: STM32F4
Post by: UnaClocker on Jun 08, 2012, 11:18 pm
I disagree that it'll NEVER be as easy as the Arduino. The Maple Leaf board uses an Arduino style IDE, and is exactly like the Arduino when programming it. The Maple uses an STM32F1 if I'm not mistaken.
As for an example sketch.. I'd like to see at least one of the ADC's get read, and then use that information to drive a PWM output. Maybe a stepper motor and i2c example too.
At $8-$15 for a STM32 board, it'd make an extremely nice RepRap brain. Overkill, for sure, but for the price...
Title: Re: STM32F4
Post by: Resinator on Jun 10, 2012, 02:32 pm
Code: [Select]
I disagree that

I agree to disagree!, its pretty head busting stuff

I have managed some success, I actually feel like I am getting somewhere, it was pretty straightforward getting one ADC to work but I have struggled getting two to work separately its all this channel stuff that confuses me.

I have a program that uses an interrupt to blink the orange LED and measures the input on Port C pin 0 (Channel 10)


Code: [Select]
#include "stm32f4_discovery.h"
#include <stdio.h>
#include <math.h>
#include "stm32f4xx.h"
void INTTIM_Config(void);
void IO_Config(void);

void ADC1_CH10_Config(void);


void TIM2_IRQHandler(void)//interrupt toggles orange LED = PD13
{
  if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
  {
    GPIO_ToggleBits(GPIOD, GPIO_Pin_13);

    TIM_ClearITPendingBit(TIM2, TIM_IT_Update);

  }
}

int main(void){

int *ADC1_DATA =0x4001204c;//ADC1 Data register (pointer to!)



  INTTIM_Config();
  IO_Config();
  GPIO_SetBits(GPIOD, GPIO_Pin_15|GPIO_Pin_14|GPIO_Pin_12);//Set 3 LED's HIGH


   ADC1_CH10_Config();

   /* Enable ADC1 */
   ADC_Cmd(ADC1, ENABLE);

   
   /* Start ADC1 Software Conversion */
   ADC_SoftwareStartConv(ADC1);


  while (1)
  {


  ADC_SoftwareStartConv(ADC1);
float VIN = *ADC1_DATA*0.720214843 +16.0;
        float IIN = (VIN-2500.0)*0.745614035;



  }
}

void INTTIM_Config(void)
{
  NVIC_InitTypeDef NVIC_InitStructure;

  NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  /* TIM2 clock enable */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
  /* Time base configuration */
  TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
  TIM_TimeBaseStructure.TIM_Period = 500000;  // period 500000 = 0.5 seconds
  TIM_TimeBaseStructure.TIM_Prescaler = 80; // Prescale 80 = 1us per click
  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
  /* TIM IT enable */
  TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
  /* TIM2 enable counter */
  TIM_Cmd(TIM2, ENABLE);
}



void IO_Config(void)

{
  /* GPIOD enable as output for LED's */
  GPIO_InitTypeDef GPIO_InitStructure;
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOD, &GPIO_InitStructure);

/* GPIOC enable as analog input */
 
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1 ;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOC, &GPIO_InitStructure);



}
/* ENABLE ADC1 (channel 10=PC0) */
void ADC1_CH10_Config(void)

{RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
ADC_CommonInitTypeDef ADC_CommonInitStructure;
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
ADC_CommonInit(&ADC_CommonInitStructure);

  ADC_InitTypeDef ADC_InitStructure;

  ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
  ADC_InitStructure.ADC_ScanConvMode = DISABLE;
  ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
  ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
  ADC_InitStructure.ADC_ExternalTrigConv=ADC_ExternalTrigConv_T1_CC1;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfConversion = 1;
  ADC_Init(ADC1, &ADC_InitStructure);

  /* ADC1 regular channels 10 configuration */
  ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 1, ADC_SampleTime_56Cycles);

}
Title: Re: STM32F4
Post by: Resinator on Jun 10, 2012, 09:36 pm
I have had some good success today, I have managed to get three ADC's working independently

However I am unable to configure a single port to work with a single ADC, for example if I use port A pin 0 for ADC1 then trying to configure port A pin 1 to another ADC doesn't work???, so I have had to use a port per an ADC

ADC1=PortA
ADC2=PortB
ADC3=PortC

I wish I knew how to just use one ADC and a single port but it seems like I would have to reconfigure all over again which I would rather just use another ADC after all it is available

I should of mentioned above the reference voltage is 2.96V I dont know how to change this as I have read upto 3.6V as a reference I tried tying VDD to 3.6V but nothing changes

Heres three setup functions that can be called to setup GPIO and the three ADC's

Code: [Select]
void IO_Config(void)

{
 /* GPIOD Periph clock enable */
 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
  GPIO_InitTypeDef  GPIO_InitStructure;
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
 GPIO_Init(GPIOD, &GPIO_InitStructure);

 GPIO_InitTypeDef GPIO_InitStructure;
 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
 GPIO_Init(GPIOC, &GPIO_InitStructure);

 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
 GPIO_Init(GPIOB, &GPIO_InitStructure);

 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
 GPIO_Init(GPIOA, &GPIO_InitStructure);
}

void ADC1_PA0_CH0_Config(void)

{RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
ADC_CommonInitTypeDef ADC_CommonInitStructure;
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
ADC_CommonInit(&ADC_CommonInitStructure);

 ADC_InitTypeDef ADC_InitStructure;

 ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
 ADC_InitStructure.ADC_ScanConvMode = DISABLE;
 ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
 ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
 ADC_InitStructure.ADC_ExternalTrigConv=ADC_ExternalTrigConv_T1_CC1;
 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
 ADC_InitStructure.ADC_NbrOfConversion = 1;
 ADC_Init(ADC1, &ADC_InitStructure);

 /* ADC1 regular channels 10 configuration */
 ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_56Cycles);
 /* Enable ADC1 */
    ADC_Cmd(ADC1, ENABLE);
}


void ADC2_PB0_CH8_Config(void)
{  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC2, ENABLE);
   ADC_CommonInitTypeDef ADC_CommonInitStructure;
  ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
  ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
  ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
  ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
  ADC_CommonInit(&ADC_CommonInitStructure);

 ADC_InitTypeDef ADC_InitStructure;

 ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
 ADC_InitStructure.ADC_ScanConvMode = DISABLE;
 ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
 ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
 ADC_InitStructure.ADC_ExternalTrigConv=ADC_ExternalTrigConv_T1_CC1;
 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
 ADC_InitStructure.ADC_NbrOfConversion = 1;
 ADC_Init(ADC2, &ADC_InitStructure);

 ADC_RegularChannelConfig(ADC2, ADC_Channel_8, 1, ADC_SampleTime_56Cycles);
 /* Enable ADC2 */
  ADC_Cmd(ADC2, ENABLE);
}


void ADC3_PC0_CH10_Config(void)
{RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC3, ENABLE);
 ADC_InitTypeDef       ADC_InitStructure;
 ADC_CommonInitTypeDef ADC_CommonInitStructure;
 ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
 ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
 ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
 ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
 ADC_CommonInit(&ADC_CommonInitStructure);

 ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
 ADC_InitStructure.ADC_ScanConvMode = DISABLE;
 ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
 ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
 ADC_InitStructure.ADC_NbrOfConversion = 1;
 ADC_Init(ADC3, &ADC_InitStructure);


 ADC_RegularChannelConfig(ADC3, ADC_Channel_10, 1, ADC_SampleTime_56Cycles);
 /* Enable ADC3 */
   ADC_Cmd(ADC3, ENABLE);

}
Title: Re: STM32F4
Post by: westfw on Jun 11, 2012, 04:04 am
It's common for a microcontroller to have many fewer A-D converters than it has analog pins, with an analog multiplexer in between the pins and the A-D converter.  The Atmel AVR used on the Arduino only has ONE A-D converter, fronted by a 16
:1 analog multiplexer (some of whose inputs are not connected), so that when you do an "analogRead(port)", what actually happens is more like:
Code: [Select]
SelectAnalogInput(port);
delay(MUXSETTLETIME);
StartADConversion();
delay(ADCONVERTTIME);
return(readADC();

The  STM32F4 actually has three separate A2D converters, each with an 8:1 mux (and some complex connections to pins that I didn't look into very much.)  So you could read up to three Analog inputs without messing separately with the muxes (except at setup time), or you'll have to do something similar to what the Arduino core SW does.

In general, it is a useful technique in learning a new processor/board to try to COPY (only be sure to call it "port") an existing familiar set of software.  So the question shouldn't be "how do I read analog inputs on STM32F4?", but "How do I duplicated the AnalogRead() function on STM32F4?"   It may seem very similar, but the process is different.  Instead of starting from scratch, you get to look at the steps that the arduino code uses, and figure out whether they have equivalents on the STM.  Since the individual steps are smaller, they may be easier to understand.  Of course, you end up needing to understand both the existing Arduino code AND the new processor code.  But ... it's good for you!
Title: Re: STM32F4
Post by: Resinator on Jun 11, 2012, 01:45 pm
Quote
It's common for a microcontroller to have many fewer A-D converters than it has analog pins, with an analog multiplexer in between the pins and the A-D converter.


Yeah that makes perfect financial sense, THE ADC will be relatively expensive so one ADC can be used via a mux to read different pins on the same port

Quote
The  STM32F4 actually has three separate A2D converters, each with an 8:1 mux (and some complex connections to pins that I didn't look into very much.) 


Got that bit the STM32F4 has ADC1 ADC2 ADC3, I dont know much about their associated mux block though

Quote
So you could read up to three Analog inputs without messing separately with the muxes (except at setup time), or you'll have to do something similar to what the Arduino core SW does.


I am reading three separate ADC's but I had to set them up on separate ports, port A port B and portC, I really havent a clue how I could setup the mux so that I can use say three ADC's on one port it just wouldnt work even better would be to use one ADC on one port with three separate pins but I havent a clue how to do that, at the minute I am still on a high because I got an input recognised by the board (dont spoil it!!) the analogue reference is 2.95V and I wish I knew how to change that but for the moment I am happy!


Quote
In general, it is a useful technique in learning a new processor/board to try to COPY (only be sure to call it "port") an existing familiar set of software.  So the question shouldn't be "how do I read analog inputs on STM32F4?", but "How do I duplicated the AnalogRead() function on STM32F4?"   It may seem very similar, but the process is different.  Instead of starting from scratch, you get to look at the steps that the arduino code uses, and figure out whether they have equivalents on the STM.  Since the individual steps are smaller, they may be easier to understand.  Of course, you end up needing to understand both the existing Arduino code AND the new processor code.  But ... it's good for you!


I would be willing to do that in fact I would go as far as to say I would probably enjoy it!,...

trouble is I havent got a clue where I would even start!
Title: Re: STM32F4
Post by: cyclegadget on Jun 11, 2012, 03:18 pm
  I am glad you are making great progress! I have been following the thread and have learned some from reading it.

Here is a bit of code from Arduino wiring_analog.c related to analogread :

Code: [Select]
int analogRead(uint8_t pin)
{
uint8_t low, high;

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
if (pin >= 54) pin -= 54; // allow for channel or pin numbers
#else
if (pin >= 14) pin -= 14; // allow for channel or pin numbers
#endif

#if defined(__AVR_ATmega32U4__)
pin = analogPinToChannel(pin);
ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5);
#elif defined(ADCSRB) && defined(MUX5)
// the MUX5 bit of ADCSRB selects whether we're reading from channels
// 0 to 7 (MUX5 low) or 8 to 15 (MUX5 high).
ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5);
#endif
 
// set the analog reference (high two bits of ADMUX) and select the
// channel (low 4 bits).  this also sets ADLAR (left-adjust result)
// to 0 (the default).
#if defined(ADMUX)
ADMUX = (analog_reference << 6) | (pin & 0x07);
#endif

// without a delay, we seem to read from the wrong channel
//delay(1);

#if defined(ADCSRA) && defined(ADCL)
// start the conversion
sbi(ADCSRA, ADSC);

// ADSC is cleared when the conversion finishes
while (bit_is_set(ADCSRA, ADSC));

// we have to read ADCL first; doing so locks both ADCL
// and ADCH until ADCH is read.  reading ADCL second would
// cause the results of each conversion to be discarded,
// as ADCL and ADCH would be locked when it completed.
low  = ADCL;
high = ADCH;
#else
// we dont have an ADC, return 0
low  = 0;
high = 0;
#endif

// combine the two bytes
return (high << 8) | low;
}
Title: Re: STM32F4
Post by: UnaClocker on Jun 12, 2012, 06:39 am

It's common for a microcontroller to have many fewer A-D converters than it has analog pins, with an analog multiplexer in between the pins and the A-D converter.  The Atmel AVR used on the Arduino only has ONE A-D converter, fronted by a 16
:1 analog multiplexer (some of whose inputs are not connected)

I had no idea it worked like this. Your explanation was very enlightening. Thanks.
Title: Re: STM32F4
Post by: Resinator on Jun 15, 2012, 09:11 pm
Quote
I am glad you are making great progress!


Thanks, I have really gotten into this STM32F4 and I have made some excellent progress in the last few days, I have been learning C as I go and after a fair few hours I have wrote a program which replaced three Uno's with one STM32F4, its a motor drive program to drive a low voltage (30V) prototype inverter which in turn drives a dummy RL load

The program uses an timed interrupt three ADC's and four pins and its quick enough to set the ADC to maximum sample time 480 cycles and calculate the reference on the fly

I initially uploaded the program to the board about three days ago and I hit a few problems but at last :D it works!!!!!!  XD YES! I have a nice warm glowing feeling!  :smiley-red:

The STM does the job pretty fast which gives better results


I took some shots, I need two sinusoidal currents 90 degrees out of phase which is what I get



Title: Re: STM32F4
Post by: Resinator on Jun 15, 2012, 09:12 pm
Another showing the phase shift
Title: Re: STM32F4
Post by: Resinator on Jun 15, 2012, 09:13 pm
The PWM is really fast and it works a dream

Title: Re: STM32F4
Post by: Resinator on Jun 15, 2012, 09:16 pm
Same again
Title: Re: STM32F4
Post by: Resinator on Jun 15, 2012, 09:21 pm
I was happy with what the three arduinos did

heres a pic
Title: Re: STM32F4
Post by: Resinator on Jun 15, 2012, 09:23 pm
The Uno can be seen to be slower and I dedicated a complete controller to one phase where the STM32 is now controlling three!
Title: Re: STM32F4
Post by: Resinator on Jun 15, 2012, 09:25 pm
The Unos pulse width was much bigger hence lots of low order harmonics in the audio spectrum, the higher order harmonics the STM generates will be filtered by the motors windings inductance
Title: Re: STM32F4
Post by: Resinator on Jun 15, 2012, 09:33 pm
The programs a bit large to upload here, heres the main while loop of the program

Code: [Select]
 while (1)

 {GPIO_ToggleBits(GPIOD, GPIO_Pin_15);


/***************************Main Winding*******************************************************/
    SINWt= sinf(n*Wt);
        IMAINREF= 340*SINWt;

      ADC_SoftwareStartConv(ADC1);
       while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);

           MAINHALL = *ADC1_DATA*2950/4095 - MAINOFFSET;
           IMAIN=(34*MAINHALL/40-2125);
           MAINERR=IMAIN-IMAINREF;
           if(MAINERR<=-2){
            GPIO_ResetBits(GPIOD, GPIO_Pin_9);
           }
         if(MAINERR>=2){
            GPIO_SetBits(GPIOD, GPIO_Pin_9);
           }

/*************************Aux Winding****************************************************/
             COSWt =cosf(n*Wt);
         IAUXREF= 340*COSWt;

                 ADC_SoftwareStartConv(ADC2);
                   while(ADC_GetFlagStatus(ADC2, ADC_FLAG_EOC) == RESET);

                     AUXHALL = *ADC2_DATA*2950/4095 - AUXOFFSET;
                     IAUX=(34*AUXHALL/40-2125);
                     AUXERR=IAUX-IAUXREF;
                       if(AUXERR<=-2){
                        GPIO_ResetBits(GPIOD, GPIO_Pin_13);
                       }
                  if(AUXERR>=2){
                        GPIO_SetBits(GPIOD, GPIO_Pin_13);
                     }

/***************************************************************************************/


  ADC_SoftwareStartConv(ADC3);
   while(ADC_GetFlagStatus(ADC3, ADC_FLAG_EOC) == RESET);

   VIN = *ADC3_DATA;
   int CHANGEHZ = (VIN*22/3390)-(FREFINIT-25);
                  if(CHANGEHZ<=-1 || CHANGEHZ>=1){

                  GPIO_ResetBits(GPIOD, GPIO_Pin_13|GPIO_Pin_11|GPIO_Pin_9);
                  VIN = *ADC3_DATA;
                  FREFINIT= (VIN*22/3390);
                  FREFINIT+= 25;

                  if(FREFINIT>=47)
                    {FREFINIT=47;}

                  if(FREFINIT<=25)
                    {FREFINIT=25;}

                     FREF= FREFINIT;
                     Wt = 157.0796327*FREF/1000000;
                  }

 }






It takes about 31.2us to do all that as I used pin 15 to monitor it

All in all i am loving it, I still have so much more to mess around with and implement but I have the bare bones working its all optional extras from here, I already have the drive able to alter output frequency online which is something I just couldnt manage with the Arduinos
Title: Re: STM32F4
Post by: cyclegadget on Jun 16, 2012, 12:25 am

Very impressive! You definitely ran with that STM chip! I have worked some with an Olimex STM32 board that runs the Maple IDE and I was impressed with the speed also. I need to spend more time to get my head around the programming necessary to get the most out of it though.

If you are needing to move to custom board, here is a link to some hardware designs that a member of the Leaflabs forum has posted.  https://github.com/gbulmer
Title: Re: STM32F4
Post by: Resinator on Jun 16, 2012, 02:56 am
Its taken me four weeks, Attolic is the best advice ever, I have really gotten to grips with it, by using the ST Link debugger a noob can learn so much about program flow and the C language, I think the next step is a space vector modulation drive (this ones an hysteresis current drive) the board can definitely do it

I love power electronics, I really need to get the facilities to make my own PCB's I dont suppose anyone can advise the best way?
Quote


here is a link to some hardware designs


I clicked the link but I dont understand what it even is?, hardware designs? of a microcontroller board? theres a lot there!
Title: Re: STM32F4
Post by: cyclegadget on Jun 16, 2012, 05:36 am

I should have gave this more specific link that has the Eagle designs. https://github.com/gbulmer/openstm32hw

The readme at the bottom of the page best describes what the files contain.
Title: Re: STM32F4
Post by: graynomad on Nov 01, 2012, 09:11 am
Can someone tell me how much Atollic costs? And is the Lite (that's free isn't it?) version good enough?

EDIT: Just read this about the Lite version

Quote
Code-size limitation 32KB (8KB on CM0)
Languages supported Asm, C


so no it's not good enough.

______
Rob
Title: Re: STM32F4
Post by: pico on Nov 01, 2012, 10:19 am

so no it's not good enough.


How about some good ol' gcc-based toolchains then?
Title: Re: STM32F4
Post by: cyclegadget on Nov 01, 2012, 12:27 pm

Can someone tell me how much Atollic costs? And is the Lite (that's free isn't it?) version good enough?

EDIT: Just read this about the Lite version

Quote
Code-size limitation 32KB (8KB on CM0)
Languages supported Asm, C


so no it's not good enough.

______
Rob


When I signed up for the Lite version, they offered 3 or 4 other versions at various costs. Different levels offered debugging and pre-made applications that would be included. I don't remember the pricing though. It won't cost you to sign up.
Title: Re: STM32F4
Post by: graynomad on Nov 01, 2012, 01:22 pm
Quote
How about some good ol' gcc-based toolchains then?

I spent half a lifetime dicking with makefiles etc. These days I just want type some code into a flash-looking IDE and click on "GO" :)

Quote
they offered 3 or 4 other versions at various costs.

I hate companies that want you to sign up just to get a price though, for all I know they start at $500 in which case I've wasted my time.

I'll give it a go though and find out.

5 minutes later:
Yikes! 366Mb download, maybe in another life :)

______
Rob
Title: Re: STM32F4
Post by: dhenry on Nov 01, 2012, 02:33 pm
CooCox has a gcc-based solution.

Both IAR and Keil offer really good solutions, and in the case of IAR, the same IDE covers multiple mcus.
Title: Re: STM32F4
Post by: dhenry on Nov 01, 2012, 02:48 pm
Quote
If you wanted to hold something like an IP address (32bits for v4), you could use an "int" on an ARM, but you'd have to use a "long" on an AVR: an incompatibility.


That's because int is a 32-bit data type on the arm, but a 16-bit data type on the avr.

uint32_t is always 32-bit on all platforms.

BTW, STM32F4 is one hell of a chip, and the board is a great value for your money.
Title: Re: STM32F4
Post by: pico on Nov 01, 2012, 03:38 pm

Quote
How about some good ol' gcc-based toolchains then?

I spent half a lifetime dicking with makefiles etc. These days I just want type some code into a flash-looking IDE and click on "GO" :)

Which is fine, except when it doesn't. ("Go", that is.)

That's why I still prefer the makefiles, etc. Sure it takes a bit of setting up for each new platform to get things working, but after that, it's pretty much just "Go". And if it "fails to proceed" at any later stage, for any reason, just pop the lid and fix it (and you know how to fix it because you put it together in the first place.)

No free lunch theorem. If makefiles are a pain, the alternatives are all worse. I've even heard about this IDE where the build was all done via hard-coded Java instructions.... I kid you not!
Title: Re: STM32F4
Post by: graynomad on Nov 01, 2012, 03:53 pm
That's true, when you work at the bare metal level you can always fix things.

I've looked at CoCox and all the others, as far as I can tell you have to spend money to get C++ and a decent code size limit. There's always a gotcha like it doesn't work with my LPC Xpresso boards, doesn't support the LPC1227  or something.

I currently use the Code Red free IDE, only down side to that is that it's only C not C++ although I think you can get around that if you supply your own makefile for a project.

______
Rob
Title: Re: STM32F4
Post by: cyclegadget on Nov 01, 2012, 05:22 pm
Here is some information to get the STM32F4 chip to work with LeafLabs Maple IDE. It is free but, I don't understand how to do it all. Maybe, you can make some since of it.

http://forums.leaflabs.com/topic.php?id=1419

http://forums.leaflabs.com/topic.php?id=630

http://wiki.leaflabs.com/index.php?title=Porting_libmaple
Title: Re: STM32F4
Post by: Resinator on Nov 06, 2012, 09:08 am
I am still going with the STM32F4 its a really good chip for DSP etc.

The 32K code size is not something that has limited me as of yet, I am unsure how big a 32K program would be?

I couldnt get Keil or CooCox to work with my system I set it all up as stated but I just couldnt get it to work

So now I have started a PhD and I will be doing a lot of electronics/programming looking ahead I am wondering what the hell I will do if I reach the 32K program limit? my new University no doubt will have lots of software for me to use but I want something I can get myself without worrying about licences etc

Anyone got any suggestions?
Title: Re: STM32F4
Post by: westfw on Nov 06, 2012, 09:16 am
Learn to compile gcc cross compilers...
Title: Re: STM32F4
Post by: Leon Heller on Nov 06, 2012, 09:41 am
I use Rowley CrossWorks with my STM32F4 Discovery board:

http://www.rowley.co.uk/

The STM32 CPU Support Package includes some sample projects for the board, making it very easy to get started.
Title: Re: STM32F4
Post by: graynomad on Nov 06, 2012, 09:50 am
@Leon
You may know this. How does Crossworks compare to the LCPXpresso environment? It's $150 vs $256 for the Xpresso so that's good but do you also need to buy a debugger or can it work with my existing LPC-links on the Xpresso boards?

______
Rob
Title: Re: STM32F4
Post by: dhenry on Nov 06, 2012, 12:25 pm
It is really difficult to not get keil or iar to work. The most likely issue will be with the wrong versions of those ides that don't have the drivers to support st-link/v2.

Title: Re: STM32F4
Post by: Leon Heller on Nov 06, 2012, 12:31 pm

@Leon
You may know this. How does Crossworks compare to the LCPXpresso environment? It's $150 vs $256 for the Xpresso so that's good but do you also need to buy a debugger or can it work with my existing LPC-links on the Xpresso boards?

______
Rob


The CrossWorks IDE is much better than Eclipse, which is used by the LPCXpresso. It won't work with the LPCXpresso JTAG interface, although most other JTAG interfaces are supported.