pratheeshprm143
Newbie level 6
Hai
I am using PIC18F4550 with USB (20MHz xtal). When i try to send data through UART, my serial port does not get the actual data that I have send.
When I try to send data 00-FF, only some values are correct (7,8,9, j,k,l,m & n). I think the problem is in my baud rate. I have tried more than twenty configurations from many blogs. But the problem is not fixed. I am using C18 toolkit. My code well worked with proteus simulator. Also the port (PORTB) bits are changed in my hardware. Here is my code and configuration bit settings.
I have also tried many SPBRG values for 20MHZ crystal like 1Eh,1Fh,20H,21H and so on(with the equation in data sheet).
I am using PIC18F4550 with USB (20MHz xtal). When i try to send data through UART, my serial port does not get the actual data that I have send.
When I try to send data 00-FF, only some values are correct (7,8,9, j,k,l,m & n). I think the problem is in my baud rate. I have tried more than twenty configurations from many blogs. But the problem is not fixed. I am using C18 toolkit. My code well worked with proteus simulator. Also the port (PORTB) bits are changed in my hardware. Here is my code and configuration bit settings.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #include <p18f4550.h> unsigned int i,j; void delay(int); void main(void) { TRISB=0x00; PORTB=0X00; TXSTA=0x20; SPBRG=0x20; TXSTAbits.TXEN=1; RCSTAbits.SPEN=1; while(1) { TXREG='G'; while(PIR1bits.TXIF==0); delay(100); PORTB=~PORTB; } } void delay(int d) { for(i=0;i<d;i++) { for(j=0;j<d;j++) { } } }
I have also tried many SPBRG values for 20MHZ crystal like 1Eh,1Fh,20H,21H and so on(with the equation in data sheet).
Last edited by a moderator: