UART for 7" Mikroe HMI (FT90x)

General discussion on mikroC PRO for FT90x.
Post Reply
Author
Message
signalflow
Posts: 6
Joined: 27 Jul 2017 00:17

UART for 7" Mikroe HMI (FT90x)

#1 Post by signalflow » 27 Jul 2017 00:24

Hi, I am having trouble getting the UART working properly for the 7" mikro HMI. I used the UART1 functions from the Library Manager at the right side of the mikroC Pro. I am able to get it to transmit suing UART1_Write() function. I am also able to get it to read using the UART1_Read() function. My problem is that if I try to check the data ready flag by reading UART1_Data_Ready(), it never goes true. So it is never going into the IF statement that I have pasted below. If I remove that IF statement, then it reads ok. But if I remove the IF statement and just always do a READ, then it waits there at the read. So I want to see if the data is ready before I do a read. Also, how can I find where mikroC is told what pins are what on the FT900?

Code: Select all

UART1_Init(9615);
  Delay_ms(100);                 // Wait for UART module to stabilize
  UART_Set_Active(&UART1_Read, &UART1_Write, &UART1_Data_Ready, &UART1_Tx_Idle); // set UART1 active
  Delay_ms(100);                 // Wait for UART module to stabilize

//later I do this...
if(UART_Data_Ready())
        {
          receive=UART1_Read();
        }


hexreader
Posts: 1785
Joined: 27 Jun 2010 12:07
Location: England

Re: UART for 7" Mikroe HMI (FT90x)

#2 Post by hexreader » 27 Jul 2017 09:45

Guessing a bit here, but shouldn't "UART_Data_Ready" be replaced with "UART1_Data_Ready" ?
Start every day with a smile...... (get it over with) :)

signalflow
Posts: 6
Joined: 27 Jul 2017 00:17

Re: UART for 7" Mikroe HMI (FT90x)

#3 Post by signalflow » 27 Jul 2017 14:44

I tried UART1_Data_Ready() first and since that didn't work, I tried UART_Data_Ready(). The latter is for the active UART and UART1 is active. Neither work though. On the 7" Mikroe HMI, UART1 in the code actually controls UART0 on the schematic. But UART0 gives compile errors. But that's not the problem. The problem is the UART1_Data_Ready() always returns FALSE.

User avatar
darko.ilijevski
Posts: 581
Joined: 21 Mar 2017 16:57

Re: UART for 7" Mikroe HMI (FT90x)

#4 Post by darko.ilijevski » 27 Jul 2017 17:10

Hello,

In the mikromedia HMI 7", FT900Q is the used MCU and it has it's UART0 RX and TX pins (GP48 and GP49) going out through the main connector. We do not have UART0, so we named it as UART1.
So UART0 on the schematics is actually UART1 in the compiler's library. Now as for your code, it should look like this - I have tested it and it works:

Code: Select all

char output;
void main() {
   UART1_Init(9600);
   
  while (1) {
      if (UART1_Data_Ready() == 1) {       // checks if there's something in the UART rx buffer

        output = UART1_Read();                    // reads one char off the buffer
        UART1_Write(output);             // sends it back
     }
  }
}
I will attach the project files here as a .ZIP file, so you can test it yourself. Also I don't know why did you use that baudrate, it's not one of the standard baudrates. Also I couldn't see your IF statement inside a loop, else it will just check once and exit, before you had a chance to send some data through...
If you have more questions regarding this, feel free to ask
Best regards
Attachments
UART on FT900Q.zip
(1.32 KiB) Downloaded 108 times
BR,
Darko

Post Reply

Return to “mikroC PRO for FT90x General”