element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Software Application Development UART Interrupt does not work
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 1 reply
  • Subscribers 328 subscribers
  • Views 1096 views
  • Users 0 members are here
Related

UART Interrupt does not work

fayyazrafiq
fayyazrafiq over 12 years ago

Dear All,

I want to use UART interrupt. I get an application code from the Xilinx Examples and somehow modified it but it does not work. The below is my complete code for the UART interrupt. Please help me, I wanted to do it asap. Any help is highly appreciated.  

void Handler(void *CallBackRef, u32 Event, unsigned int EventData)
{

t//portBASE_TYPE xHigherPriorityTaskWoken=pdFALSE;
t/*
t * All of the data has been received
t */
tif (Event == XUARTPS_EVENT_RECV_DATA)
t{
ttXUartPs_Recv(&UartPs, RecvBuffer,1);
tt//int a;
tt//for(a=0;a<8;a++)
tt//{
tttRxBuffer[RxIndex]=RecvBuffer[0];
tttRxCounter++;
tttRxIndex = RxCounter % RXBUFFERSIZE;
tt//}


t// xSemaphoreGiveFromISR(amftDataReceivedSemaphore, &xHigherPriorityTaskWoken);
t XUartPs_SetInterruptMask(&UartPs, XUARTPS_IXR_RXFULL );
t}
}
//************************************************

int UartPsIntrExample(XScuGic *IntcInstPtr, XUartPs *UartInstPtr,
tttu16 DeviceId, u16 UartIntrId)
{
tint Status;
tXUartPs_Config *Config;
t//int Index;
tu32 IntrMask;
t//int BadByteCount = 0;

t/*
t * Initialize the UART driver so that it's ready to use
t * Look up the configuration in the config table, then initialize it.
t */
tConfig = XUartPs_LookupConfig(DeviceId);
tif (NULL == Config) {
t#ifdef print_status
ttxil_printf("UART Lookup Failed
r");
t#endif
ttreturn XST_FAILURE;
t}

tStatus = XUartPs_CfgInitialize(UartInstPtr, Config, Config->BaseAddress);
tif (Status != XST_SUCCESS) {
t#ifdef print_status
ttxil_printf("UART Configuration Failed
r");
t#endif
ttreturn XST_FAILURE;
t}

t/*
t * Check hardware build
t */
t//Status = XUartPs_SelfTest(UartInstPtr);
t//if (Status != XST_SUCCESS) {
t//txil_printf("SelfTest Failed
r");
t//treturn XST_FAILURE;
t//}

t/*
t * Connect the UART to the interrupt subsystem such that interrupts
t * can occur. This function is application specific.
t */
tStatus = SetupInterruptSystem(IntcInstPtr, UartInstPtr, UartIntrId);
tif (Status != XST_SUCCESS) {
t#ifdef print_status
ttxil_printf("Setup Interrupt System failed
r");
t#endif

ttreturn XST_FAILURE;
t}

t/*
t * Setup the handlers for the UART that will be called from the
t * interrupt context when data has been sent and received, specify
t * a pointer to the UART driver instance as the callback reference
t * so the handlers are able to access the instance data
t */
tXUartPs_SetHandler(UartInstPtr, Handler, UartInstPtr);

t/*
t * Enable the interrupt of the UART so interrupts will occur, setup
t * a local loopback so data that is sent will be received.
t */
tIntrMask = XUARTPS_IXR_RXFULL;
tXUartPs_SetInterruptMask(UartInstPtr, IntrMask);

tXUartPs_SetOperMode(UartInstPtr, XUARTPS_OPER_MODE_NORMAL);

t/*
t * Set the receiver timeout. If it is not set, and the last few bytes
t * of data do not trigger the over-water or full interrupt, the bytes
t * will not be received. By default it is disabled.
t *
t * The setting of 2 will timeout after 2 x 4 = 8 character times.
t * Increase the time out value if baud rate is high, decrease it if
t * baud rate is low.
t */
tXUartPs_SetRecvTimeout(UartInstPtr, 2);

    #ifdef print_status
ttxil_printf("Exit from UART Interrupt Setup
r");
t#endif



treturn XST_SUCCESS;
}

/*****************************************************************************/
/**
*
* This function sets up the interrupt system so interrupts can occur for the
* Uart. This function is application-specific. The user should modify this
* function to fit the application.
*
* @paramtIntcInstancePtr is a pointer to the instance of the INTC.
* @paramtUartInstancePtr contains a pointer to the instance of the UART
*ttdriver which is going to be connected to the interrupt
*ttcontroller.
* @paramtUartIntrId is the interrupt Id and is typically
*ttXPAR_<UARTPS_instance>_INTR value from xparameters.h.
*
* @returntXST_SUCCESS if successful, otherwise XST_FAILURE.
*
* @notettNone.
*
****************************************************************************/
int SetupInterruptSystem(XScuGic *IntcInstancePtr,
ttttXUartPs *UartInstancePtr,
ttttu16 UartIntrId)
{
tint Status;


tXScuGic_Config *IntcConfig; /* Config for interrupt controller */

t/*
t * Initialize the interrupt controller driver
t */
tIntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
tif (NULL == IntcConfig) {
t#ifdef print_status
ttxil_printf("Interrupt Controller Lookup Failed
r");
t#endif
ttreturn XST_FAILURE;
t}

tStatus = XScuGic_CfgInitialize(IntcInstancePtr, IntcConfig,
tttttIntcConfig->CpuBaseAddress);
tif (Status != XST_SUCCESS) {
t#ifdef print_status
ttxil_printf("Interrupt Controller Configuartion Failed
r");
t#endif
ttreturn XST_FAILURE;
t}

t/*
t * Connect the interrupt controller interrupt handler to the
t * hardware interrupt handling logic in the processor.
t */
tXil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
tttt(Xil_ExceptionHandler) XScuGic_InterruptHandler,
ttttIntcInstancePtr);


t/*
t * Connect a device driver handler that will be called when an
t * interrupt for the device occurs, the device driver handler
t * performs the specific interrupt processing for the device
t */
tStatus = XScuGic_Connect(IntcInstancePtr, UartIntrId,
tttt  (Xil_ExceptionHandler) XUartPs_InterruptHandler,
tttt  (void *) UartInstancePtr);
tif (Status != XST_SUCCESS) {
t#ifdef print_status
ttxil_printf("Interrupt Controller Connect Failed
r");
t#endif
ttreturn XST_FAILURE;
t}

t/*
t * Enable the interrupt for the device
t */
tXScuGic_Enable(IntcInstancePtr, UartIntrId);


#ifndef TESTAPP_GEN
t/*
t * Enable interrupts
t */
t Xil_ExceptionEnable();
#endif

treturn XST_SUCCESS;
}

  • Sign in to reply
  • Cancel
  • Former Member
    0 Former Member over 11 years ago

    I have the same problem could anyone solved it?
    or any other way how to make uart interrupt?
    sorry for my English

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube