Siva ram
/
SPI_DAC_EPS
Nikunj code
Diff: main.cpp
- Revision:
- 0:b121e4eadb42
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jul 06 12:45:23 2015 +0000 @@ -0,0 +1,50 @@ +#include "mbed.h" + +SPI spi(PTA16, PTA17, PTA15); // mosi, miso, sclk +DigitalOut cs(PTD2); +Serial pc(USBTX, USBRX); +uint16_t input = 24576; +uint16_t Num = 15 ; +uint8_t K , F , i ,input2 = 0; + +int main() { + // Chip must be deselected + cs = 1; + + // Setup the spi for 8 bit data, high steady state clock, + // second edge capture, with a 1MHz clock rate + spi.format(8,0); // mode not decided + spi.frequency(1000000); + + cs = 0; + spi.write(input); + spi.write(input2); + cs = 1; + + + + for ( i = 0 ; i<= 15; i++ ) + + { + + cs = 0; // Select the device by seting chip select low + + spi.write(0x3F) ; // power up int ref and select all dacs 0b01101111 + + K = Num >> 8 ; + spi.write ( K ); + F = Num - ( K << 8 ) ; + spi.write ( F) ; + Num = Num + 2400 ; + + cs = 1; + + wait (1) ; + pc.printf ("%d %d %d \n " , Num, F, K ); + pc.printf( "\n\r"); + +} + + + +} \ No newline at end of file