UART Write Giving strangecharacters as received characters

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
Oluwole_Oyetoke
Posts: 19
Joined: 06 May 2013 22:02

UART Write Giving strangecharacters as received characters

#1 Post by Oluwole_Oyetoke » 03 Sep 2015 22:43

I am trying to play around with simple USART read and write, however, my USART terminal keeps displaying funny characters as the output. Please is there anything i am doing wrong?

Code: Select all

void main() {
  UART1_Init(9600);
  Delay_ms(1000);
  LCD_Init();
  LCD_Out(1,1,"Welcome");
  Delay_ms(1000);
  LCD_Cmd(_LCD_CLEAR);
  while(1){
       if(UART1_Data_Ready()==1){

      uartReadData = UART1_Read();   //uartReadData declared as a char
      UART1_Write(uartReadData);
      LCD_Chr_Cp(uartReadData);
        }


  
  
  }
}

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: UART Write Giving strangecharacters as received characte

#2 Post by Aleksandar.Mitrovic » 04 Sep 2015 10:40

Hi,

Did you try to use different baud rate or oscillator settings?

Also did you declare "uartReadData" as char.

Best regards,
Aleksandar

Oluwole_Oyetoke
Posts: 19
Joined: 06 May 2013 22:02

Re: UART Write Giving strangecharacters as received characte

#3 Post by Oluwole_Oyetoke » 05 Sep 2015 10:18

Yes I have done that, but it still does not receive the character sent
Attachments
USART Terminal Display
USART Terminal Display
Capturew.JPG (91.15 KiB) Viewed 1871 times

Jack Flanders
Posts: 337
Joined: 17 Apr 2008 02:53
Location: Fantasy Land

Re: UART Write Giving strangecharacters as received characte

#4 Post by Jack Flanders » 05 Sep 2015 21:57

Your first post shows this:

Code: Select all

 UART1_Init(9600);
but your image of the terminal program shows that you are connected at 38400 baud. Try connecting at 9600 and see what you get...

Oluwole_Oyetoke
Posts: 19
Joined: 06 May 2013 22:02

Re: UART Write Giving strangecharacters as received characte

#5 Post by Oluwole_Oyetoke » 06 Sep 2015 00:02

Now i get the right character, however, the LCD in proteus which is supposed to display the read character displays double. E.g, if i send letter 'k' trjough the UART, the LCD shows 'kk' Any Idea why this is?

I am 9600 baud rate and my MCU clock speed is 48MHz

Please help out

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: UART Write Giving strangecharacters as received characte

#6 Post by Aleksandar.Mitrovic » 07 Sep 2015 08:36

Hi,

Since Proteus is not officially supported by mikroElektronika I suggest you to test this on real hardware.

Your settings should work on 9600 baud rate.

Best regards,
Aleksandar

Post Reply

Return to “mikroBasic PRO for PIC General”