Forum: FPGA, VHDL & Co. Eval AD7760/62EDZ an FX2


von Patrick V. (Firma: home) (ich27)


Angehängte Dateien:

Lesenswert?

Hallo zusammen...

mein erster Beitrag und dann gleich so eine Frage:

also ich habe hier 2 Eval-Boards:
ein Cypress FX2 Development Board CY3681 PDC-9018 REV C 
(http://www.cypress.com/?rID=14319)
und ein Analog Devices EVAL-AD7760/62EDZ 
(http://www.analog.com/en/analog-to-digital-converters/ad-converters/ad7760/products/product.html)

Ich habe mir das FX2 GPIF Tool Utility-Beispiel von Cypress genommen (zu 
finden in: C:\Cypress\USB\Application Reference Materials\Support 
Information\High Speed Devices\CY7C68013 FX2\Examples) und es ein wenig 
abgewandelt:

in gfpitool.c
1
void TD_Init( void )
2
{ // Called once at startup
3
...
4
  // 16-bit bus (WORDWIDE=1)...
5
  SYNCDELAY;                    // 
6
  EP2FIFOCFG = 0x01;
7
  SYNCDELAY;                    // 
8
  EP6FIFOCFG = 0x05;
9
...
10
}
11
12
...
13
14
void TD_Poll( void )
15
{ // Called repeatedly while the device is idle
16
  BYTE dummy = 0;
17
  
18
  // Handle OUT data...
19
  
20
  // is the host sending data...
21
  if( !( EP2468STAT & 0x01 ) )
22
  { 
23
    // EP2EF=0, when endp buffer "not" empty
24
    
25
    // ...at this point the pkt. switched from the usb domain to the cpu domain
26
    
27
    // if the host sent a pkt... then a buffer was available
28
    // AUTOOUT=0, so pass pkt. to peripheral domain - (GPIF)
29
    SYNCDELAY;          // 
30
    EP2BCL = 0x00;            // w/skip=0
31
32
  }
33
  else
34
  { 
35
    // host is "not" sending data...
36
  }    
37
  
38
  if ( write_mode == TRUE ) 
39
  {
40
  // is the peripheral interface idle...
41
  if( GPIFTRIG & 0x80 )
42
  { 
43
    // DONE=1, when GPIF is "idle"
44
  
45
    // check if there's a pkt in the peripheral domain...
46
    if( EP24FIFOFLGS & 0x02 )
47
    { 
48
      // ...EF=1 when buffer "empty", no more data to xfr.
49
    }    
50
    else
51
    { 
52
      // EF=0, when slave fifo is "not empty"
53
      // ...the cpu passed the pkt. to the peripheral domain
54
    
55
      // check if peripheral "not full"...
56
//      if( GPIFREADYSTAT & 0x02 )
57
      { 
58
        // RDY1=1, when peripheral is "not" FULL (tied to peripheral "full" flag)
59
    
60
//        xFIFOTC_OUT = ( ( EP2FIFOBCH << 8 ) + EP2FIFOBCL );
61
62
        // setup GPIF transaction count
63
        SYNCDELAY;            // 
64
        EP2GPIFTCH = EP2FIFOBCH;
65
        SYNCDELAY;
66
        EP2GPIFTCL = EP2FIFOBCL;  
67
68
        // trigger FIFO write transaction(s), using SFR
69
        // R/W=0, EP[1:0]=00 for EP2 write(s)
70
        SYNCDELAY;
71
        GPIFTRIG = GPIFTRIGWR | GPIF_EP2;  
72
      
73
        // NOTE: 512 bytes transfers in ~75usec on 8-bit async bus 
74
        // ...once master (GPIF) drains OUT pkt, it (re)arms to usb domain
75
/*        
76
        if( xFIFOTC_OUT < enum_pkt_size )
77
        { 
78
          // handle short pkt. to peripheral
79
80
          // wait for the transaction to terminate naturally...
81
          while( !( GPIFTRIG & 0x80 ) )
82
          { 
83
              // should take <75usec @ 8-bit async.
84
            ; // poll GPIFTRIG.7, DONE bit...
85
          }
86
          
87
          // signal "shortpkt" to peripheral peripheral here...
88
        }
89
        else
90
        { 
91
          // was max. pkt. size...
92
          // ...let transaction terminate naturally...
93
        }
94
*/
95
      }
96
//      else
97
      { 
98
        // RDY1=0, when peripheral is FULL
99
      }
100
    }
101
  }  
102
  else
103
  { 
104
    // DONE=0 when GPIF is "not" IDLE...
105
  }
106
  } else {
107
108
if ( EP68FIFOFLGS & 0x01 )
109
{
110
  dummy = LED2_ON;
111
} else {
112
  dummy = LED2_OFF;
113
}
114
if (( GPIFREADYSTAT & 0x01 ))
115
{
116
  dummy = LED0_ON;
117
} else {
118
  dummy = LED0_OFF;
119
}
120
if (!( GPIFREADYSTAT & 0x01 ))
121
{
122
  if ( !( GPIFTRIG & 0x80 ) )
123
  {
124
    dummy = LED1_ON;
125
  }
126
} else {
127
  dummy = LED1_OFF;
128
}
129
130
// Handle IN data...
131
  
132
  
133
  // is the peripheral interface idle...
134
  if( GPIFTRIG & 0x80 )
135
  { 
136
    // check if peripheral "not empty"...
137
    if ( !( GPIFREADYSTAT & 0x01 ) )
138
    { 
139
      // RDY0=1, when peripheral "not" empty...
140
141
      if( EP68FIFOFLGS & 0x01 )
142
      { 
143
        // EP6FF=1, when fifo "full"
144
      }
145
      else
146
      { 
147
        // EP6FF=0, when fifo "not full", buffer available...
148
149
        // setup GPIF transaction count
150
        SYNCDELAY;          // 
151
        EP6GPIFTCH = 0x00;    
152
        SYNCDELAY;
153
        EP6GPIFTCL = 0x04;    
154
          
155
        // trigger FIFO read transaction(s), using SFR
156
        // R/W=1, EP[1:0]=FIFO_EpNum for EPx read(s)
157
        SYNCDELAY;
158
        GPIFTRIG = GPIFTRIGRD | GPIF_EP6; 
159
        
160
        // NOTE: 512 bytes transfers in ~75usec on 8-bit async bus 
161
        // NOTE: 64 bytes transfers in ~10usec on 8-bit async bus 
162
        
163
        // wait for the transaction to terminate naturally...
164
        SYNCDELAY;                // 
165
        while( !( GPIFTRIG & 0x80 ) )
166
        { 
167
            // should take <75usec @ 8-bit async.
168
          ; // poll GPIFTRIG.7, DONE bit...
169
        }
170
171
        
172
       // AUTOIN=0, so 8051 pass pkt. to host...
173
        SYNCDELAY;              // 
174
        INPKTEND = 0x06;        // ...commit however many bytes in pkt.
175
                                // ...NOTE: this also handles "shortpkt"
176
        
177
/*    count++;
178
      XGPIFSGLDATLX = count;
179
    count++;
180
    XGPIFSGLDATH = count;
181
*/
182
      }
183
    }
184
    else
185
    { 
186
      // master has all the data the peripheral sent...
187
    }
188
  }
189
  else
190
  { 
191
    // peripheral interface busy...
192
  }
193
  }
194
195
}

dazu noch ein paar Kleinigkeiten mit den LED's zur Kontrolle von einigen 
Sachen.
Außerdem lasse ich den FX2 vom ADC mit 40MHz synchronisieren (das Zeug 
steht ja dann alles in der gpif.c)

Die Pinbelegung:  ADC -> FX2
MCLK_CED   - IFCLK
DATA[15:0] - FD[15:0]
CS         - CTL1
RD/WR      - CTL2
DRDY       - RDY0

soweit so gut.

Nun die Frage: ich habe also die Waveforms mit dem GPIF-Designer 
geändert und bekomme es einfach nicht gebacken die Daten richtig vom ADC 
aus zulesen. Es ist doch so, dass die FIFORd-Waveform so oft aufgerufen 
wird, wie groß der gewählte FIFO-Puffer gewählt ist, also hier:
1
        // setup GPIF transaction count
2
        SYNCDELAY;          // 
3
        EP6GPIFTCH = 0x00;    
4
        SYNCDELAY;
5
        EP6GPIFTCL = 0x04;
4 x 2 Byte = 8 Byte (wegen WIDEWORD)?

Ich habe aber nun das Problem, dass ich zwar Daten (etwas davon) 
bekomme, aber eigentlich möchte ich nur 4 Byte (2 WIDEWORD's) auslesen, 
lese aber mittlerweile 8 aus, weil schon die ersten 2 Bytes, die ich 
bekomme immer(!) auf FF stehen (?). Dann bekomme ich irgendein Byte, 
dann wieder FF, wieder ein Byte, dann wieder FF...
Ich habe einfach das Gefühl, dass die zweiten 8 Bit nicht auslesen kann?
Habe mir das TRM und die AD-Unterlagen schon zu Gemüte geführt (würg), 
weiß jetzt aber nicht weiter?!

Jetzt hoffe ich dass man mit dem Ganzen hier ein wenig was anfangen 
kann?

Danke schonmal

mfg

von ohne ahnung (Gast)


Lesenswert?

und dazu noch in nem falschen forum. -> bitte verschieben.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.