Snail.cz
Newbie level 4
Hi,
I have a problem with EUSART(18F4550) Interface. I can't connect this MCU with PC via RS232.
When I transmit byte from MCU, the PC receive somethink else. For example: MCU transmit 0xaa and PC receive 0xff. So, I think it's problem with baudrate...
The problem isn't in hardware, because with 16F877A everythink works fine...
I'am using 20MHz crystal, and I want 20Mhz Fosc. So, configuration bits are:
CONFIG1L = 0b00100100;
CONFIG1H = 0b00001100;
Is that rigth ?
There is my code, i dont known what I doing wrong...
Thanks, and excuse my poor english...
I have a problem with EUSART(18F4550) Interface. I can't connect this MCU with PC via RS232.
When I transmit byte from MCU, the PC receive somethink else. For example: MCU transmit 0xaa and PC receive 0xff. So, I think it's problem with baudrate...
The problem isn't in hardware, because with 16F877A everythink works fine...
I'am using 20MHz crystal, and I want 20Mhz Fosc. So, configuration bits are:
CONFIG1L = 0b00100100;
CONFIG1H = 0b00001100;
Is that rigth ?
There is my code, i dont known what I doing wrong...
Code:
void serial_init(){
TRISC7 = 1; //Nastavení bran
TRISC6 = 1;
SPBRG = 64;
BAUDCON = 0b00000000;
TXSTA = 0b00100110;
RCSTA = 0b10010000;
}
unsigned char RS232_send_byte(unsigned char data){
while(TXIF == 0){}; // cekaci smycka
TXREG = data;
return(1);
}
void main(void){
serial_init();
while(1){
DelayMs(300);
RS232_send_byte(0xaa);
}
}
Thanks, and excuse my poor english...