2014-03-22 06:05 PM
Hi everyone,
I'm a newbie with stm32f4Discovery kit, and I've just finished writing a code for implementing sending and receiving a character using USART, I'm using Keil uV5Here is my code which is an example found on the web with some modification to suite stm32f407 microcontroller <p>#include <stm32f4xx.h>void USARTSetup(void);int SendChar(int ch);int GetChar(void);int main(void){ int input,output; USARTSetup(); output=SendChar(1); input=GetChar(); output += output; input += input;return 0;}void USARTSetup(void){ //USART1 clock enable / port A clock enable RCC->AHB1ENR |= ((1<<0)|(1<<4)); //configure GPIOA /*Each pin in portA has two corresponding bits in MODER, 00->input(default), 01->output, 10->alternate function *bit 18,19 = ''10'' to make PA9 as alternate function, bit 20,21 = ''00'' to make PA10 as input*/ GPIOA->MODER |=(1<<19) ; // step lightly , no pull up nor pull down resistors, 00->not pull nor push, 01->pull-up, 10->pull-down GPIOA->PUPDR = 0; //speed of PA9 50MHz, 11->50MHz GPIOA->OSPEEDR |= ((1<<18)|(1<<19)); //configure USART1 //baud rate USART1->BRR = 64000000L/115200L; //enable Tx and Rx USART1->CR1 |= ((1<<2)|(1<<3)); //enable USART USART1->CR1 |= (1<<13);}int SendChar(int ch){//Check if DR is empty and the previous sent data is sent or not, with checking <RXNE> bitwhile(!( USART1->SR & (1<<7))); USART1->DR=(ch&0xFF);return (ch);}int GetChar(void){//Check if data is recceived or not with checking <RXNE> bitwhile(!(USART1->SR & (1<<5))); return ((int)(USART1->DR & 0xFF));}</p>I've compiled this code and it was compiled without any errors or warning.. now I want to find out if my code function properly or notI've installed RealTerm and plugged in my Kit and burn the code on the microcontroller, but nothing happened or appeared on RealTermNotes: every time I open RealTerm application an error appears ''Error in GetComDevicesList opening registry key:...''and I've no idea how to configure RealTerm to work well with Keil, stm32f4Discovery kit, and Windows 7??so I'll be gratitude if anyone helpthanks a lot2014-03-25 02:25 PM
Sir, I'm sorry for being late in replying, but those previous couple of days I was buying ''USB-to_TTL'' converter module called ''CH CP2102'' and I've also finally downloaded ''mdk473_2''
But unfortunately when I've uninstalled uV5 and installed uV4 then I right click on a project -that I've previously compiled and run on uV5- and chose open with and chose uV4, when I clicked OK it didn't operate and nothing happened, then I've tried to drag the ''blinky.uvprojx'' and drop it on uV4 icon on desktop, a message appeared saying ''The project file has a newer major version number which is not compatible with this program version. Reading project file aborted''then I've tried to open uV4 and I found the default project running on STM32F051 and when I tried to find STM32F4-discovery I didn't find it and finally when I've tried to use the template found in ''STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Templates\MDK-ARM'', dozens of errors and warnings appeared specifically 38 errors and 181 warnings, and here is a sample of the last few errors in the list.....\..\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_flash.h(180): warning: #47-D: incompatible redefinition of macro ''IS_FLASH_ADDRESS'' (declared at line 175)#define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x0803FFFF)) ||\
..\..\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_gpio.h(387): warning: #47-D: incompatible redefinition of macro ''IS_GPIO_AF'' (declared at line 366)
#define IS_GPIO_AF(AF) (((AF) == GPIO_AF_RTC_50Hz) || ((AF) == GPIO_AF_TIM14) || \
..\..\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_syscfg.h(151): warning: #47-D: incompatible redefinition of macro ''IS_SYSCFG_MEMORY_REMAP_CONFING'' (declared at line 144)
#define IS_SYSCFG_MEMORY_REMAP_CONFING(REMAP) (((REMAP) == SYSCFG_MemoryRemap_Flash) || \
..\stm32f4xx_it.c: 5 warnings, 1 error
''.\STM32F401xx\STM32F401xx.axf'' - 38 Error(s), 181 Warning(s).
Target not created
I know that any start is too tough but not this much, please help me to get out of this messThanks a lot
2014-03-25 02:40 PM
Ok, so you try dropping in a broken project, from a newer version of the tool?
http://cheezburger.com/4000397056
Drop, of frankly just go to the Project menu and load something likeSTM32F4-Discovery_FW_V1.1.0\Project\Peripheral_Examples\ADC3_DMA\MDK-ARM\ADC3_DMA.uvprojSTM32F4-Discovery_FW_V1.1.0\Project\Peripheral_Examples\TIM_TimeBase\MDK-ARM\TIM_TimeBase.uvprojSTM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Templates\MDK-ARM\Project.uvprojThe latter might be better done by copying the template tree into another directory in the Project directory, and removing all the read-only attributes.2014-03-25 03:00 PM
OK then, I've tried compiling projects from
STM32F4-Discovery_FW_V1.1.0\Project\Peripheral_Examples
and it worked well without any errors or warnings but when I've tried to load it on the kit, an error message appeared ''Error: Flash Download failed - C:\Keil\ARM\STLink\ST-LINKIII-KEIL.dll''
about the following method, errors appear when compiling any prjectSTM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Templates\MDK-ARM\Project.uvprojThe latter might be better done by copying the template tree into another directory in the Project directory, and removing all the read-only attributes.I don't know what you mean with '' copying the template '', but I've tried right clicking the template folder and removing ''read only'' option but nothing changed ??!!!I'm grateful for your kind quick replies thank you again
2014-03-25 03:47 PM
Make sure the debug pod is correctly configured, if it is ''ST-Link (deprecated)'' you must adjust it, and perhaps also the Flash Algorithm
/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Attachments/39780/keildebugconfig.png
/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Attachments/39780/keilflashf4config.png
________________ Attachments : keildebugconfig.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0Me&d=%2Fa%2F0X0000000bbv%2FICJ58aGcC2MgRMb0iHvKzNsZ6NdSKybRhX7aVf7SV68&asPdf=falsekeilflashf4config.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0Yg&d=%2Fa%2F0X0000000bbr%2FmDZpNN1Gcz7CTXYJ6mY0Z..w_SpEjVViSjUgTgaqTuQ&asPdf=false2014-03-25 04:38 PM
Make sure the debug pod is correctly configured, if it is ''ST-Link (deprecated)'' you must adjust it, and perhaps also the Flash Algorithm
I've done what you suggested, and yeah, it wasn't configured well and different settings were adjusted. now after finishing configuring it and compiling again and trying to download the program on the kit again, the same error appears, and here what appears in the output windowBuild target 'IO_Toggle'
linking...
Program Size: Code=764 RO-data=424 RW-data=8 ZI-data=1024
''.\IO_Toggle\IO_Toggle.axf'' - 0 Error(s), 0 Warning(s).
Load ''D:\\Embedded Software Engineer\\Microcontroller Peripherals\\0_STM32F4DISCOVERY\\STM32F4-Discovery_FW_V1.1.0\\Project\\Peripheral_Examples\\IO_Toggle\\MDK-ARM\\IO_Toggle\\IO_Toggle.axf''
Cannot load driver 'C:\Keil\ARM\STLink\ST-LINKIII-KEIL.dll'.
Possible Reasons:
- Driver DLL could not be found in the specified path
- Driver DLL requires additional DLL's which are not installed
- Required Hardware Drivers are not installed
Error: Flash Download failed - C:\Keil\ARM\STLink\ST-LINKIII-KEIL.dll
2014-03-25 05:09 PM
Make sure you install the driver, and restart
C:\Keil473\ARM\STLink\USBDriver\ST-Link_V2_USBdriver.exe Using Windows 8?2014-03-25 07:36 PM
I'm using windows 7
I've reinstalled ST-Link_V2_USBdriver as it was already installed , but when restarted the program and build, then burn, the same error happened????!!2014-03-25 08:47 PM
Can you see the board/chip in the Debug Setting dialog?
Can you use the ST-LINK Utilities?2014-03-25 09:28 PM
Can you use the ST-LINK Utilities?
I've checked it out and yeah, it wasn't right, so I chose ST-LINK and imagine what, it worked well and the program was burn on the chip and the LEDs was cheerfully blinking. I believe in ''try.. try.. till you die'' especially if you have some wonderful person helping, just like you. thanks a lot sir. I just hope you be patient with me till the end of this. this will really be kind of youNow to move a step forward I've copied your code suggested above and pasted it instead of the working program and when building it, new errors appear..linking...
.\IO_Toggle\IO_Toggle.axf: Error: L6218E: Undefined symbol USART_Cmd (referred from main.o).
.\IO_Toggle\IO_Toggle.axf: Error: L6218E: Undefined symbol USART_GetFlagStatus (referred from main.o).
.\IO_Toggle\IO_Toggle.axf: Error: L6218E: Undefined symbol USART_Init (referred from main.o).
.\IO_Toggle\IO_Toggle.axf: Error: L6218E: Undefined symbol USART_ReceiveData (referred from main.o).
.\IO_Toggle\IO_Toggle.axf: Error: L6218E: Undefined symbol USART_SendData (referred from main.o).
Not enough information to list image symbols.
Finished: 1 information, 0 warning and 5 error messages.
''.\IO_Toggle\IO_Toggle.axf'' - 5 Error(s), 1 Warning(s).
Target not created
also usart.h is included in stm32f4xx_conf.h .. I really don't understand what is meant by
(referred from main.o) ... ?
I know that the object file is the output of the compiler, but when there'll be error in this file?Thanks for your great support2014-03-25 09:42 PM
You have to add stm32f4xx_usart.c to the project, you'll need to go up the directory tree, and into the libraries directory.
STM32F4-Discovery_FW_v1.1.0\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c You probably have stm32f4xx_gpio.c already, but you need the source for each library component you use.