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 10:10 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.
This is just great, finally it compiled without any errors or warnings and also burnt on the chip.. you're wonderful sir, and I'm really so grateful Now to the last step, testing if the USART is working fine with realterm. Now I've installed realterm, and I have my USB-to-TTL converter module.. its picture is in the attachments.. the question is.. how to use them ? I think that I have to connect PC6 pin on the discovery board with RXI pin on the module and PC7 pin on the discovery kit with TXO pin on the module and the 5V pin on the kit with VCC pin on the module and finally GND pin on the kit with GND pin on the module, then I expect to see the output and send the input of the USART on realterm ... Am I right ?? ________________ Attachments : USB-to-TTL_module.JPG : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0e8&d=%2Fa%2F0X0000000bbs%2FQnXFer99rzUyk2d436g2X78tJPTWe9ug4Di_sRXcFCg&asPdf=false
2014-10-01 03:29 AM
2015-06-23 10:00 AM
Hello Clive1, I have the same error and I am working on Windows 8. Do you have any solutions ?
Thanks2015-06-23 11:09 AM
This thread is over a year old, what ''error'' exactly are you getting?
For Windows 8, you're going to need to find a Signed Driver that Windows 8 can use, or go through the process of disabling the signing requirement.https://developer.mbed.org/teams/st/wiki/ST-Link-Driver
2015-07-08 08:50 AM
Hello,
Just for information, using a STM32VLDISCOVERY and trying to load my code, I had the message : ''Error: Flash Download failed - C:\Keil\ARM\STLink\ST-LINKIII-KEIL.dll
'' (µVision 5.15.0)I solved the issue by setting the right target in the ''Options for target'' => ''Device'' => ''STM32F100RB'' (''STM32F100VB'' was configured by default)and by setting the right debugger : ''Options for target'' => ''Debug'' ==> ''Use: ST-Link Debugger'', then ''Options for target'' => ''Utilities'' => Use Target Driver for Flash Programming'' => ''ST-Link Debugger''Then I met another issue trying to load my code : ''Error: Flash Download failed - Target DLL has been cancelled
''I just solved this issue by setting the right debug adapter port : ''Options for target'' => ''Utilities'' => ''Settings'' ==> ''Debug'' ==> ''Port: SW'' (it was ''JTAG'' by default).Now loading and debug work properly.Bye