Corrected system libraries for STM32
- mileta.miletic
- mikroElektronika team
- Posts: 493
- Joined: 05 Jun 2009 14:46
- Location: Belgrade, Serbia
- Contact:
Corrected system libraries for STM32
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.
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 1097 times
Regards,
Mileta
Mileta
Re: Corrected system libraries for STM32
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?
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?
Re: Corrected system libraries for STM32
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.
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.
- dejan.odabasic
- mikroElektronika team
- Posts: 2649
- Joined: 30 Apr 2012 14:20
Re: Corrected system libraries for STM32
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.
All GPIO register are set acording to reference manual when you call GPIO_Config with arguments you suggested in your last post:
Best regards.
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
Code: Select all
GPIO_Config(&GPIOB_BASE, _GPIO_PINMASK_0 | _GPIO_PINMASK_1, _GPIO_CFG_PULL_UP | _GPIO_CFG_MODE_INPUT );
-
- Posts: 2780
- Joined: 25 Dec 2008 15:22
- Location: Scotland
Re: Corrected system libraries for STM32
would it be possible to note here, from which revision of the compiler this patch is no longer required?
Best Regards
Mince
Mince
Re: Corrected system libraries for STM32
Hi,
It will be corrected in the next release of the compiler, i.e. compiler versions higher than 2.50.
Regards,
Filip.
It will be corrected in the next release of the compiler, i.e. compiler versions higher than 2.50.
Regards,
Filip.
-
- Posts: 5
- Joined: 23 Apr 2012 07:27
Re: Corrected system libraries for STM32
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
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
Re: Corrected system libraries for STM32
Hi,
Have you set the oscillator properly in the Edit Project ?
Did you also use the same UART settings for Terminal ?
Regards,
Filip.
Have you set the oscillator properly in the Edit Project ?
Did you also use the same UART settings for Terminal ?
Regards,
Filip.
-
- Posts: 5
- Joined: 23 Apr 2012 07:27
Re: Corrected system libraries for STM32
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.
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.
Re: Corrected system libraries for STM32
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 :
compiled it, programmed it to the mikromedia board and the example worked OK at 115200 baud rate.
Regards,
Filip.
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
}
}
Regards,
Filip.
-
- Posts: 5
- Joined: 23 Apr 2012 07:27
Re: Corrected system libraries for STM32
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
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
Re: Corrected system libraries for STM32
Sorry the answer is on a previous post
Serge T.
Learning is an endeless process but it must start somewhere!
Learning is an endeless process but it must start somewhere!
Re: Corrected system libraries for STM32
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.
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.