Kyle Cassar / Mbed 2 deprecated DACAD7390

Dependencies:   mbed

main.cpp

Committer:
cassar10
Date:
2014-04-05
Revision:
0:82cd70f9fc3f
Child:
2:8633e348822f

File content as of revision 0:82cd70f9fc3f:

#include "mbed.h"

SPI DAC(p5, p6, p7);                //mosi, miso, sclck
DigitalOut CLR (p10);               //Resets DAC register to 0 when pulled low
DigitalOut LD (p8);                 //Pull low to load DAC register from shift register
DigitalOut led(LED2);

int main()
{
        DAC.format(12,0);               //Set to 12 bit data transfer with no change in clock polarity or phase
        DAC.frequency(2000000);

    while(1) {

        CLR = 1;                    //Pull this low to set back to 0;
        LD = 1;                     //Send high as the DAC register is loaded once pulled low.
        DAC.write(0x3ff);           //Write 256 to DAC
        LD = 0;                     //Send to DAC register from shift register
        wait_us(10);                //Give time to update
        LD = 1;                     //Send back into read mode
        wait(2);
        DAC.write(0xBff);           //Write 256 to DAC
        LD = 0;                     //Send to DAC register from shift register
        wait_us(10);                //Give time to update
        LD = 1; 
        wait(2); 


    }
}