Jump to content
ELFORUM - Forumul electronistilor

tentativa nereusita atmega64-FT245BM-PC - help daca se poate


Guest poli_danny

Recommended Posts

Guest poli_danny

Buna,Am o prostie de proiect pt faculta in care citesc un senzor de temp/umid SHT11 si vreau sa transfer datele la calculator prin USB. Am reusit cu max232 in windows hyperterminal dar cu FT245 nu reusesc nicicum. Folosesc o placa de dezvoltare Cerebot cu atmega64 de la Digilent inc. Producatorii chipului FT245 pun la dispozitie un driver prin care dispozitivul conectat la calc prin USB e vazut ca un COM, astfel pot sa il citesc intr-o aplicatie C#, ca un port serial normal. Problema e ca la receptie primesc pe langa caracterul transmis si o sumedenie de alte caractere : "qqq???ppp?????". Cineva imi zicea ca trebuie sa leg masa FT245BM cu masa Cerebot-ului [done that, tot la fel se comporta] iar eu am citit in datasheet ca daca nu folosesc pinul Si/Wu , atunci e bine sa fie conectat la VCCIO, dar asta sa fie problema? Circuitul cu FT245 e usb bus powered iar profu de la faculta mi-a aratat ca conectand dispozitivul la un calc pe usb - receiver si pe un calc la portu paralel -transmitter, atunci merge. Pe mine sincer ma intereseaza sa transmit doar 3 octeti de date, altceva nu, nu numere, nu litere sau alte prostii.A mai lucrat cineva cu asa ceva? Sigur e ceva banal de tampit la mijloc. Inca ceva ce merita mentionat e ca am folosit portul F ca port paralel de date - e un port de ADC-uri dar din moment ce nu am dat drumul ADC-urilor presupun ca se comporta ca un port normal.Am pus si codul scris in Codevision AVR.Multam multvoid main(void){// Declare your local variables here// Port D initialization ----------- PORT pt handshake ----------- // Func7=In Func6=In Func5=In Func4=In Func3=Out Func2=In Func1=In Func0=Out // State7=T State6=T State5=T State4=T State3=T State2=0 State1=0 State0=T PORTD=0x00;DDRD=0x09;// Port F initialization ----------- PORT PARALEL de DATE ----------- // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 PORTF=0x00;DDRF=0xFF;// Timer/Counter 0 initialization// Clock source: System Clock// Clock value: Timer 0 Stopped// Mode: Normal top=FFh// OC0 output: DisconnectedASSR=0x00;TCCR0=0x00;TCNT0=0x00;OCR0=0x00;// Timer/Counter 1 initialization// Clock source: System Clock// Clock value: Timer1 Stopped// Mode: Normal top=FFFFh// OC1A output: Discon.// OC1B output: Discon.// OC1C output: Discon.// Noise Canceler: Off// Input Capture on Falling Edge// Timer1 Overflow Interrupt: Off// Input Capture Interrupt: Off// Compare A Match Interrupt: Off// Compare B Match Interrupt: Off// Compare C Match Interrupt: OffTCCR1A=0x00;TCCR1B=0x00;TCNT1H=0x00;TCNT1L=0x00;ICR1H=0x00;ICR1L=0x00;OCR1AH=0x00;OCR1AL=0x00;OCR1BH=0x00;OCR1BL=0x00;OCR1CH=0x00;OCR1CL=0x00;// Timer/Counter 2 initialization// Clock source: System Clock// Clock value: Timer2 Stopped// Mode: Normal top=FFh// OC2 output: DisconnectedTCCR2=0x00;TCNT2=0x00;OCR2=0x00;// Timer/Counter 3 initialization// Clock source: System Clock// Clock value: Timer3 Stopped// Mode: Normal top=FFFFh// OC3A output: Discon.// OC3B output: Discon.// OC3C output: Discon.// Noise Canceler: Off// Input Capture on Falling Edge// Timer3 Overflow Interrupt: Off// Input Capture Interrupt: Off// Compare A Match Interrupt: Off// Compare B Match Interrupt: Off// Compare C Match Interrupt: OffTCCR3A=0x00;TCCR3B=0x00;TCNT3H=0x00;TCNT3L=0x00;ICR3H=0x00;ICR3L=0x00;OCR3AH=0x00;OCR3AL=0x00;OCR3BH=0x00;OCR3BL=0x00;OCR3CH=0x00;OCR3CL=0x00;// Analog Comparator initialization// Analog Comparator: Off// Analog Comparator Input Capture by Timer/Counter 1: OffACSR=0x80;SFIOR=0x00;while (1) { // Place your code here for(i=0;i<384;i++){ if(PIND.1==0){//poate scrie PIND.1=TXE# PORTD = 0x01; //wr signal goes high delay_us(10); PORTF ='B'; //trimite pe portul de date delay_us(10); PORTD = 0x00; //wr signal goes low delay_us(10); } else{// nu poate scrie } }//close for }//close while}//close main

Link to comment
Share on other sites

daca zici ca ai reusit cu max 232 de ce nu incerti cu FT232R iar ca sa fii sigur cu conectarea corecta cauta exemple pe googleThe FT232R is a USB to serial UART interface with optional clock generator output, and the new FTDIChip-ID™ security dongle feature. In addition, asynchronous and synchronous bit bang interface modes are available. USB to serial designs using the FT232R have been further simplified by fully integrating the external EEPROM, clock circuit and USB resistors onto the device.

Link to comment
Share on other sites

Guest poli_danny

Da stiu de FT232.. faza naspa e ca asta presupune proiectul: folosirea circuitului FT245. Dar am rezolvat problema.. inclin sa cred Solutie: am mutat pe alt port. Initial scriam datele pe portul ADC-urilor care din moment ce nu le-am pornit inseamna ca portul trebuia sa se comporte ca un port normal.. dar se pare ca ceva e ciudat.Multumesc de sfat oricum.Cheers

Link to comment
Share on other sites

  • 2 weeks later...
Guest poli_danny

Problema acuma e cu transmisia catre calculator. Am facut o aplicatie C# care imi deschide si citeste portul virtual COM3 dar eu de la uC ma intereseaza sa transmit ori o variabila float[valoarea temperaturii ex: 32.12] ori un sir de 1 sau 2 octeti[variaza in fctie de precizia masuratorii pt temperatura] care sa ii prelucreze aplicatia C si sa ii transforme in float. Am vazut pe net la cineva care pur si simplu a declarat o variabila float care apoi o trimitea pe portul de 8 biti ai FT245 si facea handshake-ul cu WR si TXe si cica ii ajungeau datele la calc.. mie imi receptioneaza doar codul ascii al (floor)variabila. What to do? thanks

Link to comment
Share on other sites

de ce nu faci un itoa si transmiti vectorul de caractere? sau in 2 octeti diferiti sa transmiti int-ul pentru partea intreaga (int)floor(val) si partea fractionara (int)(val%1)pentru a doua varianta cum n-ai valori mai mari de 127 (nu vad de ce ai avea) poti folosi MSB-ul pentru a marca care e partea intreaga si care e cea fractionala.

Link to comment
Share on other sites

sau varianta a 2 e sa transformi toata variabila float in caractere ascii "ftoa" si transmiti toate cifrele ca si caractere. Insa cum zicea srdjan e ceea mai economica varianta si folosesti doar 2 octeti daca ai val intre 0-127, si e si destul de usor de implementat, daca folosesti comunicatie paralela.

Link to comment
Share on other sites

Guest poli_danny

chiar acuma ma pregateam sa va scriu.. am rezolvat cu ftoa .. trasmit caracterele one by on din array.. multzam mult... faza e ca puteam sa le transmit la comp dar aplicatia C# mi le vedea in ASCII ,, trimiteam 48 de la ft245 si imi citea "0"multzam mult.. era pt proiectu de licenta .. m-ati scos din rahat :d

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines