Hi,
okay, the show goes on . . .
Today I implemented the SOPC system shown in the attachment. I designed my own ADC streaming component (ads62_avalon_st) and connected it with the SGDMA components provided in the example that BadOmen gave to me.
I use the following code to try to start the SGDMA:
# include <io.h>
# include <stdio.h>
# include <stdlib.h>
# include "sys/alt_dma.h"
# include "system.h"
# include <unistd.h>
# include "sys/alt_irq.h"
# include "altera_avalon_spi.h"
# include "altera_avalon_spi_regs.h"
# include "altera_avalon_pio_regs.h"
# include "i2c_defs.h"
# include "e_adc_0100_firmware_defs.h"
# include "descriptor_regs.h"
# include "csr_regs.h"
# include "response_regs.h"
# include "sgdma_dispatcher.h"
static volatile int rx_done = 0;
char* OK = "-> OK!\n";
char* FAILED = "-> FAILED!\n";
// flag used to determine when all the transfers have completed
volatile int sgdma_interrupt_fired = 0;
static void sgdma_complete_isr(void *context, alt_u32 id)
{
sgdma_interrupt_fired = 1;
clear_irq(SGDMA_DISPATCHER_CSR_BASE);
}
int main()
{
int total_error_counter = 0;
int current_error_counter = 0;
int testNumber = 0;
unsigned int potValue = 0;
unsigned int pioIn = 0;
unsigned int pioOut = 0;
char c = 0x00;
int i = 0;
sgdma_standard_descriptor a_descriptor;
sgdma_standard_descriptor * a_descriptor_ptr = &a_descriptor; // using this instead of 'a_descriptor' throughout the code
unsigned long control_bits = DESCRIPTOR_CONTROL_TRANSFER_COMPLETE_IRQ_MASK;
alt_irq_register(SGDMA_DISPATCHER_CSR_IRQ, NULL, sgdma_complete_isr); // register the ISR
enable_global_interrupt_mask(SGDMA_DISPATCHER_CSR_BASE); // turn on the global interrupt mask in the SGDMA
construct_standard_st_to_mm_descriptor(a_descriptor_ptr, (alt_u32 *)SRAM_BASE, 0xff, control_bits);
while (1)
{
c = getchar();
if (c == START_SGDMA_TRANSFER)
{
if (write_standard_descriptor(SGDMA_DISPATCHER_CSR_BASE, SGDMA_DISPATCHER_DESCRIPTOR_SLAVE_BASE, a_descriptor_ptr) != 0)
{
printf("Failed to write descriptor to the descriptor SGDMA port.");
}
}
if (sgdma_interrupt_fired == 1)
{
for (i = 0; i < 0xff; i++) {
printf("%x\n", IORD_32DIRECT(SRAM_BASE, i));
}
sgdma_interrupt_fired = 0;
}
if (c == OUTPUT_RAMP_PATTERN)
{
printf("ADS62 outputs digital ramp.\n");
IOWR_ALTERA_AVALON_SPI_CONTROL(ADS62_SPI_BASE, ALTERA_AVALON_SPI_CONTROL_SSO_MSK);
IOWR_ALTERA_AVALON_SPI_TXDATA(ADS62_SPI_BASE, 0x0002);
IOWR_ALTERA_AVALON_SPI_CONTROL(ADS62_SPI_BASE, 0x0);
usleep(10);
IOWR_ALTERA_AVALON_SPI_CONTROL(ADS62_SPI_BASE, ALTERA_AVALON_SPI_CONTROL_SSO_MSK);
IOWR_ALTERA_AVALON_SPI_TXDATA(ADS62_SPI_BASE, 0x1614);
IOWR_ALTERA_AVALON_SPI_CONTROL(ADS62_SPI_BASE, 0x0);
usleep(10);
}
if (c == SRAM_TEST)
{
// Test SRAM.
printf("\n\nTesting SRAM with Counter 0x0 -> 0xFFFF.\n");
// Write testpattern into memory.
for (testNumber = 0; testNumber < 0xffff; testNumber++)
{
IOWR_32DIRECT(SRAM_BASE, testNumber, testNumber);
}
// Read test pattern from memory.
for (testNumber = 0; testNumber < 0xffff; testNumber++)
{
if (IORD_32DIRECT(SRAM_BASE, testNumber) != testNumber)
{
current_error_counter++;
total_error_counter++;
printf("SRAM Read Error at Address: %x\n", testNumber);
}
}
if (current_error_counter == 0)
{
printf("Counter Pattern %s\n\n", OK);
} else
{
printf("Counter Pattern with %d Errors %s\n\n", current_error_counter, FAILED);
}
}
c = 0x00;
}
}
Unfortunately this is not working, yet (it seems that the interrupt after the SGDMA transfer is not triggered). However, the SRAM test is working as expected.
I will continue tomorrow but maybe, in the meantime, somebody has an idea that will help me to get this running.
Thanks,
Maik