# RX62N UART interrupt

**URL:** <https://forums.freertos.org/t/rx62n-uart-interrupt/4674>\
**Category:** Kernel\
**Created:** [November 6, 2012, 3:34pm UTC](https://forums.freertos.org/t/rx62n-uart-interrupt/4674 "2012-11-06T15:34:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 6, 2012, 3:34pm UTC](https://forums.freertos.org/t/rx62n-uart-interrupt/4674/1 "2012-11-06T15:34:44Z")

</div>

**[esswme123](https://sourceforge.net/u/esswme123/)** wrote on [Tuesday, November 06, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/cc65ff9d/#29f7):

Hey guys, I’'m new to freeRTOS so I’m still discovering my footsteps with it :). I’ve used the RX62N demo with uIP ([http://www.freertos.org/FreeRTOS\_RX62N\_GCC\_GNURX.html)](http://www.freertos.org/FreeRTOS_RX62N_GCC_GNURX.html%29) and was trying to do a simple modification: to make the system send a small message (“Hello”) via the serial port each time I press the UpdateIO button in page “io.shtml”.

My problem is that it’s not working :(. My code is as follows:  
I have created a new file called UARTDriver.c where I have created 3 functions. The first is the init function, and I’ve written the following (It’s called in the main function):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int i = 0;  
MSTP(SCI2) = 0;  
IOPORT.PFFSCI.BIT.SCI2S = 1;

SCI2.SCR.BYTE = 0;

PORT5.DDR.BIT.B2 = 0;  
PORT5.ICR.BIT.B2 = 1;  
PORT5.DDR.BIT.B3 = 1;

SCI2.SMR.BYTE = 0X00;  
SCI2.SCR.BIT.RIE = 1;  
SCI2.SCR.BIT.TIE = 1;  
IPR(SCI2, RXI2) = 1;  
IPR(SCI2, TXI2) = 1;  
IEN(SCI2, RXI2) = 1;  
IEN(SCI2, TXI2) = 1;

SCI2.BRR = 80;  
SCI2.SCR.BIT.TEIE=1;  
for(i = 0; i \< 1000; i++)  
{  
asm(“nop”);  
}

The second function is the send character function function, and is only used by the third function:

void transmit\_data(unsigned char data)  
{  
&nbsp;&nbsp;&nbsp;&nbsp; while (sci2\_txi\_flag == 0);&nbsp;&nbsp; // This is where the program gets stuck when I run it. I have also tried replacing this with IR(SCI2, TXI2) == 0

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SCI2.TDR = data;  
}

The third function is the send string function:

void transmit\_string(unsigned const char \*data, short dataSize)  
{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; short i = 0;

&nbsp;&nbsp;&nbsp;&nbsp; for(i = 0; i\<dataSize; i++)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transmit\_data(data\_);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
}

Now, when I call the function transmit\_string() from within the function “generate\_io\_state()” in file “httpd-cgi.c”, the whole stack hangs (Even the LEDs stop playing). When I stop the debugger I find the OS stuck in an infinite loop in a function named “vApplicationMallocFailedHook()”. I have tried to put my code in the predefined ISR vectors “void INT\_Excep\_SCI2\_TXI2(void) \_\_attribute\_\_ ((interrupt))” in file “inthandler.c”, but it didn’t work… the ISR is never called from the first place. Any help would be greatly appreciated as I have no clue about how to get around this problem.

Thanks a lot,\_

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 6, 2012, 5:02pm UTC](https://forums.freertos.org/t/rx62n-uart-interrupt/4674/2 "2012-11-06T17:02:41Z")

</div>

**[edwards3](https://sourceforge.net/u/edwards3/)** wrote on [Tuesday, November 06, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/cc65ff9d/#5ee3):

All this chip configuration stuff is not FreeRTOS related so the driver can be created outside of a FreeRTOS project unless it is using FreeRTOS services. I would suggest getting your UART output to work in a simple hello world project first, and when you know it is working try adding it back into your application.  
I don’t know where you got the UART code from, but if you want to check it for correctness then Renesas provide a peripheral driver library for the 62N. Search their website for RPDL to find it because it is not obvious.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 6, 2012, 5:38pm UTC](https://forums.freertos.org/t/rx62n-uart-interrupt/4674/3 "2012-11-06T17:38:44Z")

</div>

**[travfrog](https://sourceforge.net/u/travfrog/)** wrote on [Tuesday, November 06, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/cc65ff9d/#9e0e):

Hi esswme123,

If the debugger stops in “vApplicationMallocFailedHook()” then you have not provided enough heap for the RTOS in FreeRTOSCOnfig.h. Nothing will execute if the malloc fails.

Hope this helps.  
Regards

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 6, 2012, 6:24pm UTC](https://forums.freertos.org/t/rx62n-uart-interrupt/4674/4 "2012-11-06T18:24:09Z")

</div>

**[boscodog](https://sourceforge.net/u/boscodog/)** wrote on [Tuesday, November 06, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/cc65ff9d/#ae5b):

I do not see where you are setting SCR.RE and SCR.TE  
are the UART transmitter and receiver enabled elsewhere?&nbsp; Otherwise no TX or RX.  
remember to OR in these bits together.

Note 2. A 1 can be written only when TE = 0 and RE = 0. After setting TE or RE to 1, only 0 can be written in TE and RE.
