Forum Discussion
Altera_Forum
Honored Contributor
7 years ago --- Quote Start --- I have successfully used SPI (3 Wire Serial) to drive slow ADCs and DACs with both NIOSII/C program and HPS/Linux. depending on your dac type you can have different code. Mine was simple:
int DACSetVoltage(float V, int DACnr)
{
int value = DACVoltage2Bit(V); // this is my function that converts float value to binary corresponding to DAC type and reference voltage used.
alt_u8 array;
array = value>>8;
array = value & 0xff;
return alt_avalon_spi_command(DAC_SPI_BASE, DACnr, 2, array, 0, 0, 0);
} --- Quote End --- Thanks, settem. Which core are you using, and if you don't mind, what is the DAC part number? I may be able to figure something out from that much.