theAsker

Members
  • Content count

    36
  • Joined

  • Last visited

About theAsker

  • Rank
    Frequent Visitor

Recent Profile Visitors

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

  1. theAsker

    read EOC bare-metal

    Hi @jpeyron thanks for your answer. both examples are looking very good. The problem is only, that the interrupt isn't working. Do I have to add the connection in the block diagram from eos_out to the zynq-block or from iip2intc_irpt? I also add my code at the bottom, maybe you can find my mistake! If it is correctly working at the end, I also will give you my project for other users. Because I think this is a very useful example at the end. #include <stdio.h> #include "platform.h" #include "xparameters.h" //#include "xgpio.h" #include "xadcps.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 XADC_DEVICE_ID XPAR_PS7_XADC_0_DEVICE_ID #define INTC_XADC_INTERRUPT_ID XPAR_FABRIC_XADC_WIZ_0_IP2INTC_IRPT_INTR u32 XAdc_INT = 0x000000030; //Bit Mask of enabled interrupts of XADC //EOS and EOC enabled u32 test; XAdcPs XAdcInst; XScuGic INTCInst; static int value; //----------------------------------------------------------------- // PROTOTYPE FUNCTIONS //----------------------------------------------------------------- static void XADC_Intr_Handler(void *baseaddr_p); static int InterruptSystemSetup(XScuGic *XScuGicInstancePtr); static int IntcInitFunction(u16 DeviceId, XAdcPs *XAdcInstancePtr); //----------------------------------------------------------------- // INTERRUPT HANDLER FUNCTIONS // - called by the XADC interrupt // - toggles the value //----------------------------------------------------------------- void XADC_Intr_Handler(void *InstancePtr) { // Disable XADC interrupts XAdcPs_IntrDisable(&XAdcInst, XAdc_INT); if ((XAdcPs_IntrGetStatus(&XAdcInst) & XAdc_INT) != XAdc_INT) { return; } // Increment counter based on button value // Reset if center button pressed if(value != 1) { value = value + 1; } else { value = 0; } printf("value is %i\n", value); (void)XAdcPs_IntrClear(&XAdcInst, XAdc_INT); // Enable XADC interrupts XAdcPs_IntrEnable(&XAdcInst, XAdc_INT); } //----------------------------------------------------------------- // INITIAL SETUP FUNCTIONS //----------------------------------------------------------------- int InterruptSystemSetup(XScuGic *XScuGicInstancePtr) { // Enable interrupt XAdcPs_IntrEnable(&XAdcInst, XAdc_INT); Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XScuGic_InterruptHandler, XScuGicInstancePtr); Xil_ExceptionEnable(); return XST_SUCCESS; } int IntcInitFunction(u16 DeviceId, XAdcPs *XAdcInstancePtr) { XScuGic_Config *IntcConfig; int status; // Interrupt controller initialization 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 XADC interrupt to handler status = XScuGic_Connect(&INTCInst, INTC_XADC_INTERRUPT_ID, (Xil_ExceptionHandler)XADC_Intr_Handler, (void *)XAdcInstancePtr); if (status != XST_SUCCESS) { return XST_FAILURE; } // Enable XADC interrupts XAdcPs_IntrEnable(XAdcInstancePtr, XAdc_INT); // Enable XADC and timer interrupts in the controller XScuGic_Enable(&INTCInst, INTC_XADC_INTERRUPT_ID); return XST_SUCCESS; } int main() { init_platform(); int status; XAdcPs_Config *XADC_Config; //--------------------------------------------------------- // INITIALIZE THE PERIPHERALS & SET DIRECTION OF GPIO //--------------------------------------------------------- // Initialize Push Buttons XADC_Config = XAdcPs_LookupConfig(XPAR_PS7_XADC_0_DEVICE_ID); status = XAdcPs_CfgInitialize(&XAdcInst, XADC_Config, XADC_Config->BaseAddress); if (status != XST_SUCCESS) { return XST_FAILURE; } XAdcPs_SelfTest(&XAdcInst); test = XAdcPs_IntrGetStatus(&XAdcInst); // Initialize interrupt controller status = IntcInitFunction(INTC_DEVICE_ID, &XAdcInst); if (status != XST_SUCCESS) { return XST_FAILURE; } printf("%u\n", test); while(1) { ; } return 0; }
  2. theAsker

    reading XADC from user space

    I have to check this. Will there be problems, when the value always will change?
  3. theAsker

    Configuration: XADC

    I found the mistake. It is really a mess that it took me arround 6 hours to figure out, that I am reading to the wrong channel. Does someone know if bipolar mode with simultaneous sampling is slower than unipolar mode with simultaneous sampling
  4. theAsker

    Configuration: XADC

    I enabled in the XADC Wizard Block for Vaux6 and Vaux14 (my channels) bipolar. -no configurations now, only initialisation is added in the bare-metal code- How if I let read the channels i get much smaller values. Raw value is arround 350 now. Before that, the value was arround 1250 (330mV DC is connected). (Update: If I let the two inputs open, I also measure the same) So I think there is something happening in the conversion. But surly not the right .... Also if I change the cables + to - and - to + so I should measure -330mV, i get the same raw-value. Does someone have an idea, why?
  5. theAsker

    Configuration: XADC

    I don't understand exactly what, I have to change? Could you help me here. There is for the XADC Wizard block the option to enable bipolar channels. But in the case, I am doing this, also nothing is happening... analog common mode is not interesting for me, cause I want my voltage +-0.5V arround 0V
  6. theAsker

    Configuration: XADC

    I added now all kind of configurations: XAdcPs_WriteInternalReg(xadc_ptr, XADCPS_CFR0_OFFSET, 0x8400); //bipolar mode XAdcPs_WriteInternalReg(xadc_ptr, XADCPS_CFR1_OFFSET, 0x4F0F); XAdcPs_WriteInternalReg(xadc_ptr, XADCPS_CFR2_OFFSET, 0x0400); In the first code line, the bipolar should be enabled. But if I change now the two cables of my input, the raw_values stays the same. Do you know, where my problem is?
  7. theAsker

    Configuration: XADC

    Hello everyone! I bought the Zybo Z7-20 board, and my aim is to convert 2 analog signals to digital signals via XADC in an simultaneous wy. For this I want to use the bare-metal programming in bipolar-mode (I am using Vivado IDE & SDK 2017.4). In the library xadcps.h I found nothing about the configuration to bipolar mode. Can anyone help me, telling which functions I need and how do I have to configurate them? Is there an example existing? Thanks for all help!
  8. theAsker

    Program code on PetaLinux

    I want to map the XADC from user space. I use for this: #define START_ADDRESS_XADC 0x43C00000 int fd = open("/dev/mem", O_RDWR|O_SYNC); char *ptr = (char *)mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, START_ADDRESS_XADC); when I want to write now to the registers like: ptr[ 0x40 ] = 0x8200; And I read the address before writing, it returns a 0. After writing, also a 0. So I think, a don't have permissions to write to this address. Why and how do I fix that?
  9. theAsker

    Program code on PetaLinux

    update: i figured out, that I can not write to the XADC registers the configuration. Can someone tell me why?
  10. theAsker

    Program code on PetaLinux

    Thanks for the response! About working with /dev/iio:deviceX it isn't writte so much down. And reading from files is in my application to slow. So I am back at my solution way with mapping from /dev/mem. So for it is working correctly. I am possible to map. But if i let the code run. I only get 0 for voltages. I read something, that you have to disable the driver. I tried it both ways, but nothing happend. Maybe you could have a look over my code and you're seeing my mistake right now. #include <stdio.h> #include <stdlib.h> #define XADC_START_ADDR 0x43C00000 #define XADC_END_ADDR 0x43C0FFFF #define XADC_SIZE (XADC_END_ADDR - XADC_START_ADDR) #define UINT16 unsigned short #define UINT32 unsigned long int main () { int fd = open("/dev/mem", O_RDWR|O_SYNC); UINT16 test; if (fd == -1) { printf("Error: no open /dev/mem\n"); return -1; } char *xadc_addr = (char *)mmap(0, XADC_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, XADC_START_ADDR); if (xadc_addr == MAP_FAILED) { printf("Error: no mmap\n"); return -1; } //here could be the problem, but if I add the enable, i get the error: "segmentation fault" //enable: JTAG DRP (for measure external voltages) //*((volatile UINT32 *)(xadc_addr + 0x02)) = 0x0001; if(*((volatile UINT32 *)(xadc_addr + 0x02)) == 0x0001) { printf("Error: enable for external voltagemessurement"); return -1; } //continuous sampling mode in config_register0 *((volatile UINT16 *)(xadc_addr + 0x40)) |= 0x0400; if (*((volatile UINT16 *)(xadc_addr + 0x40)) == 0x0400) { printf("continuous sampling mode\n"); return -1; } //UINT16 volatile* pReg = (UINT16 volatile*)(xadc_addr + 0x40); //UINT16 val = *pReg; //printf("Register 40 is %u\n", val); //simultaneous mode in config_register1 *((volatile UINT16 *)(xadc_addr + 0x41)) |= 0x4000; if (*((volatile UINT16 *)(xadc_addr + 0x41)) == 0x4000) { printf("Error: no configuration of simultaneous mode\n"); return -1; } //enable calibration *((volatile UINT16 *)(xadc_addr + 0x48)) |= 0x0001; if (*((volatile UINT16 *)(xadc_addr + 0x41)) == 0x0001) { printf("Error: enable calibration\n"); return -1; } //ADC powered up and ADC-Clock = DCLK/2 in config_register2 *((volatile UINT16 *)(xadc_addr + 0x42)) |= 0x0400; if (*((volatile UINT16 *)(xadc_addr + 0x42)) == 0x0400) { printf("Error: ADC powered up and ADC-Clock = DCLK/2\n"); return -1; } //enable channel 6 and 14 for simultaneous mode *((volatile UINT16 *)(xadc_addr + 0x49)) |= 0x4000; if (*((volatile UINT16 *)(xadc_addr + 0x49)) == 0x4000) { printf("Error: simultaneous mode for channel 6 and 14\n"); return -1; } //enable flags *((volatile UINT16 *)(xadc_addr + 0x3F)) |= 0x0400; if(*((volatile UINT16 *)(xadc_addr + 0x3F)) == 0x0400) { printf("Error: enable JTAG_XADC\n"); return -1; } //Read: channel 6 unsigned int val1 = *((volatile UINT16 *)(xadc_addr + 0x16)); printf("channel 6: %u\n", val1); printf("successful test\n"); close(fd); return 0; } thanks for all help!
  11. theAsker

    Program code on PetaLinux

    Hello, I have some questions about application code of linux, for reading the external voltages. 1) At the moment I use the c++ commands: file.read("path"); then file >> array; and at least file.close(); It there a much more gentil way to solve it. For example mmaping the registers directly to PS. I thought about using the "GPIO" mapping function for reading ports: *((volatile unsigned *)(gpio_base + offset)); Is this possible. And if yes, how will i figure out the gpio_base (of course I mean here the xadc_base) and the necessary offset? 2) Is there the possibility to do the same with EOS (interrupt if the converting worked)? thanks for your help!
  12. theAsker

    Program code on PetaLinux

    Hi! Thank you for your answer! I read now something and found out, that the interrupt from the xadc block is not as i expected. Do you have an idea, how I can (write a c++ code) read the external voltages so that i don't miss a value? Thought about adding in the block design a clock devider and then connect it via UIO to use it then as an interrupt? Do you have another idea, or how do you solve it, getting really all voltages read, you want?
  13. theAsker

    Program code on PetaLinux

    The important thing here is: I want an event driven sampling. so always when a new sample value is there, i want that it will be read! And it is absolutly not clear for me how to do it! I am really a newbie to this and I am feeling lost.... update question: in the path: /sys/bus/iio/devices/trigger1/ there is uevent. Is this my trigger? or when is the value inside uevent not 0! What is this uevent?
  14. theAsker

    Program code on PetaLinux

    Now I am also a bit confused. Cause I don't know which xadcread.cpp file you mean. To explain my problem a bit more: At the moment I read a voltage with the following code: myvoltageIR.open("/sys/bus/iio/devices/iio\:device1/in_voltage9_vaux14_raw"); myvoltageIR >> voltage; myvoltageIR.close(); But know I want to do this only, when I get an interrupt from XADC. I also see, that there is an interrupt available: Cause if I do the following: $ cat /proc/interrupt \snip 46: 0 0 GIC-0 85 Level 43c00000.xadc_wiz \snip My problem now is, how do I build a c++ code/problem, that reads that interrupt and only reads the voltage, when an interrupt is available.
  15. theAsker

    Program code on PetaLinux

    Thank you for your Answer! Are you having an c/c++ - example, how I can read the external voltages controlled via the interrupt with my petalinux?