Nikunj code

Dependencies:   mbed

main.cpp

Committer:
Piasiv1206
Date:
2015-07-06
Revision:
0:b121e4eadb42

File content as of revision 0:b121e4eadb42:

#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");
          
}
 
 
 
}