theAsker

Members
  • Content count

    34
  • 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

    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
  2. 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?
  3. 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
  4. 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?
  5. 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!
  6. 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?
  7. 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?
  8. 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!
  9. 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!
  10. 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?
  11. 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?
  12. 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.
  13. 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?
  14. theAsker

    Program code on PetaLinux

    I get now the correct voltages. I had one mistake in the XADC configuration. But with the help of another post of you @sbobrowicz in an other thread, I was able to fix the problem. I have two more questions: 1) If I want to safe the voltage values in a txt-file I am not able to read all values. I think the problem is, that my code works to slowly, or the linux system is to slowly. Is there a way, to make the linux more quickly. Or are you having a hint how to write all values (with 1 MSPS) to a textfile, to send it afterwards? 2) There is a file called sample_frequency int the path /sys/bus/iio/devices/iio\:device1/ . I think this is the place to change the sample frequency. The value is very, very big. What is the value I have to calculate to change the sampling frequency to 320kSPS? thanks for a lot of help!
  15. theAsker

    Program code on PetaLinux

    Hello! I was able to fix the problem. I only had to add an interrupt to the bloc diagram and also to the device driver. But now I have a now problem. The voltages I read are not correct. And I don't know why. In the attachment you can see my code for testing. Is someone having a plan, why I am having this effect? My driver is here: &xadc_wiz_0 { interrupts = <0 53 4>; interrupt-parent = <0x1>; clocks = <&clkc 15>; xlnx,channels { #address-cells = <1>; #size-cells = <0>; channelJA4@7 { reg = <7>; }; channelJA1@15 { reg = <15>; }; }; }; My constraints are: set_property -dict { PACKAGE_PIN N15 IOSTANDARD LVCMOS33 } [get_ports { Vaux14_0_v_p }]; #IO_L21P_T3_DQS_AD14P_35 Sch=JA1_R_p #set_property -dict { PACKAGE_PIN L14 IOSTANDARD LVCMOS33 } [get_ports { ja[1] }]; #IO_L22P_T3_AD7P_35 Sch=JA2_R_P #set_property -dict { PACKAGE_PIN K16 IOSTANDARD LVCMOS33 } [get_ports { ja[2] }]; #IO_L24P_T3_AD15P_35 Sch=JA3_R_P set_property -dict { PACKAGE_PIN K14 IOSTANDARD LVCMOS33 } [get_ports { Vaux6_0_v_p }]; #IO_L20P_T3_AD6P_35 Sch=JA4_R_P set_property -dict { PACKAGE_PIN N16 IOSTANDARD LVCMOS33 } [get_ports { Vaux14_0_v_n }]; #IO_L21N_T3_DQS_AD14N_35 Sch=JA1_R_N #set_property -dict { PACKAGE_PIN L15 IOSTANDARD LVCMOS33 } [get_ports { ja[5] }]; #IO_L22N_T3_AD7N_35 Sch=JA2_R_N #set_property -dict { PACKAGE_PIN J16 IOSTANDARD LVCMOS33 } [get_ports { ja[6] }]; #IO_L24N_T3_AD15N_35 Sch=JA3_R_N set_property -dict { PACKAGE_PIN J14 IOSTANDARD LVCMOS33 } [get_ports { Vaux6_0_v_n }]; #IO_L20N_T3_AD6N_35 Sch=JA4_R_N The configuration of the XADC is: AXI4Lite, channel_sequencer, AXI4 Stream Interface is false, Timing Mode is continuous, DCLK Frequency is 100MHz, Sequencer Mode is continuous, channel averaging ist none and enable external mux is also false. xadcread.cpp