Showing results for 
Search instead for 
Did you mean: 
Registered: ‎11-01-2018

Trouble w/ Zynq 7010 UART Interrupts using BSP has me going in circles.

Host Operating System: Centos7 x86_64
Vivado Version 2018.3 (64bit)
Xilinx SDK 2018.3

I've configured the Zynq 7010 ARM CortexTM-A9 MPCoreTM based processing system for bare metal operation. UART1 is instantiated and I'm using the BSP specifically "xuartps.h/.c" for implementing my application software.

I have referred to the example application provided by Xilinx concerning the use of UART interrupts. You will see this as my code below reflects it. I've been experiencing difficulty and confustion on several key concepts related to UART interrupts that I will address next.

After referring to the user guide I'm still confused on the difference between the TX & RX FIFO and the shift registers. My understanding is that there are two 64 "byte" FIFO's (one for TX and one for RX) and 32 "bit" shift registers (one for TX and one for RX). The 32 "bit" shift registers are located inside the transmitter and receiver module. Is my understanding correct up to this point?

I'm confused on the handler I wrote as you see below. I'm use to using a predefined ISR function that I bring into context. However, with this A9 I guess I'm suppose to register a handler which is like a ISR?!?! Furthermore, in this handler below there are Event's and EventData parameters passed in. Guess I don't understand where they come from and also how these macros (XUARTPS_EVENT_SENT_DATA, XUARTPS_EVENT_RECV_DATA, etc...) map to a interrupt. For example, none of those macros map to a RX triggered interrupt and if so how?


I have took it upon myself to utilize the TIMEOUT featured interrupt in accomplishing my task above. However, it doesn't work and I believe I've misunderstood a few crucial aspects which I've pointed out above. Could you provide some clarification to my two questions above and enlighten me on what I may be doing wrong below?

#include <stdio.h>
#include "telemetry.h"
#include "commands.h"
#include "platform.h"
#include "xil_printf.h"
#include "xparameters.h"
#include "xuartps.h"
#include "xscugic.h"
#include "xil_exception.h"

// Globals
XUartPs UartDrvInstance;
XScuGic GicDrvInstance;

// Interrupt Handlers
void UartHandler( void *CallBackRef, uint32_t Event, uint32_t EventData );

int main() { init_platform(); uint8_t buffer[10] = {0};
/* Init Uart */ XUartPs_Config* UartConfig; UartConfig = XUartPs_LookupConfig( XPAR_XUARTPS_0_DEVICE_ID ); XUartPs_CfgInitialize( &UartDrvInstance, UartConfig, UartConfig->BaseAddress ); XUartPs_SetBaudRate( &UartDrvInstance, 115200 ); /* Configure Interrupt Controller */ XScuGic_Config* GicConfig; GicConfig = XScuGic_LookupConfig( XPAR_SCUGIC_SINGLE_DEVICE_ID ); XScuGic_CfgInitialize( &GicDrvInstance, GicConfig, GicConfig->CpuBaseAddress ); Xil_ExceptionRegisterHandler( XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler) XScuGic_InterruptHandler, &GicDrvInstance ); XScuGic_Connect( &GicDrvInstance, XPAR_XUARTPS_1_INTR, (Xil_ExceptionHandler) XUartPs_InterruptHandler, (void *)&UartDrvInstance ); XScuGic_Enable( &GicDrvInstance, XPAR_XUARTPS_1_INTR ); Xil_ExceptionEnable(); /* Set the handler */ XUartPs_SetHandler( &UartDrvInstance, (XUartPs_Handler)UartHandler, &UartDrvInstance ); /* Set the uart interrupts */ uint32_t interruptMask = 0; interruptMask = XUARTPS_IXR_RXFULL|XUARTPS_IXR_TOUT|XUARTPS_IXR_RXOVR ; XUartPs_SetInterruptMask(&UartDrvInstance, interruptMask);
XUartPs_SetOperMode(&UartDrvInstance, XUARTPS_OPER_MODE_NORMAL); XUartPs_SetRecvTimeout(&UartDrvInstance, 8); uint32_t i = 0; while(1) { if ( tout_happened == 1 ) { XUartPs_Recv( &UartDrvInstance, (uint8_t*)&buffer[0], sizeof(buffer) ); tout_happened = 0; } } cleanup_platform(); return 0; } //------------------------------------------------------------------------------ // Interrupt Handlers //------------------------------------------------------------------------------ void UartHandler( void *CallBackRef, uint32_t Event, uint32_t EventData ) { /* All of the data has been sent */ if (Event == XUARTPS_EVENT_SENT_DATA) { } /* All of the data has been received */ if (Event == XUARTPS_EVENT_RECV_DATA) { } /* * Data was received, but not the expected number of bytes, a * timeout just indicates the data stopped for 8 character times */ if (Event == XUARTPS_EVENT_RECV_TOUT) { tout_happened = 1; } /* * Data was received with an error, keep the data but determine * what kind of errors occurred */ if (Event == XUARTPS_EVENT_RECV_ERROR) { } /* * Data was received with an parity or frame or break error, keep the data * but determine what kind of errors occurred. Specific to Zynq Ultrascale+ * MP. */ if (Event == XUARTPS_EVENT_PARE_FRAME_BRKE) { } /* * Data was received with an overrun error, keep the data but determine * what kind of errors occurred. Specific to Zynq Ultrascale+ MP. */ if (Event == XUARTPS_EVENT_RECV_ORERR) { } }



0 Kudos