# How to use serial Interrupt

**URL:** <https://forums.digi.com/t/how-to-use-serial-interrupt/4881>\
**Category:** NET+OS\
**Tags:** hardware\
**Created:** [January 22, 2010, 12:06pm UTC](https://forums.digi.com/t/how-to-use-serial-interrupt/4881 "2010-01-22T12:06:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alvaro\_Meneses](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alvaro\_Meneses](https://forums.digi.com/u/Alvaro_Meneses)\
**Post date:** [January 22, 2010, 12:06pm UTC](https://forums.digi.com/t/how-to-use-serial-interrupt/4881/1 "2010-01-22T12:06:00Z")

</div>

Hello everybody.  
I need to use the serial port directly, using my own code and receive data by interrupt process.  
I wrote the next code but it does not work.  
I can see the incoming data and the UART status register change but the interrupt does not work.

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
This is the Interrupt service Routine  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
int ISR\_A5\_RX (void \*isrParameter)  
{  
short data;  
data=serial-\>data\_reg;

```
    serial-&gt;status_a|=0x80000200;

return 0;

```

}

void init\_serial(void)  
{  
serial= MERCURY\_REGS\_1;  
serial-\>ctrl\_a=0x0B000A00;//0x3B000A00; 8 bit 1stp parity Odd  
serial-\>bit\_rate\_reg=0xC014017F;//x16 a 2400bps (FCLK=14.745.600)  
serial-\>ctrl\_b=0x04000000;  
serial-\>ctrl\_a|=0x80000200;//Starts UART

}  
/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
MAIN  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
void applicationStart (void)

{  
int num,i;  
naIsrInstall(SER2RX\_INTERRUPT, ISR\_A5\_RX, NULL);  
init\_serial();  
naInterruptEnable(SER2RX\_INTERRUPT);  
tx\_interrupt\_control(TX\_INT\_ENABLE);  
while(1)  
{  
num=0;  
for(i=0;i\<200;i++)  
num++;  
}  
tx\_thread\_suspend(tx\_thread\_identify());  
}

Any suggestions would be appreciated.

---

<div class="post-metadata">

**Author:** ![Alvaro\_Meneses](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alvaro\_Meneses](https://forums.digi.com/u/Alvaro_Meneses)\
**Post date:** [January 22, 2010, 1:28pm UTC](https://forums.digi.com/t/how-to-use-serial-interrupt/4881/2 "2010-01-22T13:28:25Z")

</div>

I`m sorry but the information about the interrupt ID it is not clear, I use the SER1RX\_INTERRUPT and it worked.

---

<div class="post-metadata">

**Author:** ![Alvaro\_Meneses](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alvaro\_Meneses](https://forums.digi.com/u/Alvaro_Meneses)\
**Post date:** [January 22, 2010, 1:40pm UTC](https://forums.digi.com/t/how-to-use-serial-interrupt/4881/3 "2010-01-22T13:40:26Z")

</div>

aps, remember to disable the command line interface, It uses the PORTB (SER1).
