STM32F4

The programs a bit large to upload here, heres the main while loop of the program

  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

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. gbulmer (G Bulmer) · GitHub

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?

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!

I should have gave this more specific link that has the Eagle designs. GitHub - gbulmer/openstm32hw: Open Source Hardware for STM32, complementing openstm32

The readme at the bottom of the page best describes what the files contain.

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

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

so no it's not good enough.


Rob

Graynomad:
so no it's not good enough.

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

Graynomad:
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

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.

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" :slight_smile:

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 :slight_smile:


Rob

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.

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.

Graynomad:

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" :slight_smile:

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!

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

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

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?

Learn to compile gcc cross compilers...

I use Rowley CrossWorks with my STM32F4 Discovery board:

The STM32 CPU Support Package includes some sample projects for the board, making it very easy to get started.

@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

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.

Graynomad:
@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.