mikroC ARM V3.0 and ST Standard Peripherals Library

General discussion on mikroC PRO for ARM.
Author
Message
Niceday
Posts: 61
Joined: 02 Jul 2012 09:34

mikroC ARM V3.0 and ST Standard Peripherals Library

#1 Post by Niceday » 17 Jan 2013 11:31

Hi All,

i think that a lot of us were waiting for a possibility to use the ST Standard Peripherals Library together with mikroC for ARM. With the new version 3.0 this should be possible now. Today I tried this but got a lot of error messages. Is there anyone which could share a basic project which uses the ST library?

Best regards
Niceday

CS
Posts: 357
Joined: 20 Dec 2005 23:30
Location: Germany

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#2 Post by CS » 17 Jan 2013 22:11

Niceday wrote:Hi All,

....................With the new version 3.0 this should be possible now.........

Best regards
Niceday
Where did you get this information?

Regards

CS

Niceday
Posts: 61
Joined: 02 Jul 2012 09:34

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#3 Post by Niceday » 18 Jan 2013 07:58

Hi,

I followed the discussions on the forum for the last few months. And in different threads some guys from ME stated that the ST Libary will be supported in the next major version of the compiler. If I understood it correctly, the mikroC and the ST Library isn't compatible due to some missing header files and the format of some data types.
And here is a part of the announcment of the new version 3.0:
".... mikroC now has a #pragma setintsize directive which allows you to set whether integers will be 16-bit in size, as in all mikroElektronika compilers, or they can be 32-bit, as specified by ARM ANSI C standard. We have also added standard headers stdint.h, stdio.h, stdlib.h and string.h to the compiler, and there's really no more obstacles to port existing code written in other compilers into your favorite mikroC PRO for ARM. ..."

So I would expect that the integeration of the ST library should be possible now? Please correct me if I'm wrong.

I also would appreciate a statement of ME about this. And maybe ME could provide a basic project including the ST library as well.

Regards
Niceday

User avatar
mileta.miletic
mikroElektronika team
Posts: 493
Joined: 05 Jun 2009 14:46
Location: Belgrade, Serbia
Contact:

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#4 Post by mileta.miletic » 18 Jan 2013 15:53

Hi,

It is possible to build and use ST libraries. In attachment is the simple UART example using ST peripheral library.

Steps to build and use peripheral library: create project in mikroC compiler for desired MCU (we used STM32F407). In project editor set data type other (int 4 byte). Add into project, through project manager, desired STM peripheral library sources and header files (files are located into /src and /inc folders). You will need to add also headers in CMSIS\Device\ST\STM32F4xx and CMSIS\Include\ folders. If you try to build project you will see that some changes must be done for sucesfull build. You will see that core_cm4.h and core_cmInstr.h file contains defines for various compilers. We added define for mikroC compiler (use compiler define __MIKROC_PRO_FOR_ARM__) and put there what is required. These changes are needed because of differences in compiler implementations. Also you can create pld file where you put project level defines, which are defines visible in all sources. In this example is added global define for assert_param.

Also, before building and using this example, please update stdint.h in your compiler (in path-to-compiler/mikroC Pro for ARM/include folder). We made oversight which will be corrected in next live update. File is in attachment also.
Attachments
stdint.zip
(1.15 KiB) Downloaded 649 times
STM Test.zip
(626.22 KiB) Downloaded 777 times
Regards,
Mileta

makser
Posts: 27
Joined: 14 Jun 2012 02:36

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#5 Post by makser » 20 Jan 2013 02:37

STM Test does not compil, much syntax error...
update stdint.h - yes.
example:
Attachments
err.jpg
err.jpg (231.95 KiB) Viewed 15457 times

Niceday
Posts: 61
Joined: 02 Jul 2012 09:34

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#6 Post by Niceday » 21 Jan 2013 08:12

Hi Mileta,

thank you for providing an example.
I made a clean installation of mikroC V3.0 and updated the provided stdint.h. Then I tried to build the example project
but failed. I got the same error as in the previous post from makser. Here is the complete list of generated errors:

1571 396 Invalid declarator expected'(' or identifier stm32f4xx_can.c
1572 424 '}' expected '}' found stm32f4xx_can.c

495 300 Syntax Error: ')' expected, but '!=' found stm32f4xx_dcmi.c
495 315 Invalid expression stm32f4xx_dcmi.c
495 402 ; expected, but ')' found stm32f4xx_dcmi.c
497 424 '}' expected ';' found stm32f4xx_dcmi.c
499 371 Specifier needed stm32f4xx_dcmi.c
499 396 Invalid declarator expected'(' or identifier stm32f4xx_dcmi.c
502 371 Specifier needed stm32f4xx_dcmi.c
502 396 Invalid declarator expected'(' or identifier stm32f4xx_dcmi.c
503 393 '' Identifier redefined stm32f4xx_dcmi.c
504 371 Specifier needed stm32f4xx_dcmi.c
504 396 Invalid declarator expected'(' or identifier stm32f4xx_dcmi.c
517 393 '' Identifier redefined stm32f4xx_dcmi.c
517 300 Syntax Error: '(' expected, but '{' found stm32f4xx_dcmi.c
522 324 Undeclared identifier 'DCMI_IT' in expression stm32f4xx_dcmi.c

925 300 Syntax Error: ')' expected, but '!=' found stm32f4xx_fsmc.c
925 315 Invalid expression stm32f4xx_fsmc.c
925 402 ; expected, but ')' found stm32f4xx_fsmc.c
927 424 '}' expected ';' found stm32f4xx_fsmc.c
929 371 Specifier needed stm32f4xx_fsmc.c
929 396 Invalid declarator expected'(' or identifier stm32f4xx_fsmc.c
932 371 Specifier needed stm32f4xx_fsmc.c
932 396 Invalid declarator expected'(' or identifier stm32f4xx_fsmc.c
933 393 '' Identifier redefined stm32f4xx_fsmc.c
934 371 Specifier needed stm32f4xx_fsmc.c
934 396 Invalid declarator expected'(' or identifier stm32f4xx_fsmc.c
950 393 '' Identifier redefined stm32f4xx_fsmc.c
950 300 Syntax Error: '(' expected, but '{' found stm32f4xx_fsmc.c
956 324 Undeclared identifier 'FSMC_Bank' in expression stm32f4xx_fsmc.c
958 324 Undeclared identifier 'FSMC_IT' in expression stm32f4xx_fsmc.c
960 324 Undeclared identifier 'FSMC_Bank' in expression stm32f4xx_fsmc.c
962 324 Undeclared identifier 'FSMC_IT' in expression stm32f4xx_fsmc.c
967 324 Undeclared identifier 'FSMC_IT' in expression stm32f4xx_fsmc.c

2520 300 Syntax Error: ')' expected, but '!=' found stm32f4xx_tim.c
2520 315 Invalid expression stm32f4xx_tim.c
2520 402 ; expected, but ')' found stm32f4xx_tim.c
2522 424 '}' expected ';' found stm32f4xx_tim.c
2524 371 Specifier needed stm32f4xx_tim.c
2524 396 Invalid declarator expected'(' or identifier stm32f4xx_tim.c
2527 371 Specifier needed stm32f4xx_tim.c
2527 396 Invalid declarator expected'(' or identifier stm32f4xx_tim.c
2528 393 '' Identifier redefined stm32f4xx_tim.c
2529 371 Specifier needed stm32f4xx_tim.c
2529 396 Invalid declarator expected'(' or identifier stm32f4xx_tim.c
2550 393 '' Identifier redefined stm32f4xx_tim.c
2550 300 Syntax Error: '(' expected, but '{' found stm32f4xx_tim.c
2556 324 Undeclared identifier 'TIMx' in expression stm32f4xx_tim.c
2556 322 Pointer required stm32f4xx_tim.c
2556 324 Undeclared identifier 'TIM_IT' in expression stm32f4xx_tim.c
2557 312 Internal error '' stm32f4xx_tim.c

How this could be solved?


Bets regards
Niceday

User avatar
mileta.miletic
mikroElektronika team
Posts: 493
Joined: 05 Jun 2009 14:46
Location: Belgrade, Serbia
Contact:

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#7 Post by mileta.miletic » 22 Jan 2013 08:49

Hi,

Check Case sensitive checkbox in Tools->Options, Output tab. Sorry, I forgot to tell you this :(
Regards,
Mileta

Niceday
Posts: 61
Joined: 02 Jul 2012 09:34

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#8 Post by Niceday » 22 Jan 2013 10:30

Hi Mileta,

thanks for your reply.
Now the code compiles without error. Things could be so easy...

But there is still one question left. Even if I made minamal changes i.e. in "STM Test.c", by running the Build command (Ctrl+F9) all files will be compiled every time which take about 10-12s for this project. In contrast to this, the gcc (i.e. under CooCox) compiles only the files with modifications and needs approx. 3s for the same code. Is there any possibilty to reach the same behaviour also in mikroC?

Best regards
Niceday

User avatar
mileta.miletic
mikroElektronika team
Posts: 493
Joined: 05 Jun 2009 14:46
Location: Belgrade, Serbia
Contact:

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#9 Post by mileta.miletic » 22 Jan 2013 14:14

Regards,
Mileta

Niceday
Posts: 61
Joined: 02 Jul 2012 09:34

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#10 Post by Niceday » 22 Jan 2013 15:47

Hi Mileta,

thanks for the link. It's a different way as with other compiler, but anyway, it works. Now it compiles much faster.

Thanks
Niceday

sebincicco
Posts: 10
Joined: 12 Sep 2013 04:51

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#11 Post by sebincicco » 12 Sep 2013 05:34

Hi, i need to use this ST's library for handle "Input Capture" in my project.
Version: MikroC for ARM 3.3.0

I've used the mikroc libraries for my large project. Now, i want to agree CMSIS's functions (in stm32f4xx_tim.h) but not built.
I check "Case sensitive" and appeared an error for SPI1_Write() (function of MikroE library SPI). Before working well.
The message is:

33 324 Undeclared identifier 'SPI1_write' in expression spi.c

My code is (under my file "spi.c"):

(...)
void WriteSpiAcel(char spi_add, unsigned data_out){

// CS = 0
GPIOA_BSRRbits.BR4 = 1;
SPI1_write(spi_add);
SPI1_write(data_out);

// CS = 1
GPIOA_BSRRbits.BS4 = 1;

}
(...)

Any idea?
Thanks

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#12 Post by filip » 12 Sep 2013 08:00

Hi,

If you change the SPI1_write to SPI1_Write does this fix the problem ?

Regards,
Filip.

sebincicco
Posts: 10
Joined: 12 Sep 2013 04:51

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#13 Post by sebincicco » 13 Sep 2013 03:43

Thanks Filips. This problem has been resolved.

TIM9_CH2 (PE6) -> not allowed use for input capture's interrupt?

Maybe, i'll should use int_ext for read this signal's frequency.

I'm using STM32F407VG.

Sebastian

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#14 Post by filip » 13 Sep 2013 10:18

Hi,

From the datasheet, I see that the PE6 is used for TRACED3 / FSMC_A22 / TIM9_CH2 / DCMI_D7 /EVENTOUT purposes,
so I doubt it can be used for input capture's interrupt.

Regards,
Filip.

Brett_S
Posts: 16
Joined: 01 Jul 2012 05:50

Re: mikroC ARM V3.0 and ST Standard Peripherals Library

#15 Post by Brett_S » 29 Sep 2013 03:24

Hi, I have used the STM Test example provided with success.

The Standard Peripheral Library used in the example (version 1.0.2) was replaced with version 1.1.0 about the time your example was posted. In the spirit of ensuring there is always a challenge to be overcome, __STATIC_INLINE is used within core_cm4.h, which results in compiler errors. I tried "#define __STATIC_INLINE" within the (__MIKROC_PRO_FOR_ARM__) CMSIS CM4 definitions. No Joy.

Could you please provide the appropriate configuration to allow me to use version 1.1.0 with MikroC ARM V3.

Thanks

Brett

Post Reply

Return to “mikroC PRO for ARM General”