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
- Committer:
- ryouheitakamoto
- Date:
- 2020-12-28
- Revision:
- 1:3d373c17be18
- Parent:
- 0:4eeab953c09c
- Child:
- 2:2a1eb5136f89
File content as of revision 1:3d373c17be18:
#include "mbed.h"
/*ドップラーシフト対策 calsatが計算した周波数のデータを評価ボードに与える*/
Serial pc(SERIAL_TX, SERIAL_RX,921600);
Serial device(PA_9,PA_10,9600);
int main()
{
int n;
n = 123456789;
double data = n * 2 / 19.68;
int Integer_data = int(data);
int Decimal_data = 0;
double Dec = (data - Integer_data);
int i = 1;
int intbin[7]={0};
int decbin[14]={0};
while(1) {
if(i*(1.0 / 32768) > Dec ) {
Decimal_data = i;
break;
}
i++;
}
printf("Integer_data = %d\r\nDecimal_data = %d\r\n",Integer_data,Decimal_data);
/* 小数部 10進数→2進数の変換 */
int intdec = Decimal_data * 100;
for(i=0;intdec>0;i++){
decbin[i] = Decimal_data % 2;
Decimal_data = Decimal_data / 2;
}
/*整数部 10進数→2進数の変換 */
for(i=0;Integer_data >0;i++){
intbin[i] = Integer_data % 2;
Integer_data = Integer_data / 2;
}
/* 2進数の出力 */
printf(" Bainary of Integer_data = ");
int k = 8;
while( k>0 ){
printf("%d", intbin[--k]);
}
printf("\n");
printf(" Bainary of Decimal_data = ");
int l = 15;
while( l>0 ){
printf("%d", decbin[--l]);
}
printf("\n");
}