This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

uart interrupt str9

hi all,
I want to make a interrupt driven uart for str9 inwhich when it recieves a character it should jump to recieve interrupt handler where i will process somethinh to the character and then it should return to main programme mythis code does not come out from handler please help

#include "91x_lib.h"

#include "stdio.h"
#include <91x_lib.h>
#include <string.h>
#include <limits.h>
//#include "sio.h"

UART_InitTypeDef UART_InitStructure;
 static void Delay(u32 nCount)
{
  u32 j = 0;

  for(j = nCount; j != 0; j--);
}

void main(void)
{
        GPIO_InitTypeDef GPIO_InitStructure;
        UART_InitTypeDef UART_InitStructure;
        SCU_APBPeriphClockConfig(__UART0, ENABLE);
        SCU_APBPeriphClockConfig(__GPIO5, ENABLE);
        GPIO_DeInit(GPIO5);
        GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
        GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;
        GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;
        GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1  ;
        GPIO_Init (GPIO5, &GPIO_InitStructure);
        GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
        GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;
        GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3  ;
        GPIO_Init (GPIO5, &GPIO_InitStructure);
        UART_DeInit(UART0);
        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 = 115200;
        UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;
        UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx;
        UART_InitStructure.UART_FIFO = UART_FIFO_Disable;
        UART_Init(UART0, &UART_InitStructure);
        UART_Cmd(UART0, ENABLE);
        UART_ITConfig(UART0, UART_IT_Receive, ENABLE);
        SCU_AHBPeriphClockConfig(__VIC,ENABLE);
        SCU_AHBPeriphReset(__VIC,DISABLE);
        VIC_DeInit();
        VIC_Config(UART0_ITLine, VIC_IRQ, 0);
        VIC_ITCmd(UART0_ITLine, ENABLE);
        UART_Cmd(UART0, ENABLE);

         while(1)
        {

         }

  }


int SendChar (int ch)
{
        UART_SendData(UART0, ch);
   UART_ITConfig(UART0, UART_IT_Transmit,DISABLE);
        while(UART_GetFlagStatus(UART0, UART_IT_Transmit) !=RESET);
        return (ch);
}

int GetKey (void)
{  while ((UART0->FR & 0x10));                      /* RX Fifo Empty */
  return (UART0->DR);
}



/*
void UART0_IRQHandler(void)
{   unsigned char ch;

        if(UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty) != SET)
    {
          ch = UART0->DR;
          printf("%c",ch);
           VIC1->VAR=0x00;

    }

         // printf("4");
          //printf("5");

}

 */

void UART0_IRQHandler(void)
{        unsigned char ch;
  while (UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty) != SET) {
     {
      UART0->ICR = UART_IT_Receive;      /* clear the interrupt*/
           ch = UART0->DR;
          printf("%c",ch);
       VIC1->VAR = 0;

    }
           VIC1->VAR = 0;
  }

  VIC1->VAR = 0;                        /* Acknowledge Interrupt*/

}

0