i try to use your code successfull .
After i use structure data instead buffer of bytes .
So in this case the dma continually send butes and my pc
became crazy .
Then i try to fill your buffer from my data structure but the same occur .
http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif
Very strange
In pc side i'm using vc#.net with a rs232 dll .
I post my code
# include <stdio.h># include <stdlib.h># include "sys/alt_dma.h"# include "system.h"# include "alt_types.h"# include "dma_test.h"
typedef struct conn{
alt_u16 data1;
alt_u16 data2;
alt_u16 data3;
alt_u16 data4;
}Master;
alt_u8 buffer[16] __attribute__ ((section (".ext_ram")));
Master data;// __attribute__ ((section (".ext_ram")));
static volatile int dma_complete = 0;
void dma_done (void* handle)
{
dma_complete = 1;
}
int main(int argc, char* argv[], char* envp[])
{
int rc;
//buffer[0] = 0x30;
//buffer[1] = 0x31;
//buffer[2] = 0x32;
//buffer[3] = 0x33;
data.data1=10;
data.data2=20;
data.data3=30;
data.data4=40;
data.data5=50;
data.data6=60;
data.data7=70;
data.data8=80;
alt_u8 i;
alt_u8* pDati;
alt_u8 size = sizeof(data);
pDati = (alt_u8*)&data; //Point the first byte of my structure
for(i=0; i< size; ++i)
{
buffer[i] = *(pDati+i);
}
void* tx_data = (void*) &buffer[0];//data;//&buffer[0];
printf("Hello from Nios II!\n");
printf("size:%u\r",size);
alt_dma_txchan tx;
if ((tx = alt_dma_txchan_open("/dev/dma_0")) == NULL)
{
printf("Failed to open device!\n");
exit(1);
}
alt_dma_txchan_ioctl(tx, ALT_DMA_SET_MODE_8, NULL);
alt_dma_txchan_ioctl(tx, ALT_DMA_RX_STREAM_ON, (void*) UART_0_BASE+1);
dma_complete = 0;
if ((rc = alt_dma_txchan_send (tx, tx_data, 16, dma_done, NULL)) < 0 )
{
printf("Failed to post transmit request!, reason = %i\n", rc);
exit(1);
}
while (!dma_complete);
alt_dma_txchan_close (tx);
printf("Transaction Complete!\n");
printf(" :%u,%u,%u,%u,%u,%u,%u,%u\r",buffer[0],buffer[1],buffer[2],buffer[3],buffer[4],buffer[5],buffer[6],buff
er[7]);
return 0;
}
The last printf i use prints the correct value of 16 bytes buffer .
But the pc receive totally differents datas.
Printf shows to me correct data in buffer :
buffer[0]=10
buffer[1]=0
buffer[2]=20
buffer[3]=0
............
in the pc i recevice
58-58-10-30-58-58-10-30-58-58-10-30-58-58-10-30
Do you have some idea?
ciao
walter