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.
Dependencies: mbed
main.cpp
00001 00002 #include "mbed.h" 00003 #include "MCP4922.h" 00004 00005 MCP4922 MCP(SPI_MOSI, SPI_SCK,PB_6); // MOSI, SCLK, CS 00006 00007 00008 /**** Main Function ***/ 00009 int main(void) 00010 { 00011 MCP.frequency(3125000); 00012 00013 uint16_t i=0; 00014 int state=0; 00015 while(1) { 00016 if(i < 0x07FF) { 00017 i++; 00018 } 00019 else { 00020 i=0; 00021 if (state == 0 ){ 00022 state = 1; 00023 } 00024 else if(state == 1) { 00025 state = 2; 00026 } 00027 else if(state == 2){ 00028 state = 3; 00029 } 00030 else if(state == 3){ 00031 state = 0; 00032 } 00033 } 00034 00035 if(state ==0) { 00036 MCP.writeA(i); 00037 } 00038 else if (state == 1){ 00039 MCP.writeA( ((~i))&0x07FF); 00040 } 00041 else if (state == 2){ 00042 MCP.writeA( ((~i))&0x0FFF); 00043 } 00044 else if (state == 3){ 00045 MCP.writeA(i+0x07FF); 00046 } 00047 wait_us(2); 00048 } 00049 }
Generated on Fri Jul 15 2022 14:22:52 by
1.7.2