PIc 16f1527 Ic uart problem

Status
Not open for further replies.

rparthiban69

New Member
I need PIC16f1527 UART sample code.


How to declare BAUDxCON,TX1STA and RC1STA bits,


BAUD1CONbits.BRG16=0;
BAUD1CONbits.ABDOVF=0;
BAUD1CONbits.RCIDL=0;
BAUD1CONbits.SCKP=0;
BAUD1CONbits.WUE=0;
BAUD1CONbits.ABDEN=1;
TX1STAbits.SYNC = 0; //
TX1STAbits.SYNC = 0; /* asynchronous */
TX1STAbits.SENDB= 0;
RC1STAbits.SPEN = 1; /* enable serial port pins */
RC1STAbits.CREN = 1; /* enable reception */ RC1STAbits.SREN = 0; /* no effect */
PIE1bits.TX1IE = 0; /* disable tx interrupts */
PIE1bits.RC1IE = 0; /* disable rx interrupts */
TX1STAbits.TX9 = 0; /* 8- or 9-bit transmission */
RC1STAbits.RX9 = 0; /* 8- or 9-bit reception */
TX1STAbits.TXEN = 1; /* enable the transmitter */
 
What compiler are you using?.... Check you documentation as there will most likely be a library with it done for you!!!
 
Thought so... Navigate to the.. "Program files \ Hi-tech software \ PICC \ 9.83 \ samples \ USART \"

Here you will find a template that will get you started....

It might be useful to you to browse through the pic16f1527.h fil.. All the declarations are in there..
 
Just re-write it to suit.... What's your FOSC? ( this is to find out if you need SPBRGH, This is the only difference.. )

If not the USART header still enumerates correctly ( in other words it defaults to USART1 )..
 
Then you will be fine.... Just include the line "SPBRGH = 0;" in the initUART(); and it should be fine...
 
Then you will be fine.... Just include the line "SPBRGH = 0;" in the initUART(); and it should be fine...

have doubt in UART baudrate formula

SYNC=BRGH=BRG16=0, formula FOSC/[64(n+1)]
SYNC=BRG16=0,BRGH=1, formula FOSC/[16(n+1)]

in my program SYNC=0;BRG16=1;BRGH=1;

can i use this formula
SYNC=0;BRGH=BRG16=1, formula FOSC/[4(n+1)]
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…