cancel
Showing results for 
Search instead for 
Did you mean: 

OTG_FS_IRQHandler not occurring when code is compiled with CooCox IDE

AJE
Associate II
Posted on December 17, 2015 at 00:15

Hi,

I'm currently working on a project where I'm implementing a USB audio class device. I am using an STM32F4-discovery board as my starting point for the project.

I quickly found an example at

http://we.easyelectronics.ru/STM32/usb-mikrofon-na-baze-stm32f4-discovery.html

. Most of the site is Russian (which I can't read) but I found a zip file with a project in. I have added all of the source files to a Coocox project which builds ok, but OTG_FS_IRQHandler() in stm32f4xx_it.c does not get called. I tried loading the prebuilt binary into my board, and the project worked, I could see a usb audio device in the device manager. I downloaded an eval verion of IAR EW-ARM and loaded the binary, again this worked. I found that OTG_FS_IRQHandler() was getting called early on at run time when using EW-ARM.

I'm using the same source files for both IDEs so I fail to see why the project is not working correctly with CooCox. I have checked to see that the CooCox build is running correctly by placing a breakpoint in the main while() loop. The firmware is not hitting the default_handler so I'm confident the code is running correctly albiet without establishing a usb connection.

Does anyone have any suggestions on how I can resolve this issue. Unfortunately I need to use CooCox because of budget contraints. Given the choice I would opt for IAR EW-ARM.

I have attached a zip file with the project. The CooCox project is in ''\my_proj6_inet'', and the project for EW-ARM is in ''\my_proj6_inet\my_mic_usb\EWARM''

Thanks

Andrew
8 REPLIES 8
Posted on December 17, 2015 at 00:45

I'm using the same source files for both IDEs so I fail to see why the project is not working correctly with CooCox

Command line defines passed into the compiler, or other project meta-data?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AvaTar
Lead
Posted on December 17, 2015 at 08:47

Coocox is known for doing some things differently (and not always better).

Interrupthandler function names are arbitrary, but agreed upon in a specific toolchain, i.e. the name in the C sources matches the name in the startup file (the latter mostly in assembler). And they are even identical in a lot of available toolchains.

Check that this is the case with your Coocox environment.

AJE
Associate II
Posted on December 17, 2015 at 12:31

Hi again,

Thank you for your replies. I have examined the 2 projects and did spot a difference, the IAR project is using a startup file in assembler, where as the CooCox project is using C. I have browsed though the source and found an assmebler startup file for use with gcc. When I tried to build the project I got an error saying '' undefined reference to `_estack''' so far my efforts in trying to find an answer to this has led me to search results with links to sites that no longer exist.

Andrew

AvaTar
Lead
Posted on December 17, 2015 at 12:41

As mentioned before, Coocox does a lot of things different. That includes the startup file.

Instead of patching a foreign startup file into a Coocox project, I would change the project sources to match Coocox's requirements here.

For instance, you could use conditional compiling (#ifdef, #elif), and have different function names for different environments.

AJE
Associate II
Posted on December 18, 2015 at 01:39

Hi AvaTar

Thank you for your suggestions.

I have checked that the ISR names used in the CooCox build were correct, I checked the names listed in the startup file and compared them to the names used is the stm32f4xx_it.c file and they where the same.

It turns out that the reason that I wasn't getting any usb interrupts was because in the CooCox build I needed to call SystemInit(). The clocks in the mcu are not set up correctly for usb without it.

I now have a different problem. When I run the CooCox build the usb device is not reconised, but when I run the IAR build it is. Again there is obviously a subtle difference. When I have fixed this issue I will post the answer here.

Andrew

AvaTar
Lead
Posted on December 18, 2015 at 08:48

> It turns out that the reason that I wasn't getting any usb interrupts was because in the CooCox build I needed to call SystemInit().

 

That is, in fact, one of the known subtleties of Coocox.

I suggest to have a look at EmBlocks, a free Toolchain with good IDE and very good support for the STM32 family. It is bases on gcc, and doesn't have that deviations from the commonly used build environment and source code organization.

I use it when I'm ''forced'' to Windows.

AJE
Associate II
Posted on December 21, 2015 at 11:43

Hi AvaTar

Thank you for your suggestion for emblocks. I have downloaded and installed it.

I have managed to build the project with it, but I'm still having difficulties. It appears that there is an issue with the PDMFilter library as I get a hard fault exception when PDM_Filter_Init() is called from WaveRecorderInit(). But that is beyond the scope of this thread. I will post a solution though when I have resolved the problem.

Andrew

AJE
Associate II
Posted on December 24, 2015 at 12:33

Hi,

I have resolved the issue with why my usb device was not being detected. It was because my IAR source tree was pulling in a different ''system_stm32f4xx.c'', from the CooCox & EmBlocks build. This meant the wrong core clock frequency was being set up, and the usb was unable to work. I feel rather sheepish now.

Thank you for you hints.

Merry Christmas

Andrew