I am facing a issue concerning the serial USART3 on the STM32F4 discovery board. First I have searched a lot on the Internet and on the forum but without any success...
My goal is to control HerkuleX servo motors which need serial communication : http://www.dfrobot.com/wiki/index.php/Herkulex_DRS-0101_SKU:SER0032
I followed a lot of different solutions I found on the forum and Internet but I am still getting weird characters on my PC.
Normally this issue comes from a problem in the clock configuration, but as I am using the default configuration of ChibiOS, I guess the clock config is correct.
The "HAL driver system settings" in mcuconf.h remains the same as default.
Here is my usart configuration :
mcuconf :
Code: Select all
/*
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 TRUE
#define STM32_SERIAL_USE_USART2 FALSE
#define STM32_SERIAL_USE_USART3 TRUE
#define STM32_SERIAL_USE_UART4 FALSE
#define STM32_SERIAL_USE_UART5 FALSE
#define STM32_SERIAL_USE_USART6 FALSE
Serial config :
Code: Select all
const SerialConfig sd3_config =
{
38400, // bit rate
0, // CR1 register settings
0, // CR2 register settings
0, // CR3 register settings
};
Init code :
Code: Select all
/****************************************************************************************************
* Activates the serial driver 3 - baud rate : 38400
****************************************************************************************************/
sdStart(&SD3, &sd3_config);
palSetPadMode(GPIOD, 8, PAL_MODE_ALTERNATE(7)); //Tx
palSetPadMode(GPIOD, 9, PAL_MODE_ALTERNATE(7)); //Rx
main code :
Code: Select all
static const char message3[] = "STM32F4 - Discovery";
while(TRUE)
{
if (palReadPad(GPIOA, GPIOA_BUTTON))
{
sdWrite(&SD3, (uint8_t *) message3, strlen(message3));
palSetPad(GPIOD, LED_BLUE);
}
else
{
palClearPad(GPIOD, LED_BLUE);
}
}
For testing purpose, I just want to send "STM32F4 - Discovery" by pressing the user button.
I configure the serial communication on the PC as : 38400-8-N-1, no flow control
I also connected RTS to CTS, to be sure.
Should I use Serial driver system settings or UART driver setting ? I tried both, but still not working...
Should I use a different function instead of sdWrite ?
Should I change the "HAL driver system settings" ?
I used several uart or usart config, pins config, all the same issue...
I also followed this example which seems to work : http://www.telecom-robotics.org/2013/08/robotics-101-transmitting-data-with-chibios-serial-driver/
I tried to change the PIN of usart on the board (GPIOB, 10 and GPIOB, 11) but this does not work better.
I checked my RS232 adapter, mine is using a ft232l, I used before this adapter and this component without any issue and the input signals are 3.3v compatible.
I suppose it could be a clock config error, because I had this character problem on another project. I have also difficulties with the accelerometer, that's why I am supposing a clock config issue.
But as I said before, the mcuconf is the default one.
I want to be sure that is not a software problem, before buying a new serial adapter
I am completely stuck
Can anyone support me on this ?
Thanks in advance