[iyoi

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002  
00003 SPI spi(PTA16, PTA17, PTA15); // mosi, miso, sclk
00004 DigitalOut cs(PTD2);
00005 Serial pc(USBTX, USBRX);
00006 int Num  = 15 ; 
00007 int K , F , i ;
00008  
00009 int main() {
00010     // Chip must be deselected
00011     cs = 1;
00012 
00013     // Setup the spi for 8 bit data, high steady state clock,
00014     // second edge capture, with a 1MHz clock rate
00015     spi.format(8,0);        // mode not decided
00016     spi.frequency(1000000);
00017  
00018     
00019    
00020  
00021   
00022      
00023     
00024     for ( i = 0 ; i<= 15; i++ )
00025     
00026     {
00027          
00028           cs = 0;          // Select the device by seting chip select low
00029          
00030           spi.write(0x6F) ;  // power up int ref and select all dacs 0b01101111
00031           
00032           K = Num >> 8   ; 
00033           spi.write ( K );
00034           F = Num - ( K << 8 ) ;
00035           spi.write ( F) ;
00036           Num = Num + 2400 ;
00037           
00038           cs = 1;
00039           
00040           wait  (1000) ; 
00041           pc.printf ("%d %d %d \n " , Num, F, K   ); 
00042           
00043 }
00044 
00045 
00046 
00047 }