cancel
Showing results for 
Search instead for 
Did you mean: 

Re-arming UART Interrupt for STR750

mnguyen
Associate
Posted on September 25, 2008 at 07:22

Re-arming UART Interrupt for STR750

3 REPLIES 3
mnguyen
Associate
Posted on August 29, 2007 at 19:16

I am using the UART example #2 from ST library (750 family) to set up interrup routine for UART0. Basically, I just want to set it up so that the Fifo is disabled so that I can only receive 1 character per interrupt. The interrupt has to be re-armed indefinitely for many, many data to be received. One problem I encounter is the interrupt only happens once, even all the pending flags are cleared after reading the Fifo. It looks like to me that the UART_ClearITPendingBit routine supplied by ST library does not work at all.

This is how I setup UART0 in Main():

UART_InitStructure.UART_WordLength = UART_WordLength_8D;

UART_InitStructure.UART_StopBits = UART_StopBits_1;

UART_InitStructure.UART_Parity = UART_Parity_No ;

UART_InitStructure.UART_BaudRate = 9600;

UART_InitStructure.UART_HardwareFlowControl =

UART_HardwareFlowControl_None;

UART_InitStructure.UART_Mode = UART_Mode_Rx;

UART_InitStructure.UART_FIFO = UART_FIFO_Disable;

// Send command to configure UART0

UART_Init(UART0, &UART_InitStructure);

UART_LoopBackConfig(UART0,DISABLE);

/* Enable UART0 Receive interrupt */

UART_ITConfig(UART0, UART_IT_Receive, ENABLE);

// Configure and enable the interrupt controller

EIC_Configuration();

// Enable UART0

UART_Cmd(UART0, ENABLE);

This is the bulk of my interrupt routine:

if(UART_GetITStatus(UART0, UART_IT_Receive) != RESET)

{

Received_Char = UART_ReceiveData(UART0);

.....

// This recommended by ST but it does not re arm the interrupt

UART_ClearITPendingBit(UART0, UART_IT_Receive);

}

After a lot of reading and headache, i replace the UART_ClearITPendingBit call with

EIC->IPR |= 1 << UART0_IRQChannel;

at the end of my UART0_IRQHandler() to clear UART0 IT pending bit. This fix works for the first 30 characters, then there are no interrupts for another 30 seconds. Finally, after all these, the interrupt works again almost flawlessly. This last about 5 hours then the processor dies because its firmware is damaged. All I have to do is to reprogram the firmware again and things start working. The same thing happens a day later. This is such a weird thing that happen. I have used many processors and this one gives me such a doubt in its reliability.

I am looking for any help available since this is an important first project with the STR750 for me. I need a solution that is reliable and does not make me wait 30 seconds until the RS-232 data become available.

How do I re-arm UART0 interrupt again before exitting the interrupt routine?

If you can provide me an example for main() and UART0_IRQHandler() for this simple case, it would be so wonderful. I have asked ST but so far there is no reply.

Your help is so appreciated. PLEASE HELP. THANK YOU.

kaouther
Associate II
Posted on August 30, 2007 at 08:50

Hello,

There is no problem with the “UART_ClearITPendingBit “ routine. The correct procedure to clear the interrupt is to write 1 in the corresponding bit in “Interrupt Clear Register (UART_ICR)“ as done in the UART driver in STR75x library and . But “EIC->IPR |= 1 << UART0_IRQChannel; “ will clear the interrupt request of the channel which has not been served yet and you may loose interrupt.

A simple example of code can be tested on STR75x eval board ''MB469'' as Example 2 in STR75x library keep the same configuration of MRCC, GPIO and EIC as in the example and configuring the UART as follows;

=> /* UART0 configuration -------------------------------------------------------*/

/* UART0 configured as follow:

- Word Length = 8 Bits

- One Stop Bit

- Odd parity

- BaudRate = 9600 baud

- Hardware flow control disabled (RTS and CTS signals)

- Receive enabled

*/

UART_InitStructure.UART_WordLength = UART_WordLength_8D;

UART_InitStructure.UART_StopBits = UART_StopBits_1;

UART_InitStructure.UART_Parity = UART_Parity_No ;

UART_InitStructure.UART_BaudRate = 9600;

UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;

UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx;

UART_Init(UART0, &UART_InitStructure);

/* Enable the UART Receive interrupt */

UART_ITConfig(UART0, UART_IT_Receive, ENABLE);

/* Configure and enable the interrupt controller */

EIC_Configuration();

/* Enable the UART0: */

UART_Cmd(UART0, ENABLE)

And in the UART IRQ handler you get the charater recieved at each interrupt.

void UART0_IRQHandler(void)

{

if(UART_GetITStatus(UART0, UART_IT_Receive) != RESET)

{

RxBuffer[RxCounter++] = UART_ReceiveData(UART0);

/* Clear the UART0 Receive interrupt */

UART_ClearITPendingBit(UART0, UART_IT_Receive);

}

}

>>This last about 5 hours then the processor dies because its firmware is damaged. All I have to do is to reprogram the firmware again and things start working.

=> are you only using the UART simple code? which hardware used? is it on your own design or on STR75x eval board or any other?

Regards.

p_
Associate II
Posted on September 25, 2008 at 07:22

Hello,

i got a problem with this code and i hope somebody can help me out.

Like in the example i want an interrupt for every character received on the UART Rx.

Works well, but the problem is i only receive the frist char in the string.

I communicate with a GSM modul. So i send ''at\r'' to the GSM modul and it answers with ''at OK''.

So i expect 5 interrupts for each char. But in every of these 5 interrupts i only receive the char ''a''.

Does somebody know what the problem ist. My Code is similar to the one coucou wrote.

I am using the STR752 and i see on my oscilloscope that the GSM mdoul answers correct.

Thanks.

[ This message was edited by: p.diemer on 25-09-2008 10:53 ]

[ This message was edited by: p.diemer on 25-09-2008 10:59 ]