libftdi Archives
|
From: | Rodrigo Rosa <rodrigorosa.lg@xxxxxxxxx> |
---|---|
To: | libftdi@xxxxxxxxxxxxxxxxxxxxxxx |
Date: | Tue, 8 Feb 2011 13:25:10 -0800 |
On Tue, Feb 8, 2011 at 4:35 AM, Michael Plante <michael.plante@xxxxxxxxx> wrote:
i enabled loopback (tied TDI to TDO) i tried debugging this code: sync_mpsse(&ftdic); while(ftdi_read_data(&ftdic, input_buff, 100) != 0 );
unsigned int aux = 0; int counter = 0; numBytesRead = 0; // ----------------------------------------------------------------------------------------- // �Simple example
// ----------------------------------------------------------------------------------------- �� �while(1) �� �{ �� � � �// write �� � � �numBytesToSend = 0; �� � � �output_buff[numBytesToSend++]=0x6E;
�� � � �output_buff[numBytesToSend++]=0x02; �� � � �output_buff[numBytesToSend++]=0x80; �� � � �output_buff[numBytesToSend++]=0x6E; �� � � �output_buff[numBytesToSend++]=0x00;
�� � � �output_buff[numBytesToSend++]=0x00; �� � � �numBytesSent = ftdi_write_data(&ftdic, output_buff, numBytesToSend); �� � � �if(counter++ == 10) �� � � �{ �� � � � � �sync_mpsse(&ftdic);
�� � � � � �while(ftdi_read_data(&ftdic, input_buff, 100) != 0 ); �� � � � � �counter = 0; �� � � �} �� � � �sleep(3); �� � � �//read �� � � �numBytesToRead = 5;
�� � � �int i; �� � � �for(i=0;i<numBytesRead;i++) �� � � �{ �� � � � � �input_buff[i]=0x00; �� � � �} �� � � �aux = ftdic.readbuffer_remaining; �� � � �numBytesRead = 0;
�� � � �numBytesRead = ftdi_read_data(&ftdic, input_buff, numBytesToRead); �� �} changing the values of line1,�line2,�line3,�line4. the first reading get 2 bytes of ones, and after the third loop I still get 2 bytes, but they seem to look like what i expected. For the example code pasted above, I expected 3 ones followed by a zero.
the first read gives me�input_buff[0]==11111111 and input_buff[1]==1111111 the second read gives�input_buff[0]==11101111 and input_buff[1]==1110111
the third and any following loops get input_buff[0]==11101110 and input_buff[1]==1110111. I see the sequence i expected, and if i modify the code i can generate other sequences which are coherent with the code.
i think it makes sense to me getting two bytes of data, one for each time i run the command 0x6E. what i don't understand yet is the content of the returned value... �
with the test loop i made i get as many bytes as i expect, but the content of the bytes... do you know of any other doc besides AN108? � Note that bad commands can't be interpreted until the previous one finishes, i didn't get that anymore, i'm trying to reproduce it, but i haven't been successful yet. �
how often would you recommend syncing? after a given number of ftdi_write_data commands? �
the hardware connections are ok. i assumed TDI/DO�refers�to TDI, i connected the ft2232 TDI pin to the TDI pin of my device. when i was checking this i realized that i haven't been able to get the scope to read anything on TDO. still trying to figure that out.
�
i set�uint clockDivisor = 0x05DB;//Frequency = 60/((1+0x05DB)*2) (MHz) = 20khz with �0x6E and clocks to zero (one clock) i measured a 50 mu sec pulse. assuming that one pulse corresponds to one clock cycle, that's a 20kHz clock.
is that a little better? ��
isn't this suppose to give me useful info:��ftdi_context::readbuffer_remaining�? i get zero all the time. is it just a slot to use to save info? thanks again!! :) -- Rodrigo. libftdi - see http://www.intra2net.com/en/developer/libftdi for details. |
Current Thread |
---|
|