Hi,
This program receives data through the serial port and the display shows.
receive data when the computer comes correct.
when I receive data from another microcontroller data are not correct.
I am using a PIC18F452
program that receives:
/*
cada caractere recebido pela serial,
sera enviado para o display LCD no formato ASCII.
velocidade de 2400 Bps
LCD trabalhando no modo 8 bits.
Usado o hyperterminal para transferência dos dados via RS232.
cristal: 8mhz
Compilador: mikroC
*/
void main(){
unsigned short rx; //espaço
char a = 0;
//conf serial
USART_init(2400); //inicializa serial com baudrate 2400 bps
delay_ms(100);
//conf LCD
trisd = 0; // conf portD como saída
portD= 0x00;
trise = 0; // conf portE como saída
adcon1 = 0x06; // conf todos pinos de A/D como I/O de uso geral
lcd8_config ( &porte, &portd,2,1,0,7,6,5,4,3,2,1,0); // conf e inicializa LCD
lcd8_cmd(lcd_clear); // apaga LCD
do {
if (Usart_Data_Ready()) { //chegou algum byte no buffer serial
rx= Usart_read(); // le caracter
Usart_Write(rx); //ecoa no hiperterminal
a++;
Lcd8_Chr(1,a,rx); //mostra caracter no LCD
}
} while(1);
}
Problem receive data RS232
Re: Problem receive data RS232
Hi Fabiano,
Check the Baud Rate settings on both the controllers. I observe you are running at 2400 but it is usually 9600.
Regards.
Check the Baud Rate settings on both the controllers. I observe you are running at 2400 but it is usually 9600.
Regards.
- tihomir.losic
- mikroElektronika team
- Posts: 2138
- Joined: 02 Dec 2009 14:16
- Location: Serbia
- Contact:
Re: Problem receive data RS232
Hello,
first of all, I want to suggest you to download our PRO version of mikroC.
mikroC PRO for PIC: http://www.mikroe.com/download/c_pic_pro.php
mikroC PRO for PIC 2009 includes a set of libraries and examples intended to facilitate application development.
Routines are documented in detail and allow quick start in programming microcontrollers; browse through the supplied
examples and learn how to utilize PIC with minimum of code and effort.
Also, you can look for detailed explanation about UART and LCD library on following links:
- UART library
- LCD library
For any further assistance, feel free to contact us.
Best regards,
Losic Tihomir
first of all, I want to suggest you to download our PRO version of mikroC.
mikroC PRO for PIC: http://www.mikroe.com/download/c_pic_pro.php
mikroC PRO for PIC 2009 includes a set of libraries and examples intended to facilitate application development.
Routines are documented in detail and allow quick start in programming microcontrollers; browse through the supplied
examples and learn how to utilize PIC with minimum of code and effort.
Also, you can look for detailed explanation about UART and LCD library on following links:
- UART library
- LCD library
For any further assistance, feel free to contact us.
Best regards,
Losic Tihomir
mikroElektronika [Support team]
Re: Problem receive data RS232
Thanks for the help of all!
Referring to the baud rate is correct.
I downloaded the version suggested and tried to do some tests with LCD
The following problems occurred in the build.
Referring to the baud rate is correct.
I downloaded the version suggested and tried to do some tests with LCD
The following problems occurred in the build.
- Attachments
-
- tela1.JPG (108.78 KiB) Viewed 2064 times
- tihomir.losic
- mikroElektronika team
- Posts: 2138
- Joined: 02 Dec 2009 14:16
- Location: Serbia
- Contact:
Re: Problem receive data RS232
Hello,
you need to replace following lines:with this line of code:
Best regards,
Losic Tihomir
you need to replace following lines:
Code: Select all
ANSEL = 0;
ANSELH = 0;
Code: Select all
ADCON1 = 0x07;
Losic Tihomir
mikroElektronika [Support team]