• Content Count

  • Joined

  • Last visited

About vishav

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi, I have to design a counter IP which measures the number of positive edges on a signal. I was following the tutorial from digilent which is given on this link: The tutorial mentions the user logic as given below. The Verilog code for my counter is also similar. But instead, I want to store the value of counter. I tried to write the counter value in slv_reg0 but unfortunately Vivado does not allow it. How can I access this counter value in my SDK? if anyone has solved this problem before, please let me know. // Add user logic here reg [15:0] counter = 0; //simple counter always @(posedge S_AXI_ACLK) begin if(counter < PWM_COUNTER_MAX-1) counter <= counter + 1; else counter <= 0; end //comparator statements that drive the PWM signal assign PWM0 = slv_reg0 < counter ? 1'b0 : 1'b1; assign PWM1 = slv_reg1 < counter ? 1'b0 : 1'b1; assign PWM2 = slv_reg2 < counter ? 1'b0 : 1'b1; assign PWM3 = slv_reg3 < counter ? 1'b0 : 1'b1; // User logic ends
  2. I just figured it out. I forgot to program FPGA after I made changes in hardware design in Vivado.
  3. Hi, I want to use a GPIO and Timer Interrupt in my project. To implement it, I saw an example code, which is attached here. However, while debugging I see that my timer is not being initialized(status = XTmrCtr_Initialize(&TMRInst, TMR_DEVICE_ID);. It calls Data Abort Interrupt. The code is nearly the same as given on the following link: For Reference, my code is as follows. Also, find attached my hardware design, address editor and timer settings window. Any suggestions/help would be appreciated. /* * main.c * * Created on: 23.06.2018 * Author: vishavbansal */ #include "xparameters.h" #include "xgpio.h" #include "xtmrctr.h" #include "xscugic.h" #include "xil_exception.h" #include "xil_printf.h" // Parameter definitions #define INTC_DEVICE_ID XPAR_PS7_SCUGIC_0_DEVICE_ID #define TMR_DEVICE_ID XPAR_TMRCTR_0_DEVICE_ID #define BTNS_DEVICE_ID XPAR_AXI_GPIO_0_DEVICE_ID #define LEDS_DEVICE_ID XPAR_AXI_GPIO_1_DEVICE_ID #define INTC_GPIO_INTERRUPT_ID XPAR_FABRIC_AXI_GPIO_0_IP2INTC_IRPT_INTR #define INTC_TMR_INTERRUPT_ID XPAR_FABRIC_AXI_TIMER_0_INTERRUPT_INTR #define BTN_INT XGPIO_IR_CH1_MASK #define TMR_LOAD 0xFFFE7961 XGpio LEDInst, BTNInst; XScuGic INTCInst; XTmrCtr TMRInst; static int led_data; static int btn_value; static int tmr_count; //---------------------------------------------------- // PROTOTYPE FUNCTIONS //---------------------------------------------------- static void BTN_Intr_Handler(void *baseaddr_p); static void TMR_Intr_Handler(void *baseaddr_p); static int InterruptSystemSetup(XScuGic *XScuGicInstancePtr); static int IntcInitFunction(u16 DeviceId, XTmrCtr *TmrInstancePtr, XGpio *GpioInstancePtr); //---------------------------------------------------- // INTERRUPT HANDLER FUNCTIONS // - called by the timer, button interrupt, performs // - LED flashing //---------------------------------------------------- void BTN_Intr_Handler(void *InstancePtr) { // Disable GPIO interrupts XGpio_InterruptDisable(&BTNInst, BTN_INT); // Ignore additional button presses if ((XGpio_InterruptGetStatus(&BTNInst) & BTN_INT) != BTN_INT) { return; } btn_value = XGpio_DiscreteRead(&BTNInst, 1); // Increment counter based on button value // Reset if centre button pressed if(btn_value != 1) led_data = led_data + btn_value; else led_data = 0; XGpio_DiscreteWrite(&LEDInst, 1, led_data); (void)XGpio_InterruptClear(&BTNInst, BTN_INT); // Enable GPIO interrupts XGpio_InterruptEnable(&BTNInst, BTN_INT); } void TMR_Intr_Handler(void *data) { if (XTmrCtr_IsExpired(&TMRInst,0)){ XTmrCtr_Stop(&TMRInst,0); // Once timer has expired 3 times, stop, increment counter // reset timer and start running again //if(tmr_count == 3){ // tmr_count = 0; led_data++; XGpio_DiscreteWrite(&LEDInst, 1, led_data); //} //else tmr_count++; XTmrCtr_Reset(&TMRInst,0); XTmrCtr_Start(&TMRInst,0); } } //---------------------------------------------------- // MAIN FUNCTION //---------------------------------------------------- int main (void) { int status; //---------------------------------------------------- // INITIALIZE THE PERIPHERALS & SET DIRECTIONS OF GPIO //---------------------------------------------------- // Initialise LEDs status = XGpio_Initialize(&LEDInst, LEDS_DEVICE_ID); if(status != XST_SUCCESS) return XST_FAILURE; // Initialise Push Buttons status = XGpio_Initialize(&BTNInst, BTNS_DEVICE_ID); if(status != XST_SUCCESS) return XST_FAILURE; // Set LEDs direction to outputs XGpio_SetDataDirection(&LEDInst, 1, 0x00); // Set all buttons direction to inputs XGpio_SetDataDirection(&BTNInst, 1, 0xFF); //---------------------------------------------------- // SETUP THE TIMER //---------------------------------------------------- status = XTmrCtr_Initialize(&TMRInst, TMR_DEVICE_ID); if(status != XST_SUCCESS) return XST_FAILURE; XTmrCtr_SetHandler(&TMRInst, TMR_Intr_Handler, &TMRInst); XTmrCtr_SetResetValue(&TMRInst, 0, TMR_LOAD); XTmrCtr_SetOptions(&TMRInst, 0, XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION | XTC_EXT_COMPARE_OPTION); //XTC_INT_MODE_OPTION // Initialize interrupt controller status = IntcInitFunction(INTC_DEVICE_ID, &TMRInst, &BTNInst); if(status != XST_SUCCESS) return XST_FAILURE; XTmrCtr_Start(&TMRInst, 0); while(1); return 0; } //---------------------------------------------------- // INITIAL SETUP FUNCTIONS //---------------------------------------------------- int InterruptSystemSetup(XScuGic *XScuGicInstancePtr) { // Enable interrupt XGpio_InterruptEnable(&BTNInst, BTN_INT); XGpio_InterruptGlobalEnable(&BTNInst); Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XScuGic_InterruptHandler, XScuGicInstancePtr); Xil_ExceptionEnable(); return XST_SUCCESS; } int IntcInitFunction(u16 DeviceId, XTmrCtr *TmrInstancePtr, XGpio *GpioInstancePtr) { XScuGic_Config *IntcConfig; int status; // Interrupt controller initialisation IntcConfig = XScuGic_LookupConfig(DeviceId); status = XScuGic_CfgInitialize(&INTCInst, IntcConfig, IntcConfig->CpuBaseAddress); if(status != XST_SUCCESS) return XST_FAILURE; // Call to interrupt setup status = InterruptSystemSetup(&INTCInst); if(status != XST_SUCCESS) return XST_FAILURE; // Connect GPIO interrupt to handler status = XScuGic_Connect(&INTCInst, INTC_GPIO_INTERRUPT_ID, (Xil_ExceptionHandler)BTN_Intr_Handler, (void *)GpioInstancePtr); if(status != XST_SUCCESS) return XST_FAILURE; // Connect timer interrupt to handler status = XScuGic_Connect(&INTCInst, INTC_TMR_INTERRUPT_ID, (Xil_ExceptionHandler)TMR_Intr_Handler, (void *)TmrInstancePtr); if(status != XST_SUCCESS) return XST_FAILURE; // Enable GPIO interrupts interrupt XGpio_InterruptEnable(GpioInstancePtr, 1); XGpio_InterruptGlobalEnable(GpioInstancePtr); // Enable GPIO and timer interrupts in the controller XScuGic_Enable(&INTCInst, INTC_GPIO_INTERRUPT_ID); XScuGic_Enable(&INTCInst, INTC_TMR_INTERRUPT_ID); return XST_SUCCESS; }
  4. Hi @jpeyron, Thanks for the reply but I am not sure if this is what I am looking for. I was following a document which explains the frequency measurement. This document is from digilent. Here is the link: I understand the concept for the measurement of frequency now but I don't know how can I implement on zybo board. It would be very helpful if you can give any assistance on this. Thanks & Regards Vishav
  5. Hi, I am using a 4 wire fan and my task is to measure the speed of the fan using the tachometer output of the fan. The tachometer output produces 2 cycles per revolution of the fan. Hence it is a square wave whose frequency varies with the speed of the fan. I have read some posts that it can be done by calling interrupt at the rising or falling edge and hence counting the number of pulses. Does anyone have an idea how can implement this on Zybo board? Where should I input the tachometer output on the board? Which interrupts should I call for this operation? Any help would be appreciated. Thanks & Regards Vishav
  6. Hi @samikhan0105 and @jpeyron I am also facing the same issue. The Board is getting programmed successfully but is not generating any outputs. Did you find a fix for it? Regards Vishav
  7. Yes, I was able to resolve the problem. Thanks Vishav
  8. Hi, I figured it out. I had to enable AXI4Stream in XADC Wizard. I thought that would be done default by Vivado. Here is the screenshot. Regards Vishav
  9. Hi @jpeyron I tried running zybo_xadc_test.c but again the code stucks at XSysMon_CfgInitialize. It again calls the interrupt DataAbort. Does it work on your board? I am using 2016.4 SDK. However, I compared the previous code with yours. pxsmoncfg gets the same parameters as previous code. So is it really a problem of parameter initialization? Thanks Vishav
  10. Hi @JColvin, Thanks for the reply. I have been facing an issue lately which I have posted in this post. I have successfully build the hardware and exported it to my SDK. There I am trying to execute code to read built in temperature sensor. But the code stucks at XSysMon_CfgInitialize. I request you to please refer to this post for my design and code. Any help from you would be welcome Thanks Vishav
  11. Hi, I am trying to implement xadc on my Zybo Board. I created the hardware and exported it to SDK. Then, I build an application for reading the on-chip sensor. But when I run the application, it stucks at XSysMon_CfgInitialize function. On debugging, I found that it is enabling DataAbortInterrupt. Does anyone have an idea abou this? Please find attached my hardware design, code, address editor tab screenshot and the tutorial that I followed to do it. Thanks & regards Vishav xadc_code.txt lab3.pdf
  12. Hi @jpeyron, Thanks for the reference. I followed the post and successfully created the hardware and imported it to SDK. I developed an application to read sensor data which was build successfully. However, when I run the application, it stucks at XSysMon_CfgInitialize function. On debugging it, I found out that it is calling DataAbortInterrupt. I am attaching the hardware design, address editor tab and code for your reference. It would be nice if I could have a solution for it. Thanks Vishav xadc_code.txt
  13. Hi @StudentAmsterdam and @jpeyron, I am also working on a similar problem. I was able to successfully import my hardware and build my code successfully. But while running the code, it stucks at XsysMon_CfgInitialize(). While debugging, I found out that that the data abort interrupt is getting enabled. Did anyone of you faced a similar issue? I am attaching my design, address editor tab and code for reference. Thanks Vishav xadc_code.txt
  14. Hi @JColvin yes, I am using original Zybo board. My Project involves reading a speed sensor and then using Ethernet to pass the data to the computer. So I thought of starting with reading an analog sensor and printing the value in SDK Terminal. Then I can modify the code accordingly. The tutorial "Zybo XADC demo" doesn't give me any insight into how xadc was added in my hardware? I hope you can understand, what I am looking for. Thanks Vishav
  15. Hi, I want to read an analog sensor value into my Zybo Board. I am looking for a starting tutorial. I have already followed XADC Demo but unfortunately I did not find it informative. Can you please suggest me some other sources? Thanks Vishav