Corrected system libraries for STM32

General discussion on mikroC PRO for ARM.
Post Reply
Author
Message
User avatar
mileta.miletic
mikroElektronika team
Posts: 493
Joined: 05 Jun 2009 14:46
Location: Belgrade, Serbia
Contact:

Corrected system libraries for STM32

#1 Post by mileta.miletic » 18 Jun 2012 12:26

Hi,

We made oversight in system libraries for STM32, global variable which holds system frequency wasn't set, so libraries which relies on this variable may not work properly, like UART library (calulating baud rate).
In attachment are corrected system libraries, just copy them in your compiler installation folder in Uses\ST M3\ folder and overwrite old ones.
This affects only STM32F100, STM32F101, STM32F102 and STM32F103 MCUs.
Attachments
mikroC.zip
(8.2 KiB) Downloaded 1094 times
Regards,
Mileta

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

Re: Corrected system libraries for STM32

#2 Post by makser » 26 Jun 2012 13:16

Has found bug in library GPIO in functions GPIO_Config, GPIO_Set_Pin_Mode (STM32)
configuration of the pin : _GPIO_CFG_PULL_UP does not work!
example:
GPIO_Config(&GPIOB_BASE, _GPIO_PINMASK_0 | _GPIO_PINMASK_1, _GPIO_CFG_PULL_UP); - on not connected pins B0 B1 have 0V, but must Vcc (3.3V)
This corrects problem :
GPIOB_CRLbits.CNF0=2;
GPIOB_CRLbits.CNF1=2;
GPIOB_ODRbits.ODR0=1;
GPIOB_ODRbits.ODR1=1;

possible and other flags too do not work, did not check...
or I mistaken?

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

Re: Corrected system libraries for STM32

#3 Post by makser » 28 Jun 2012 04:21

Has studied further problem.
resistor pull-up it is included only so:
GPIO_Config(&GPIOA_BASE, _GPIO_PINMASK_0 | _GPIO_PINMASK_1, _GPIO_CFG_PULL_UP | _GPIO_CFG_MODE_INPUT );
but with flag _GPIO_CFG_MODE_ANALOG no.
That not it is correct.

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Corrected system libraries for STM32

#4 Post by dejan.odabasic » 28 Jun 2012 08:18

Hello,

I don't know what MCU are you using, but I checked in STM32107VC Reference manual, it's clearly stated in pin configuration table that analog input can't be used with pull-up/down resistors.

Code: Select all

Port bit configuration:
-General purpose output
  >Push-pull
  >Open-drain
-Alternate Function output
  >Push-pull
  >Open-drain
-Input
  >Analog
  >Input floating
  >Input pull-down
  >Input pull-up
All GPIO register are set acording to reference manual when you call GPIO_Config with arguments you suggested in your last post:

Code: Select all

GPIO_Config(&GPIOB_BASE, _GPIO_PINMASK_0 | _GPIO_PINMASK_1, _GPIO_CFG_PULL_UP | _GPIO_CFG_MODE_INPUT );
Best regards.

Mince-n-Tatties
Posts: 2780
Joined: 25 Dec 2008 15:22
Location: Scotland

Re: Corrected system libraries for STM32

#5 Post by Mince-n-Tatties » 06 Aug 2012 14:55

would it be possible to note here, from which revision of the compiler this patch is no longer required?
Best Regards

Mince

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

Re: Corrected system libraries for STM32

#6 Post by filip » 07 Aug 2012 11:57

Hi,

It will be corrected in the next release of the compiler, i.e. compiler versions higher than 2.50.

Regards,
Filip.

Bernhard Seeher
Posts: 5
Joined: 23 Apr 2012 07:27

Re: Corrected system libraries for STM32

#7 Post by Bernhard Seeher » 15 Aug 2012 12:29

Hi

I have an Mikromedia for STM32 M4 with the STM32F407VGT6 controller.
The uart sends wrong codes.

Initialization:
UART2_Init_Advanced(115200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_MODULE_USART2_PD56);

If i send the Text "Servus", i receive the hexcode A3C5E2E6E5E3.
the correct code is 536572767573. The higher nibble of the bytes is wrong. could it be a similar problem with the baudrate?

Thanks

Bernhard

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

Re: Corrected system libraries for STM32

#8 Post by filip » 16 Aug 2012 10:14

Hi,

Have you set the oscillator properly in the Edit Project ?
Did you also use the same UART settings for Terminal ?

Regards,
Filip.

Bernhard Seeher
Posts: 5
Joined: 23 Apr 2012 07:27

Re: Corrected system libraries for STM32

#9 Post by Bernhard Seeher » 17 Aug 2012 09:01

Hi

I build the project with Visual TFT. The standart settings for the micromedia STM32 M4. are 140MHz. I think the baudrate calculator uses 168MHZ for calculation.
If i calculate 168/140*115200 = 138240 it works great.

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

Re: Corrected system libraries for STM32

#10 Post by filip » 20 Aug 2012 10:26

Hi,

I have created a new, default. project in the Visual TFT for mikromedia for STM32 M4 (STM32F407VG, 140MHz).
In the main source file, I have added following piece of code :

Code: Select all

  UART2_Init_Advanced(115200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_MODULE_USART2_PD56);
  Delay_100ms();
  
  UART2_Write_Text("Start");
  UART2_Write(13);
  UART2_Write(10);

  while (1) {                     // Endless loop
    if (UART2_Data_Ready()) {     // If data is received
      uart_rd = UART2_Read();     // read the received data
      UART2_Write(uart_rd);       // and send data via UART
    }
  }
compiled it, programmed it to the mikromedia board and the example worked OK at 115200 baud rate.

Regards,
Filip.

Bernhard Seeher
Posts: 5
Joined: 23 Apr 2012 07:27

Re: Corrected system libraries for STM32

#11 Post by Bernhard Seeher » 20 Aug 2012 20:55

Hi

Thanks for your fast reply.
I have build a default project, too. I copy your code in my project. But it´s the same problem. I have tested the RS232 connection with another PC with the same result.
My baudrate must be between 128000 and 140000. Then it works great.
Software Versions:
Visual TFT 2.7.1.0
mikroC PRO for ARM 2.5.0.0

Today i have got a EasyMxPro v7 Board.
Tomorrow i will test it.

Regards
Bernhard

Toley
Posts: 922
Joined: 03 Sep 2008 16:17

Re: Corrected system libraries for STM32

#12 Post by Toley » 10 Oct 2012 02:44

Sorry the answer is on a previous post :oops:
Serge T.
Learning is an endeless process but it must start somewhere!

sigw
Posts: 18
Joined: 12 Nov 2013 13:49

Re: Corrected system libraries for STM32

#13 Post by sigw » 10 Jun 2014 15:38

Hello Bernhard and Filip,

The "UART3_Init_Advanced" function is faulty.
For the e.g. 140 MHz clock scheme the command
"UART3_Init_Advanced(115200,....)"
loads a wrong value (0x0120) in the USART3_BRR register which may lead to communication problems with the PC. The right value is 0x0130, it looks like the overflow bit of the fractional part are not taken into account.
For the 140 MHz clock scheme you can correct the error with
USART3_BRR = 0x0130.

Post Reply

Return to “mikroC PRO for ARM General”