Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

RS-485 UART help please

Status
Not open for further replies.

haxan

New Member
Hi,

I have done RS-485 based UART communication on Atmel 8051 but am not able to do so well in PIC18F4480. The problems i am facing are:

1. I am not able to understand the interrupt handler for Rx.
2. How to send address byte (Which register to modify).
3. How to check if the node was found on BUS.

In 8051, there is a bit TB8 which when set means address bit is received.
And to check if the Node was found, i used to check the bit SM2.

Can please someone tell me which are the register bits in PIC18F.
 
How to set Baud rate in PIC18 in C language?

also, even though i am clearing the Interrupt Flag but somehow it keeps on going in the interrupt over and over again.

Here is my code so far.

/* ~~~~ Interrupt Handler ~~~~ */
void rx_handler (void);
#pragma code rx_interrupt = 0x8
void rx_int (void)
{
_asm goto rx_handler _endasm
}
#pragma code
#pragma interrupt rx_handler
void rx_handler (void)
{
PORTBbits.RB5 = ~PORTBbits.RB5;
PIR1bits.RCIF = 0; // Clear Receive Interrupt Flag
}

void main(void)
{
TRISC = 0b11000000;

OpenUSART (
USART_TX_INT_OFF &
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_NINE_BIT &
USART_CONT_RX &
USART_BRGH_HIGH, 103
);

RCONbits.IPEN = 1; /* Make receive interrupt high priority */
IPR1bits.RCIP = 1; /* Enable all high priority interrupts */
INTCONbits.GIEH = 1;
while(1);
}
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top