khalid el horri
/
nucleo_F746ZG_TDC502_port_programm_test
programme tdc502
main.cpp
- Committer:
- khalidel
- Date:
- 2017-06-11
- Revision:
- 1:346b69769c2e
- Parent:
- 0:893cddb940f0
File content as of revision 1:346b69769c2e:
#include "mbed.h" #include "TDC502.h" Serial pc(USBTX,USBRX); //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 int main() { pc.baud(115200); //vitesse de transmission // tdc502.TestPerformanceWrite(); // tdc502.TestPerformanceRead(); 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"); } }