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