UART communication problem

General discussion on mikroC PRO for ARM.
Post Reply
Author
Message
pensees
Posts: 15
Joined: 29 Sep 2020 05:45

UART communication problem

#1 Post by pensees » 29 Sep 2020 06:14

Hi,

I'm using mikromedia+ for STM32 ARM board with STM32F407ZG MCU.

I try to UART communication with FT232 module using UART library.


// Code example
void Init_MCU() {

...

UART2_Init_Advanced(115200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_MODULE_USART2_PD5_PA3);
}

// Event Handler (when touchscreen pressed)
void touched() {

char* cmd = "Test";
char* receive;

...

UART2_Write_Text(cmd);

while (!UART2_Data_Ready());
receive[0] = (char)UART2_Read();

UART2_Write_Text("Receive Done");
}


Then I connect RX/TX pin to pin No. 47 & 48.

After compile and load to board then executed, but library functions don't work. (Nothing shows in terminal)


Please advice for me.
Thanks.
Attachments
MyProject.zip
(715.87 KiB) Downloaded 62 times

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: UART communication problem

#2 Post by filip.grujcic » 29 Sep 2020 08:21

Hello,

Have you configured the MCU clock correctly in the Edit Project window (Ctrl + Shift + E)?
You can click on the Load Scheme button and look for a scheme which suits your set up. There are many for STM32F407ZG.

Regards,
Filip Grujcic

pensees
Posts: 15
Joined: 29 Sep 2020 05:45

Re: UART communication problem

#3 Post by pensees » 12 Oct 2020 09:46

Hi, filip

Thanks for your advice, I tried all configurations but still not work correctly.

For detail, I used STM32F407ZG_HSE_PLL_25MHz_to_168MHz configuration by default.

And I adjust MCU Clock Frequency to 150MHz.

What should I do more??
Attachments
configurations_VTFT.png
configurations_VTFT.png (30.36 KiB) Viewed 1927 times
configurations.png
configurations.png (7.56 KiB) Viewed 1927 times

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: UART communication problem

#4 Post by filip » 13 Oct 2020 08:40

Hi,

If you chosen the 168MHz profile, why did you enter 150 MHz frequency in the Device Clock input field ?

Regards,
Filip.

pensees
Posts: 15
Joined: 29 Sep 2020 05:45

Re: UART communication problem

#5 Post by pensees » 14 Oct 2020 03:07

In VTFT settings, Hardware pattern is "Mikromedia_Plus_for_STM32_ARM" (default)

This pattern uses "VTFT_Mikromedia_Plus_for_STM32_HSE_PLL_25MHz_150MHz" scheme. (MCU frequency is 150MHz)


So, I matched scheme between General setting and VTFT setting. ("STM32F407ZG_HSE_PLL_25MHz_to_168MHz")

But it still not work correctly.

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: UART communication problem

#6 Post by filip.grujcic » 14 Oct 2020 15:22

Hello,

Have you double checked that you didn't connect Rx to Rx and Tx to Tx by accident?

Kind regards,
Filip Grujcic

pensees
Posts: 15
Joined: 29 Sep 2020 05:45

Re: UART communication problem

#7 Post by pensees » 15 Oct 2020 02:19

Yeah, I checked several times.

(Pin &47 is Rx that connected FT232's Tx, Pin &48 is Tx that connected FT232's Rx)

* Pin &47 : _GPIO_USART2_RX_PA3
* Pin &48 : _GPIO_USART2_TX_PD5

AntiMember
Posts: 137
Joined: 02 Jan 2020 19:00

Re: UART communication problem

#8 Post by AntiMember » 15 Oct 2020 08:36

Did you try to separate the problem?
Connect Pin 47 to Pin 48 and check in debug.

pensees
Posts: 15
Joined: 29 Sep 2020 05:45

Re: UART communication problem

#9 Post by pensees » 16 Oct 2020 09:21

Yes, I checked separately and debug mode.

But still problem exists...


In case of Soft_Uart library, write (send) is ok. (Because it send only 1 character repeatly)

Read (receive) is partially worked. (For example, Host send 30 characters, the board just receives 1/5 ~ 1/6)

pensees
Posts: 15
Joined: 29 Sep 2020 05:45

Re: UART communication problem

#10 Post by pensees » 29 Dec 2020 08:33

Thanks to everyone, solved using H/W UART6 module and pin &45/46.

Post Reply

Return to “mikroC PRO for ARM General”