Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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);
}
}