Enabling USART interrupt sources makes only the first task start

adissida wrote on Monday, September 14, 2015:

But, when I have the USB cable from the FTDI chip to my computer connected, then it works, all tasks start.
Have I missed something?

This is my init of uart:

void trvInit_CLIUART( void )
{
volatile avr32_usart_t *usart = trvCLI_USART;
// CLI - USART1 INIT
static const gpio_map_t USART_GPIO_MAP =
{
{trvCLI_USART_RX_PIN, AVR32_USART1_RXD_0_0_FUNCTION},
{trvCLI_USART_TX_PIN, AVR32_USART1_TXD_0_0_FUNCTION}
};
static const usart_options_t USART_OPTIONS =
{
.baudrate = trvCLI_USART_BAUD,
.charlength = trvCLI_USART_CHAR_LENGTH,
.paritytype = USART_NO_PARITY,
.stopbits = USART_1_STOPBIT,
.channelmode = USART_NORMAL_CHMODE
};

trvUART_CLI_CREATE_QUEUES();

portENTER_CRITICAL();
{
	gpio_enable_module( USART_GPIO_MAP, sizeof(USART_GPIO_MAP) / sizeof(USART_GPIO_MAP[0]) );
	
	usart_init_rs232( trvCLI_USART, &USART_OPTIONS, F_CPU );
	
	// disable receiver and transmitter. */
	usart->cr |= AVR32_USART_CR_RXDIS_MASK | AVR32_USART_CR_TXDIS_MASK;
	
	trvUART_CLI_ISR_reg();
	
	/* Enable USART interrupt sources (but not Tx for now)... */
	usart->ier = AVR32_USART_IER_RXRDY_MASK;

	/* Enable receiver and transmitter... */
	usart->cr |= AVR32_USART_CR_TXEN_MASK | AVR32_USART_CR_RXEN_MASK;
}
portEXIT_CRITICAL();


trvCLI_ClearScreen();
//trvCLI_WriteLine( "Debug USART initiated\n\r" );

}

rtel wrote on Monday, September 14, 2015:

Sorry - I have no idea what you are trying to do, or what is wrong:
http://www.freertos.org/FAQ-how-to-use-the-FreeRTOS-support-forum.html

adissida wrote on Monday, September 14, 2015:

Im usign v8.2.2 of freeRTOS together with ATMEL UC3. Im using my own custom PCB, no demo board.
For CLI im using UART1 which is connected to a FTDI chip. I have also two tasks which is blinking two LEDs in different freq (just to see that it is alive). As long as I have the USB from FTDI chip connected to my computer, the two tasks is running, I get text on the console and so on… When I disconnect the USB for the console, only the first task starts. I then connect the FTDI USB to the computer and it is alive. I can also boot the board with USB from FTDI connected to computer, then disconnect it, and the two tasks is still running. So it has something to do with usart->ier = AVR32_USART_IER_RXRDY_MASK. When I delete that line in the code above, it always works (two LEDs blinking), with or without the USB from FTDI connected to the computer (but not the interrupt).

heinbali01 wrote on Monday, September 14, 2015:

Hi Adis,

I’m afraid that the information that you’re giving is still not enough to give some advice.
You are setting an RX-ready interrupt, and I presume that somewhere the code (the ISR) checks what interrupts have been enabled.
One of your tasks stops blinking the LED: it sounds like it stays in a blocking call for ever.
If I were you I would use a limited value for xBlockTime so you are able to show more information and/or to set breakpoints.

Please give more information or attach some sample source code if you like.

Regards.

adissida wrote on Monday, September 14, 2015:

Hi Hein

I think I found the problem. In my code in the first post, if I only enter this:
usart->cr = AVR32_USART_CR_TXEN_MASK;
To be said; im using external RAM. The init of the SDRAM and vPortDefineHeapRegions() is done after the UART init. So when I put the usart->cr = AVR32_USART_CR_RXEN_MASK; after the SDRAM init it works.

The strange thing is why did it work before with the USB cable connected to the computer.

heinbali01 wrote on Tuesday, September 15, 2015:

The strange thing is why did it work before with
the USB cable connected to the computer.

Maybe you board had somehow rebooted and therefore the SDRAM was still properly initialised?