uart code in mikroc pro

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
nsreen
Posts: 5
Joined: 01 Dec 2011 07:49

uart code in mikroc pro

#1 Post by nsreen » 02 Dec 2011 23:18

i want an example code of uart at mikroc pro as really i am confused about it and can't make the whole code and thanks in advance

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

Re: uart code in mikroc pro

#2 Post by filip » 05 Dec 2011 10:54

Hi,

You can find UART examples in the following folder in the mikroC compiler :
\Examples\Development Systems\EASYPIC7\UART\

For detailed explanation, please see UART library topic in the help file.

Regards,
Filip.

Elektrik
Posts: 5
Joined: 05 Dec 2011 16:27

Re: uart code in mikroc pro

#3 Post by Elektrik » 05 Dec 2011 16:52

Hello.
I'm also having trouble with UART using FT232RL on PIC16F688.
I've connected FT`s TX and RX lines vice versa to hardware UART pins on PIC. I'm using Internal 4Mhz clock in PIC. Here's code used from Examples folder of PIC:

Code: Select all

char uart_rd;

void main() {
  CMCON0 = 0x07;
  ANSEL = 0;                     // Configure PORTC pins as digital

  UART1_Init(9600);               // Initialize UART module at 9600 bps
  Delay_ms(100);                  // Wait for UART module to stabilize

  UART1_Write_Text("Start");
  UART1_Write(13);
  UART1_Write(10);

  while (1) {                     // Endless loop
    if (UART1_Data_Ready()) {     // If data is received,
      uart_rd = UART1_Read();     // read the received data,
      UART1_Write(uart_rd);       // and send data via UART
    }
  }
}
In terminal emulator on PC (Putty) insted of "Start" command line shows "Ъ│#oТш", and if i press for example key "A", ir return char "ю". Where to search an explanation how to solve this :) Thanks.

nsreen
Posts: 5
Joined: 01 Dec 2011 07:49

Re: uart code in mikroc pro

#4 Post by nsreen » 06 Dec 2011 08:06

thnx i found it :)

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

Re: uart code in mikroc pro

#5 Post by filip » 06 Dec 2011 10:05

Hi Elektrik,

This seems to be the issue with oscillator or the baud rate.
Please, check these things and make sure that they are correctly configured.

Regards,
Filip.

Elektrik
Posts: 5
Joined: 05 Dec 2011 16:27

Re: uart code in mikroc pro

#6 Post by Elektrik » 06 Dec 2011 15:31

filip wrote:Hi Elektrik,

This seems to be the issue with oscillator or the baud rate.
Please, check these things and make sure that they are correctly configured.

Regards,
Filip.
Today I've atached external 4Mhz oscillator, configured as XT, and hardware UART works like a charm! Seems like internal oscillator`s frequency is dependant on phase of the moon, and only thing works brillianty with interna osc. is turning LED on and off :) Thanks mate!

Post Reply

Return to “mikroC PRO for PIC General”