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.
Fork of ProgettoAUC by
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 //TEA5767 example with STM32 nucleo 00005 //Developed by Mazzella, Vitone, (un po')Tarallo 00006 00007 TextLCD lcd(D12, D11, D5, D4, D3, D2, TextLCD::LCD16x2); 00008 I2C radio(D14, D15); //sda, sc1 00009 AnalogIn trimmer(PA_0);// A0 ingresso analogico 00010 00011 00012 00013 float frequenza; 00014 unsigned int N,m1,m2; 00015 char config_t[5]; 00016 00017 00018 const int addr = 0xC0; //address for writing data, reading is C1 00019 00020 int main() 00021 { 00022 while (1) { 00023 frequenza=(108-87.5)*trimmer.read()+87.5; 00024 N=4*(frequenza*1e6+225000)/32768; 00025 //a questo punto dobbiamo converitre in esadecimale N ed inviarlo al modulo radio 00026 // usando unsigned int n sappiamo con sicurezza di utilizzare solo 2 byte 00027 m2=N & 0x00FF;//isoliamo il secondo byte di N 00028 m1=N & 0xFF00;//isoliamo il primo byte di N,dobbiamo però shifarlo 00029 m1=m1>>8; 00030 00031 config_t[0] = char(m1); 00032 config_t[1] = char(m2); // config data byte, tune at 100.00MHz 00033 config_t[2] = 0x10; 00034 config_t[3] = 0x12; 00035 config_t[4] = 0x00; 00036 00037 radio.write(addr, config_t, 5); 00038 00039 lcd.locate(0,0); 00040 lcd.printf("Frequenza: "); 00041 lcd.locate(0,1); 00042 lcd.printf("%-2.2f", frequenza ); 00043 lcd.printf("MHz "); 00044 00045 wait(0.3); 00046 } 00047 00048 00049 }
Generated on Fri Jul 15 2022 00:27:02 by
1.7.2
