Skip to main content
Explorer II
June 18, 2024
Solved

UART sending some else data and not as intended

  • June 18, 2024
  • 5 replies
  • 3164 views

i am using STM3210e-eval board which has stm32f103zgt6 MCU no i am just sending data over uart to my pc the uart is interfaced with rs232 port so for the looking at the schematics i have connected it's tx and rx to ft232rl's rx and tx respectively and taken the vcc and gnd from the board to the module i have also check the ioc file and it has been set properly asynchronous  mode with 1 stop bit and none parity bit i have also double check the baud rate but i recieve something else on putty now the problem isn't in putty because i checked the data directly over oscilloscope directly from tx pin of mcu and it shows the exact same data as was shown on putty so i guess the mcu is some how converting my data into something else and then sending also it is not random on checking from for all the integers i found out that starting from 1 for all the odd numbers if sent 1 it shows 127 ascii value character and for next odd it decrements to 126 and so on and now for even number it stars at 63 ascii value character and decrements moving further but for all the multiples of 4 it gives nothing that a blank. what is happening?

PS: i have also tried changing the baud rate from 115200 to 9600.... doesn't do any difference

 

here is the code

uint8_t data[1];
data[0] = 10;
HAL_UART_Transmit(&huart1,data,1,HAL_MAX_DELAY);
HAL_Delay(1000);

 

    This topic has been closed for replies.
    Best answer by waclawek.jan

    > the problem isn't in FTDI FT232RL since even on scope without FT232RL it is the same data and if i send 0x55 is shows 0x54 on the scope which as i mentioned earlier is matching with that weird pattern of odd even

    As @Tesla DeLorean said, the problem is that you are looking at the signal on the DB9 connector of the EVAL board, *after* a RS232 convertor. RS232 has different levels than 0-3V, and is inverted.

    That's why you need a second convertor between the DB9 and FT232RL which inverts again and reverts from RS232 levels to 0-3V.

    Or, find the Tx signal directly on the mcu pin (there may be headers on the EVAL board exposing the mcu signals - I am not familiar with this particular board) and connect that to FT232RL.

    JW

    5 replies

    Graduate II
    June 18, 2024

    Have you tried data[0] = 'a'; example 

    rahul7515Author
    Explorer II
    June 18, 2024

    yes i have and still getting something else 

    Graduate II
    June 18, 2024

    Have you properly set your system core clock frequency and USART frequency before enabling the USART and setting the baud rate?

    rahul7515Author
    Explorer II
    June 18, 2024

    on cubeMX i have selected the board instead of the MCU so by opening it in default peripherals initialized everything is already set besides i am using it in asynchronous mode and i f and i am wrong guide me through it like how to set properly usart frequency and what else to do and how much to set 

    Super User
    June 18, 2024

    > i checked the data directly over oscilloscope directly from tx pin of mcu 

    Show.

    JW

    Graduate II
    June 18, 2024

    The DB9 RS232 port is outputting at RS232 levels, best I can tell the FTDI FT232RL is using 3.3V or 5V CMOS levels. These aren't compatible.

    You'd need an RS232 compatible dongle, or MAX3232 or equivalent IC to get the levels matched

    Output a 'U' / 0x55 pattern, every 1ms, and show that output on a scope, so we can see a couple of characters, and the timing of the bits and bytes.

    rahul7515Author
    Explorer II
    June 18, 2024

    the problem isn't in FTDI FT232RL since even on scope without FT232RL it is the same data and if i send 0x55 is shows 0x54 on the scope which as i mentioned earlier is matching with that weird pattern of odd even

    Graduate II
    June 18, 2024

    Can you please share the pictur of uart setting ioc? Are you using 8 bit or 9 bits data? 

    Super User
    June 18, 2024

    > the problem isn't in FTDI FT232RL since even on scope without FT232RL it is the same data and if i send 0x55 is shows 0x54 on the scope which as i mentioned earlier is matching with that weird pattern of odd even

    As @Tesla DeLorean said, the problem is that you are looking at the signal on the DB9 connector of the EVAL board, *after* a RS232 convertor. RS232 has different levels than 0-3V, and is inverted.

    That's why you need a second convertor between the DB9 and FT232RL which inverts again and reverts from RS232 levels to 0-3V.

    Or, find the Tx signal directly on the mcu pin (there may be headers on the EVAL board exposing the mcu signals - I am not familiar with this particular board) and connect that to FT232RL.

    JW