UART2 + BV101 September 10, 2012 01:26PM |
Registered: 12 years ago Posts: 11 |
Re: UART2 + BV101 September 10, 2012 02:51PM |
Admin Registered: 12 years ago Posts: 351 |
Re: UART2 + BV101 September 13, 2012 01:20AM |
Registered: 12 years ago Posts: 11 |
Re: UART2 + BV101 September 13, 2012 07:18AM |
Admin Registered: 12 years ago Posts: 351 |
Re: UART2 + BV101 September 13, 2012 09:00AM |
Registered: 12 years ago Posts: 11 |
Re: UART2 + BV101 September 13, 2012 09:10AM |
Admin Registered: 12 years ago Posts: 351 |
// =================== S E R I A L ================================== // simple serial communication on com port 2, no handshaking or // buffering // ****************************************************************** // Open com port 2 // NOTE when using printf, the output is not sent until \n so: // printf("\nHello"); DOES NOT WORK but // printf("Hello\n"); does work // ****************************************************************** void openIO(int baudRate, unsigned int mode) { // Open UART2 with Receive and Transmitter enable. U2BRG=(PBCLK/(4*baudRate))-1; U2MODE=0X8808+mode; U2STA=0X1400; } // ****************************************************************** // Low level char needed for xmodem, putchar() c function not // working quite rigt yet // ****************************************************************** void b_putc(unsigned char c) { while( U2STAbits.UTXBF); // wait U2TXREG=c; } //------------------------------------------------------------- unsigned char b_getc() { if(U2STAbits.OERR) { // overun error must be cleared U2STAbits.OERR=0; return 0; } while(!U2STAbits.URXDA); // wait for char return U2RXREG; }
Re: UART2 + BV101 September 25, 2012 09:43AM |
Registered: 12 years ago Posts: 11 |
Re: UART2 + BV101 September 25, 2012 04:26PM |
Admin Registered: 12 years ago Posts: 351 |
Re: UART2 + BV101 September 25, 2012 05:42PM |
Registered: 12 years ago Posts: 11 |