Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] UART in PIC18F4431

Status
Not open for further replies.

Ahmed.Soliman

Junior Member level 1
Joined
Oct 22, 2010
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,434
Hello guys,
I need some help configuring USART module for Asynchronous reception 9600 bps in a PIC18F4431 running at 4Mhz .
I use XC8 compiler and I read the Peripherals support document included with the compiler.
Here is my current configuring code :
Code:
void USART_Init()
{
    unsigned char config,baudconfig;
    TRISCbits.RC6 = 1;
    TRISCbits.RC7 = 1;
    CloseUSART();
    config = USART_TX_INT_OFF | USART_RX_INT_OFF | USART_ASYNCH_MODE | USART_EIGHT_BIT | USART_CONT_RX |   
                  USART_BRGH_HIGH;
    baudconfig = BAUD_IDLE_RX_PIN_STATE_HIGH | BAUD_8_BIT_RATE |BAUD_AUTO_OFF | BAUD_WAKEUP_OFF;
    baudUSART(baudconfig);
    OpenUSART(config,25);
}

I need to receive 13 bytes so I use :

getsUSART(buff,BUFFER_SIZE);

where buff is declared as a char buff [13]


I really don't know where I'm wrong ! but I'm about to give it up ! so please help me
Thanks in advance
 

I solved the problem, I should have used
Code:
config = USART_TX_INT_OFF | USART_RX_INT_OFF | USART_ASYNCH_MODE | USART_EIGHT_BIT | USART_CONT_RX |   
                  USART_BRGH_HIGH;
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top