UART "SendString" command problem [SOLVED]

For general Flowcode discussion that does not belong in the other sections.
Sasi
Posts: 107
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 12:11 pm
Has thanked: 37 times
Been thanked: 14 times

Flowcode v10 UART "SendString" command problem [SOLVED]

Post by Sasi »

Hi!
In mid-December 2024, I created a project with a PIC18F46K80 MCU in Flowcode 10. It worked fine. Since then, I have updated the component libraries several times. Now I should modify the program, but I have found that the UART "Send String" command no longer sends the string to the line. The program does not stop at the command, it continues to run, but nothing happens on the UART output. If I use the "Send Char" or "Send Number" command, it works fine. Can you help me with this?
Regards, Sasi
Last edited by Sasi on Sat May 10, 2025 4:40 pm, edited 3 times in total.

mnfisher
Valued Contributor
Posts: 1520
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 732 times

Re: UART "SendString" command problem

Post by mnfisher »

It's odd - as, for example, SendNumber uses PrintString (it converts the number to a string then sends it...)

Can you post an example that demonstrates?

Martin

Sasi
Posts: 107
Joined: Wed Dec 02, 2020 12:11 pm
Has thanked: 37 times
Been thanked: 14 times

Re: UART "SendString" command problem

Post by Sasi »

Hi Martin,
I quickly put together an example.
This behaves exactly as I described.
The result of the last UART command is not displayed in the TX line.
The commands before it work.
Thanks for looking.
Sasi
UART_Test.fcfx
(11.11 KiB) Downloaded 45 times

mnfisher
Valued Contributor
Posts: 1520
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 732 times

Re: UART "SendString" command problem

Post by mnfisher »

Hi,

How are you testing this - for example logic analyser connected to Tx or with an FTDI convertor connected to Tx and Rx. Not just looking at the reply from a GSM or BT adapter?) I'm assuming this is testing on hardware too (it works AOK in SIM)

What happens if you add another SendString after the current end line (or a delay) - if the program terminates immediately then the UART might not get flushed correctly - although for most MCUs this would not be the case... The program has end_loop goto end_loop when it 'falls off the end' - try adding
while(1)
delay(10ms)

Martin

celebriums
Posts: 42
Joined: Fri Dec 18, 2020 7:33 am
Location: Turkey
Has thanked: 23 times
Been thanked: 7 times
Contact:

Re: UART "SendString" command problem

Post by celebriums »

Hello Dear Sasi

Fake Microcontrollers
Especially clone or refurbished microcontrollers, which are widely circulated in the market, may not work at the original Microchip quality.

They often have stability problems with high-frequency operations (e.g. 115200 baud).

Sometimes ID codes cannot be read or they show strange behavior when the application is not loading.

🛠️ Solution: A good method would be to buy from a reliable supplier and check the ID and Device ID registers if in doubt.

📐 2. Crystal / Internal Oscillator Settings
Since baudrate calculations are directly dependent on the oscillator frequency, even small deviations in the internal oscillator can cause problems in communication.

Especially if the internal oscillator is used and the baudrate is high (>38400), the margin of error is seriously affected.

The settings of bits such as BRGH, BRG16 also affect this balance.

🛠️ Solution:

Use an external crystal (for example 8MHz or 16MHz).

Calculate the SPBRG value manually.

Trying lower speeds if possible.

🚀 3. 115200 Baudrate Issues
Using high baudrate in this series (especially in 18F series) can cause serious timing problems.
Because in some hardware versions the timing of the USART module deviates at high speeds.

🛠️ Solution:

First use 9600 or 19200 for testing.

If it works properly at these speeds, the problem is 90% baudrate.

🧰 4. Flowcode Library Issues
In some versions of Flowcode, the USART module may not be configured correctly. Especially in Asynchronous mode and 8-bit/16-bit configurations
Sadık Süme

Sasi
Posts: 107
Joined: Wed Dec 02, 2020 12:11 pm
Has thanked: 37 times
Been thanked: 14 times

Re: UART "SendString" command problem

Post by Sasi »

Hi,
Thanks for the suggestions, of course I have already checked them.
I have done some more tests which I have attached to the post, but I have no idea what could be causing the problem.
Interestingly, I have added a 5ms delay to the "UART_Test_2_Working" program and it no longer works ("UART_Test_2_NOT Working").
Maybe I should reinstall Flowcode10?
I am losing my mind!
UART_Test_1_Working.fcfx
(15.22 KiB) Downloaded 39 times
UART_Test_2_Working.fcfx
(15.34 KiB) Downloaded 35 times
UART_Test_2_NOT Working.fcfx
(15.33 KiB) Downloaded 39 times
Addition:
I tested the UART TX output with a Logic Analyzer.
I disconnected the TX output from the GSM radio.
Last edited by Sasi on Wed Apr 16, 2025 3:34 pm, edited 1 time in total.

Sasi
Posts: 107
Joined: Wed Dec 02, 2020 12:11 pm
Has thanked: 37 times
Been thanked: 14 times

Re: UART "SendString" command problem

Post by Sasi »

Some more tests
UART_Test_4_Working.fcfx
(15.36 KiB) Downloaded 42 times
UART_Test_4_NOT_Working.fcfx
(15.34 KiB) Downloaded 40 times
UART_Test_4_It only sends 0 (0x30).fcfx
(15.34 KiB) Downloaded 34 times
Sasi

celebriums
Posts: 42
Joined: Fri Dec 18, 2020 7:33 am
Location: Turkey
Has thanked: 23 times
Been thanked: 7 times
Contact:

Re: UART "SendString" command problem

Post by celebriums »

“AT+CNMI=2,0,0,0,0\r\n”
load this command into a string for example: STR_TX[20] Make sure it is 20 characters.

And try sending it as two separate command strings.

STR_TX="AT+CNMI=2,0,0,0,0” 17 character
STR_TX="\r\n” 4 character

Please check the Configuration Settings. When you install, these settings become default. ;)
Attachments
UART_TEST_SADIK.fcfx
(15.25 KiB) Downloaded 29 times
Sadık Süme

Sasi
Posts: 107
Joined: Wed Dec 02, 2020 12:11 pm
Has thanked: 37 times
Been thanked: 14 times

Re: UART "SendString" command problem

Post by Sasi »

Hi Sadik,

Thanks for the suggestion.
I tried the program you modified, but unfortunately the running result is similar to the original.
The following character sequence is repeated cyclically on the UART output:

"1865" -20ms_delay- "ATE0\r\n" -20ms_delay- "1865" -20ms_delay- "ATE0\r\n" -60ms_delay.

The SendString commands seem to have no effect.
I will try it with a different type of Microchip MCU from the PIC18 family.
Thanks again,
Sasi

medelec35
Matrix Staff
Posts: 1968
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 629 times
Been thanked: 659 times

Re: UART "SendString" command problem

Post by medelec35 »

Hi Sasi.
I have just tried your UART_Test_2_NOT Working.fcfx on a 18F46K80.
The only difference is I set the internal osc to 64MHz ,whereas you are using external osc.
It should not make any difference to the results.
This is what the analyser shows for baud of 19200:
PIC18F46K80 UART.png
PIC18F46K80 UART.png (198.41 KiB) Viewed 2979 times
That would suggest there is nothing wrong with the UART SendString function on 18F46K80
Therefore I'm moving this topic from Bug Reports
Martin

Post Reply