RX62N UART interrupt

esswme123 wrote on Tuesday, November 06, 2012:

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) 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):
        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)
{
     while (sci2_txi_flag == 0);   // This is where the program gets stuck when I run it. I have also tried replacing this with IR(SCI2, TXI2) == 0

      SCI2.TDR = data;
}

The third function is the send string function:

void transmit_string(unsigned const char *data, short dataSize)
{
      short i = 0;

     for(i = 0; i<dataSize; i++)
      {
           transmit_data(data_);
      }
}

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,_

edwards3 wrote on Tuesday, November 06, 2012:

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.

travfrog wrote on Tuesday, November 06, 2012:

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

boscodog wrote on Tuesday, November 06, 2012:

I do not see where you are setting SCR.RE and SCR.TE
are the UART transmitter and receiver enabled elsewhere?  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.