Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

RX62N UART interrupt

Posted by EMT on November 6, 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 {
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,

RE: RX62N UART interrupt

Posted by MEdwards on November 6, 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.

RE: RX62N UART interrupt

Posted by Richard on November 6, 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

RE: RX62N UART interrupt

Posted by David Thedens on November 6, 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.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists