for i in range(10):
            print("Host DMA pages %3d: %.8X") % (i, pages[i])

    print '\nInitialise memory pages'
    gn4124.set_memory_page(0, 0x0)
    gn4124.set_memory_page(1, 0xC0FFEE11)
    gn4124.set_memory_page(2, 0xDEADBABE)
    gn4124.set_memory_page(3, 0x0)
    gn4124.set_memory_page(4, 0x0)

    print '\nReading data from memory page 2 (before DMA)'
    page2_data_before = gn4124.get_memory_page(2)

    print '\nPreparing DMA'
    dma_length = 0x100 # DMA length in bytes
    gn4124.add_dma_item(0, pages[1], dma_length, 1, 1) # write from page 1 to SPEC memory
    gn4124.add_dma_item(0, pages[2], dma_length, 0, 0) # read from SPEC memory to page 2

    print '\nPage 0 data - DMA next items'
    page0_data = gn4124.get_memory_page(0)
    if DEBUG != 0:
        for i in range(4*(0x20/4)):
            print("[%.2X]:%.8X") % (pages[0]+i*4,page0_data[i])

    for i in range(1000):
        print("                                   TEST => %d")%i
        print("DMA controller status : %s") % gn4124.get_dma_status()

        print '\n Start DMA transfer'
        gn4124.start_dma()
        print("Status:%.8X") % adc_csr.rd_reg(CSR_STATUS)
        time.sleep(.1)

    print("Status:%.8X") % adc_csr.rd_reg(CSR_STATUS)

    print 'End of acquisition'


    print '\nReading data from memory page 1 (before DMA)'
    page1_data_before = gn4124.get_memory_page(1)

    print '\nPreparing DMA'
    dma_length = 0x1000 # DMA length in bytes
    for i in range(10):
        print("Host DMA pages %3d: %.8X") % (i, pages[i])
    gn4124.add_dma_item(0*dma_length, pages[1]+0*dma_length, dma_length, 0, 1)
    gn4124.add_dma_item(1*dma_length, pages[2]+0*dma_length, dma_length, 0, 1)
    gn4124.add_dma_item(2*dma_length, pages[3]+0*dma_length, dma_length, 0, 1)
    gn4124.add_dma_item(3*dma_length, pages[4]+0*dma_length, dma_length, 0, 0)
    #gn4124.add_dma_item(1*dma_length, pages[1]+1*dma_length, dma_length, 0, 1)
    #gn4124.add_dma_item(2*dma_length, pages[1]+2*dma_length, dma_length, 0, 1)
    #gn4124.add_dma_item(3*dma_length, pages[1]+3*dma_length, dma_length, 0, 0)

    print '\nPage 0 data - DMA next items'
    page0_data = gn4124.get_memory_page(0)
    for i in range(4*(0x20/4)):
        print("[%.2X]:%.8X") % (pages[0]+i*4,page0_data[i])

    print("DMA controller status : %s") % gn4124.get_dma_status()

    print '\n Start DMA transfer'