Jump to content
Sign in to follow this  
NotAlame

USART2 communication with STM32F4 problem

Recommended Posts

Hello,

 

I just started recently to test my stm32F4 with RX/TX communication. I tried for the first time the ChibiOS on it and the demo was a success. But now, I'm trying to use USART_SendData to send data, and here comes the problem: when I use Cutecom, I receive always some hex codes and not what I need to see (in my case: 'A'):

 

Here are the hex codes I always receive : \0x1c\0xfc

 

Here is a hint of my main.c

 /* USART Configuration */
USART_Configuration();
USART_SendData(USART2, '5');

 

I tried to change the ChibiOS exemple, and it succeeded:

chprintf((BaseChannel *)&SD2, "A");

 

But I don't want to use ChibiOS because I don't find the equivalent function of USART_ReceiveData

 

So, do you know any solution?

Share this post


Link to post
Share on other sites

I just find a solution for that: I just add *3 for my baudrate. In my case:

USART_InitStructure.USART_BaudRate = 9600*3;

 

But now, I have another problem: the USART_ReceiveData don't wanna work , I mean I can send data on the RX port, but the stm don't "use it"...

 

Is there any solution?

Share this post


Link to post
Share on other sites

I just find a solution for that: I just add *3 for my baudrate. In my case:

USART_InitStructure.USART_BaudRate = 9600*3;
But now, I have another problem: the USART_ReceiveData don't wanna work , I mean I can send data on the RX port, but the stm don't "use it"...

 

Is there any solution?

 

 
Your HSE set is wrong!
 
it must match your external clock.
 
In the case of discovery board, should be of 8M.
 
Besides the multiplier "* 3" as in your example, maybe have a  "2~8%" baud error.
 
...
 
Change this
#define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */

with

#define HSE_VALUE    ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */

or re-define 

#if defined  (HSE_VALUE)
/* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */
 #undef HSE_VALUE
 #define HSE_VALUE    ((uint32_t)8000000) 
#endif /* HSE_VALUE */

and call 

SystemCoreClockUpdate();

if you need restore the SystemCoreClock variable.

 

 

 

Regards.

Maurizio

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×