khalid el horri
/
nucleo_F746ZG_TDC502_port_programm_test
programme tdc502
Diff: main.cpp
- Revision:
- 1:346b69769c2e
- Parent:
- 0:893cddb940f0
--- a/main.cpp Tue May 16 09:56:45 2017 +0000 +++ b/main.cpp Sun Jun 11 18:38:11 2017 +0000 @@ -1,26 +1,55 @@ #include "mbed.h" #include "TDC502.h" Serial pc(USBTX,USBRX); - -DigitalOut ale(PE_0,1); +//Serial envoi(); +DigitalOut ale(PE_0,1); //ALE=1 TDC502 tdc502(PortD, 0x00FF, //PD_7, PD_6, PD_5, PD_4, PD_3, PD_2, PD_1, PD_0, DataD7 - D0 PortA, 0x00F0, //PA_7,PA_6,PA_5,PA_4, adresse AD3 à AD0 + PD_11,PD_12,PD_13, // rdn wrn csn + PE_2, PA_0); // INTFLAG TDC_READY +//déclaration broche rx tx serial envoi - PD_11,PD_12,PD_13, // rdn wrn csn - PE_2, PA_0 ); // INTFLAG TDC_READY int main() { + pc.baud(115200); //vitesse de transmission +// tdc502.TestPerformanceWrite(); +// tdc502.TestPerformanceRead(); - pc.baud(115200); - tdc502.TestPerformanceWrite(); - tdc502.TestPerformanceRead(); - tdc502.init(); - tdc502.ReadAllRegister(); - tdc502.StartMesure(); - while(1) - if (tdc502.data_ready()) { - tdc502.ReadData(); - wait(10.0); + tdc502.init(); //Initialisation du TDC502 + +// tdc502.ReadAllRegister(); //lecture des registres + //tdc502.StartMesure(); + while(1) { + pc.printf("Debut mesure 11.06\r\n"); + tdc502.StartMesure(); - } + wait_ms(10); + tdc502.StopMesure(); + pc.printf("Fin mesure\r\n"); + // faire envoi vers carte IHM envoi==tdc502.StartMesure(); + // envoi==tdc502.StopMesure(); +// Affichage des donnees acquises pour verifier. + + for (unsigned i = 0; i < tdc502.NbreDataAcquise; i++) { + + unsigned result; + float tempsns; + result = tdc502.DataTdc502[i]; + i++; + result = (result << 8) + tdc502.DataTdc502[i]; + i++; + result = (result << 8) + tdc502.DataTdc502[i]; + i++; + result = (result << 8) + tdc502.DataTdc502[i]; + + tempsns = result; + tempsns = tempsns * 500.0 / 65536.0; // vient config du tdc502 + printf("Data %u --> %.3fns\r\n",result,tempsns); + + } + printf("Nombre de mseure %u %u\r\n",tdc502.NbreDataAcquise,tdc502.NbreDataAcquise/4); + pc.printf("Appuyer sur une touche"); + pc.getc(); + pc.printf("\r\n"); + } } \ No newline at end of file