2008-03-10 04:06 AM
STR73x Uart interrupt receive (newbie)
2008-03-06 03:34 AM
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 ]2008-03-07 08:14 AM
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(); }2008-03-07 09:26 AM
yes thanks, i will try that and compare ma code :)
2008-03-10 04:06 AM
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