Saving 64KB/s from custom module with C program
Posted: Fri Jul 22, 2022 5:27 pm
Hello,
I was wondering if anyone could help me figure out how to stream approximately 64KB/s from a custom module to a PC, or even put that data into the SD card of the Red Pitaya. I have a module which outputs to 32 registers (in the 0x406... mmap area) at approximately 500Hz, and I would like to operate the module for a long time (an hour or so), saving all the data acquired (so close to 250MB).
I was thinking about writing a C program to do this, but I'm a little lost in how to access the mapped memory from the FPGA with C. I understand that you can use a pointer to this memory, but to do this you need to generate a virtual address, and I'm somewhat confused by how to do that.
Trying to work through this, it seems the map_base is derived as follows:
I can see MAP_SIZE hardcoded, PROT_READ, PROT_WRITE, and MAP_SHARED seem to be built in parameters, I can see MAP_MASK defined, but I'm a little confused by the fd part. Ignoring that part for a moment, if I copy the above code into a C file, and then set a_addr = 0x40600000, would I be able to access that register using this?
Or am I missing something? And could anyone help explain what's going on with fd?
This is the code I'm looking at: https://github.com/RedPitaya/RedPitaya/ ... /monitor.c
Thank you,
Corey
I was wondering if anyone could help me figure out how to stream approximately 64KB/s from a custom module to a PC, or even put that data into the SD card of the Red Pitaya. I have a module which outputs to 32 registers (in the 0x406... mmap area) at approximately 500Hz, and I would like to operate the module for a long time (an hour or so), saving all the data acquired (so close to 250MB).
I was thinking about writing a C program to do this, but I'm a little lost in how to access the mapped memory from the FPGA with C. I understand that you can use a pointer to this memory, but to do this you need to generate a virtual address, and I'm somewhat confused by how to do that.
Code: Select all
void* virt_addr = map_base + (a_addr & MAP_MASK);
Code: Select all
map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr & ~MAP_MASK);
Code: Select all
read_result = *((uint32_t *) virt_addr);
This is the code I'm looking at: https://github.com/RedPitaya/RedPitaya/ ... /monitor.c
Thank you,
Corey