cancel
Showing results for 
Search instead for 
Did you mean: 

STR73x Uart interrupt receive (newbie)

mtessier2
Associate II
Posted on March 10, 2008 at 12:06

STR73x Uart interrupt receive (newbie)

4 REPLIES 4
mtessier2
Associate II
Posted on March 06, 2008 at 12:34

Hello,

I'm now trying to receive a 9600 baud using the interrupt. Can somebody can give me en example of initializations and ISR routine. My software do non woks and I want to compare !! So I'm using STR731 uart0.

Thanks

Martin

[ This message was edited by: mtessier on 06-03-2008 17:06 ]

norbert
Associate
Posted on March 07, 2008 at 17:14

I hope it will help

RS232_Baudrate = 9600;

// UART Configuration

UART_StructInit( &UART_InitStruct );

UART_InitStruct.UART_BaudRate = RS232_Baudrate;

UART_InitStruct.UART_Mode = UART_Mode_8D;

UART_InitStruct.UART_Loop_Standard = UART_Standard;

UART_InitStruct.UART_StopBits = UART_StopBits_1;

UART_InitStruct.UART_FIFO = UART_FIFO_Enable;

UART_InitStruct.UART_Rx = UART_Rx_Enable;

UART_Init( UART3, &UART_InitStruct );

UART_Cmd( UART3, ENABLE );

// FIFO Reset

UART_FifoReset (UART3 , UART_RxFIFO);

UART_FifoReset (UART3 , UART_TxFIFO);

EIC_IRQChannelPriorityConfig(UART3_IRQChannel, 2);

EIC_IRQChannelConfig(UART3_IRQChannel, ENABLE);

/* interrupt setzen

UART_IT_RxHalfFull

FIFO halb voll

UART_IT_TimeOutNotEmpty

FIFO hält noch Zeichen

UART_IT_OverrunError

UART_IT_FrameError

UART_IT_ParityError bei Fehler

*/

UART_ITConfig( UART3, UART_IT_RxHalfFull |

UART_IT_TimeOutNotEmpty |

UART_IT_OverrunError |

UART_IT_FrameError |

UART_IT_ParityError, ENABLE );

UART_ITConfig( UART3, UART_IT_TimeOutIdle |

UART_IT_TxHalfEmpty |

UART_IT_TxEmpty |

UART_IT_RxBufFull,

DISABLE );

void Event_UART3(void)

{

}

void UART3_IRQHandler (void)

{

Event_UART3();

}

mtessier2
Associate II
Posted on March 07, 2008 at 18:26

yes thanks, i will try that and compare ma code :)

mtessier2
Associate II
Posted on March 10, 2008 at 12:06

My software do not genrate interupt. When I test the Uart0 Rx in the main loop I'm able to turn off and On the Led on my harware when a receive a valid message fros hyperterminal. But when I activated the interupt thier is'nt notting works.

Here is my code :

Interupt initialisation :

void Init_Interupt(void)

{

CFG_PeripheralClockConfig(CFG_CLK_EIC, ENABLE);

EIC_DeInit();

EIC_StructInit(&EIC_InitStructure);

EIC_Init (&EIC_InitStructure);

EIC_IRQChannelPriorityConfig(UART0_IRQChannel, 2);

EIC_IRQChannelConfig(UART0_IRQChannel, ENABLE);

EIC_IRQCmd(ENABLE);

}

Uart initialisation :

void Init_Uart(void)

{

CFG_PeripheralClockConfig(CFG_CLK_UART0 , ENABLE);

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_InitStructure.GPIO_Pins = 0x0200 ;

GPIO_Init (GPIO6, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_TRI_TTL;

GPIO_InitStructure.GPIO_Pins = 0x0100 ;

GPIO_Init (GPIO6, &GPIO_InitStructure);

/* UART Configuration */

UART_StructInit(&UART_InitStruct);

UART_InitStruct.UART_BaudRate = 9600;

UART_InitStruct.UART_Mode = UART_Mode_8D ; Data + Parity */

UART_InitStruct.UART_Loop_Standard = UART_Standard; /*Disable LoopBack*/

UART_InitStruct.UART_StopBits = UART_StopBits_1; /* STOP bits number */

UART_InitStruct.UART_Rx = UART_Rx_Enable;

UART_InitStruct.UART_FIFO = UART_FIFO_Enable;

UART_Init(UART0, &UART_InitStruct); /*Configure Uart0*/

UART_Cmd(UART0, ENABLE);

UART_FifoReset (UART0 , UART_RxFIFO);

UART_FifoReset (UART0 , UART_TxFIFO);

UART_ITConfig( UART0, UART_IT_RxBufFull, ENABLE );

UART_ITConfig( UART0, UART_IT_TimeOutIdle |

UART_IT_TxHalfEmpty |

UART_IT_TxEmpty |

UART_IT_RxHalfFull,

DISABLE );

}

IEC :

void UART0_IRQHandler (void)

{

u8 RxData ;

RxData =UART_ByteReceive(UART0);

switch(RxData)

{

case 0x50:

GPIO_BitWrite(Led, Bit_RESET);

break;

case 0x51:

GPIO_BitWrite(Led, Bit_SET);

break;

}

}

Main loop :

int main(void)

Init_GPIO();

Init_Uart();

Init_Interupt();

While(1)

{

// Test Uart0 without UART0_IRQHandler enable

/*

if (UART_Flag_RxBufFull)

{

RxData =UART_ByteReceive(UART0);

switch(RxData)

{

case 0x50:

GPIO_BitWrite(Led, Bit_RESET);

break;

case 0x51:

GPIO_BitWrite(Led, Bit_SET);

break;

}

}

*/

}

Thanks alot for your help

Maritn