EUSART for Pic16f1937

Here you can ask for specific code examples and discuss about it with other forum members.
Post Reply
Author
Message
mina.tawfik
Posts: 3
Joined: 25 Apr 2012 09:32

EUSART for Pic16f1937

#1 Post by mina.tawfik » 26 Apr 2012 12:13

I am trying to send and recieve data from PIC16f1937 to PC via RS232 . can any1 send a sample MikroC code of how to initialize and send texts and communicate with the PC
thnanks

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

Re: EUSART for Pic16f1937

#2 Post by filip » 27 Apr 2012 12:48

Hi,

Please, try this code :

Code: Select all

char uart_rd;
unsigned int i;

void main() {
  ANSELA = 0;                     // Configure AN pins as digital
  ANSELB = 0;
  ANSELD = 0; 
  ANSELE = 0;

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

  UART1_Write_Text("Uart1 start");

  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
    }
  }
}
Regards,
Filip.

mina.tawfik
Posts: 3
Joined: 25 Apr 2012 09:32

Re: EUSART for Pic16f1937

#3 Post by mina.tawfik » 30 Apr 2012 09:12

it didnt work at all ... I thinks the EUSART has a different way to initialize it and use it

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

Re: EUSART for Pic16f1937

#4 Post by filip » 03 May 2012 10:28

Hi,

Please, try the project from the attachment.

Regards,
Filip.
Attachments
UART.rar
(35.24 KiB) Downloaded 378 times

vientodeguerra
Posts: 2
Joined: 04 Dec 2014 02:31

Re: EUSART for Pic16f1937

#5 Post by vientodeguerra » 07 Jan 2015 02:23

Hi.

I have a similar problem. I hadn't been unable to initialize the EUART2 of pic18f66k90 , and I followed your advice to put instead of 9600 bps 19200bps . This worked !! :o but now my problem is that I have an enabled port to 19200 bps when in fact I need to have a speed of 9600. What can I do ? :?:

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

Re: EUSART for Pic16f1937

#6 Post by filip » 08 Jan 2015 11:29

Hi,

Did you set the oscillator correctly ?

Regards,
Filip.

raufawan1
Posts: 5
Joined: 14 Mar 2015 18:12

Re: EUSART for Pic16f1937

#7 Post by raufawan1 » 15 Mar 2015 05:52

the code you provided is not working correctly here are the scren shots.
actually i ave also a problem in pic18f452 in transmitting the data using uart, but there is no issue in recieveing the data through uart .. kindly elp me also. thanks
Attachments
Untitled1.png
Untitled1.png (189.17 KiB) Viewed 5368 times
Untitled.png
Untitled.png (159.76 KiB) Viewed 5368 times

Post Reply

Return to “Code Requests”