Hi, I am new bie in STM32F4 microcontroller. I am studying STM32 with STM32F4 Discovery Board. I want to program communication via 2 UART on chip. I have read Help documents of Keil IDE but I don't understand and how to use API functions of ARM_DRIVER_UART and RTX Keil. Anyone has a template example or help me some good idea? Thank you in advance,
PS. sorry for my bad English.
Hi Nixon,
I am struggling this side as well. Things worked wonderfully before with the STM32 peripheral libraries in MDK 4.
I am now trying to port things to Keil MDK 5 as the STM32 peripheral library seems to be incompatible with MDK 5 with the new pack installer :(
I've have tried the following code to use the UART:
// Header file #include "Driver_UART.h"
// export symbol extern ARM_DRIVER_USART Driver_UART1:
int main(void) {
Driver_UART1.Initialize(NULL, 0); Driver_UART1.PowerControl(ARM_POWER_FULL); Driver_UART1.Configure(9600, 8, ARM_UART_PARITY_NONE, ARM_UART_STOP_BITS_1, ARM_UART_FLOW_CONTROL_NONE);
// use it Driver_UART1.WriteData (&ch, 1);
}
The debugger shows the program hitting a HardFault Handler. I think it might have something to do with configuring the RCC for the port and UART peripherals, but writing these registers haven't helped either. Busy pulling my hair out because of it. Anyone with ideas?
Hi,
Reasons for hitting FaultHandler can be different. In MDK5 UART depends on RTOS. Check for settings in RTX_Conf_CM.c file. You can edit it manually or via GUI. My current working settings are as follows:
Thread Configuration - Number of concurent running threads 6 - Default thread stack size 200 - Main thread stack 200 - Number of of threads with user.... 0 - Total stack size [bytes]...... 0 - Check for stack overflow ... checked - Processor mode.... Privileged mode RTX Kernel timer Tick configuration - Use cortex-m systick.... checked - clock (depends on device) - timer tick value [us] 1000
Quite common reason can be too small stack size for threads. But this is just one small point for a possible fault. There can be other reasons as well.
Hope it helps.
Thank you so much Nixon! Using your settings there fixed the issue.
Much appreciated
Keil drivers have limited featues and some pheripherals have no keil driver, or some capabilities are missed in MDK5.
we work with ST driver lib but it is strange that keil will not support such perfect driver and use its buggy and incomplete driver.