Altera_Forum
Honored Contributor
9 years agoNios SPI read
Hi everybody,
I'm using the alt_avalon_spi_command Altera function to write on a DAC and i have problem when i tried to read what i have wrote before. The DAC requiert 1 instruction byte (r/w+7 adress bit) and 2 byte for write routine. So when i tried to read in any register i have de same value CBD814(14 is 0x10 + adress) i don't understant what is the problem. This is my C code: void write_dac84h84_spi(){ int i; alt_u8 wdata[49][3]={{0x00,0x01,0x8C},{0x01,0x01,0x00},{0x02,0x00,0x52},{0x03,0xF0,0x01},{0x04,0xFF,0xFF},{0x05,0x86,0x60},{0x06,0x43,0x00},{0x07,0xFF,0xFF},{0x08,0x00,0x00},{0x09,0x80,0x00},{0x0A,0x00,0x00},{0x0B,0x00,0x00},{0x0C,0x05,0xA6},{0x0D,0x05,0xA6},{0x0E,0x05,0xA6},{0x0F,0x05,0xA6}, {0x10,0x00,0x00},{0x11,0x00,0x00},{0x12,0x00,0x00},{0x13,0x00,0x00},{0x14,0x00,0x00},{0x15,0x00,0x00},{0x16,0x00,0x00},{0x17,0x00,0x00},{0x18,0x34,0x62},{0x19,0x20,0xF4},{0x1A,0xEC,0x00},{0x1B,0x08,0x00},{0x1C,0x00,0x00},{0x1D,0x00,0x00},{0x1E,0x11,0x88},{0x1F,0x11,0x44},{0x20,0x14,0x00}, {0x22,0x1B,0x1B},{0x23,0x00,0x1F},{0x24,0x10,0x00},{0x25,0x7A,0x7A},{0x26,0xB6,0xB6},{0x27,0xEA,0xEA},{0x28,0x45,0x45},{0x29,0x1A,0x1A},{0x2A,0x16,0x16},{0x2B,0xAA,0xAA},{0x2C,0xC6,0xC6},{0x2D,0x00,0x00},{0x2E,0x00,0x00},{0x2F,0x00,0x00},{0x30,0x61,0xA8},{0x7F,0x00,0x01},}; for(i=0;i<=48;i++){ alt_avalon_spi_command(DAC34_SPI_BASE,0,3,wdata[i],0,NULL,NULL); } return;} void read_dac84h84_spi(){ alt_u8 adress=0x04; alt_u8 rdata[2]; alt_avalon_spi_command(DAC34_SPI_BASE,0,1,(0x10+adress),2,rdata,NULL); printf("Registre %d : %X%X\n",adress,rdata); return;} Is there anyone who have successfull read with the function?? Maybe i miss something Best regards