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.
Revision 15:c0356b061d5e, committed 2018-11-13
- Comitter:
- kong4580
- Date:
- Tue Nov 13 11:45:38 2018 +0000
- Parent:
- 14:085075499b41
- Commit message:
- glgllg
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 085075499b41 -r c0356b061d5e main.cpp --- a/main.cpp Tue Nov 13 09:36:15 2018 +0000 +++ b/main.cpp Tue Nov 13 11:45:38 2018 +0000 @@ -2,29 +2,29 @@ #include "mbed.h" #include "eeprom.h" Serial pc(USBTX,USBRX); -EEPROM memory(PB_9,PB_8,1); +EEPROM memory(PB_9,PB_8,1);// A2=0 A1=0 A0=1 BusIn dat(PB_4,PB_5,PB_3,PA_0,PA_1,PA_4,PB_0); BusOut led(PA_5,PA_6,PA_7,PB_6,PC_7,PA_9,PA_8); -DigitalIn m(PC_1); -InterruptIn button(D2); +DigitalIn m(PC_1); //toggle switch to select mode +InterruptIn button(D2); //deboounce button int mode = 0; int tic=0; void readmode(){ - if (m == 0){ + if (m == 0){ // if m = Low mode=0; tic=1; - }else{ + }else{ // if m = High mode=1; tic=1;} } int main() { int8_t ac; - int16_t rcount=2; - int16_t count=2; + int16_t rcount=3; + int16_t count=3; button.fall(&readmode); - for (int i =0;i<60;i++){ + for (int i =0;i<1000;i++){ memory.write(i,0); } while(1){ @@ -32,18 +32,21 @@ if (mode==0 & tic==1){ memory.write(count,dac); wait_ms(1); + + + pc.printf("Data in address %d = %d\n",count,dac); count+=1; tic=0; - rcount=2; - pc.printf("Data in address %d = %d\n",count,dac); + rcount=3; }else if(mode ==1 & tic==1){ memory.read(rcount,ac); led=ac; wait_ms(1); - rcount+=1; + + pc.printf("Read in address %d = %d\n",rcount,ac); + rcount+=1; tic=0; - count=2; - pc.printf("Read in address %d = %d\n",rcount,ac); + count=3; } }