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
EUSART for Pic16f1937
Re: EUSART for Pic16f1937
Hi,
Please, try this code :
Regards,
Filip.
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
}
}
}
Filip.
-
- Posts: 3
- Joined: 25 Apr 2012 09:32
Re: EUSART for Pic16f1937
it didnt work at all ... I thinks the EUSART has a different way to initialize it and use it
Re: EUSART for Pic16f1937
Hi,
Please, try the project from the attachment.
Regards,
Filip.
Please, try the project from the attachment.
Regards,
Filip.
- Attachments
-
- UART.rar
- (35.24 KiB) Downloaded 378 times
-
- Posts: 2
- Joined: 04 Dec 2014 02:31
Re: EUSART for Pic16f1937
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 !! 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 ?
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 !! 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 ?
Re: EUSART for Pic16f1937
Hi,
Did you set the oscillator correctly ?
Regards,
Filip.
Did you set the oscillator correctly ?
Regards,
Filip.
Re: EUSART for Pic16f1937
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
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 (189.17 KiB) Viewed 5368 times
-
- Untitled.png (159.76 KiB) Viewed 5368 times