|
Hi again,
I think I posted on the wrong place of the forum. If yes, please move it to the correct place.
Now my changed code parts:
void TD_Init(void) // Called once at startup
{
// set the CPU clock to 48MHz
//CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
CPUCS = 0x12;
// set the slave FIFO interface to 48MHz
//IFCONFIG |= 0x40;
//IFCONFIG |= 0xE3; // Interface set to 48 MHz and IFCLK output is driven (IFCLKSRC=1,3048MHZ=1,IFCLKOE=1,IFCLKPOL=0)
IFCONFIG |= 0xF3; // Interface set to 48 MHz and IFCLK output is driven (IFCLKSRC=1,3048MHZ=1,IFCLKOE=1,IFCLKPOL=1)
//IFCONFIG |= 0xB3; // Interface set to 30 MHz and IFCLK output is driven (IFCLKSRC=1,3048MHZ=0,IFCLKOE=1,IFCLKPOL=1)
SYNCDELAY;
REVCTL = 0x03; // Disabled Autoarming & Enabled Enhanced Packet Handling
SYNCDELAY;
PINFLAGSAB = 0x0B; // FLAGA - EP8 Empty Flag
SYNCDELAY;
PINFLAGSCD = 0x0F; // FLAGC - EP8 Full Flag
SYNCDELAY;
PORTACFG |= 0x00;
EP1OUTCFG = 0xA0; // Configure EP1OUT as BULK EP (VALID=1,TYPE1=1)
SYNCDELAY;
EP1INCFG = 0xB0; // Configure EP1IN as BULK IN EP (VALID=1,TYPE1=1,TYPE0=1) means Interrupt-EP according to TRM
SYNCDELAY; // see TRM section 15.14
EP2CFG = 0x7F; // Invalid EP
SYNCDELAY;
EP4CFG = 0x7F; // Invalid EP
SYNCDELAY;
EP6CFG = 0x7F; // Invalid EP
SYNCDELAY;
EP8CFG = 0xE0; // Configure EP8 as BULK IN EP with 512bytes size and Quad-Buffering
SYNCDELAY;
FIFORESET = 0x80; // activate NAK-ALL to avoid race conditions
SYNCDELAY; // see TRM section 15.14
FIFORESET = 0x08; // reset, FIFO 8
SYNCDELAY; //
FIFORESET = 0x00; // deactivate NAK-ALL
SYNCDELAY;
// Configure all Fifos with (wordwide=0) to be able to use the FD[8:15] as PortD for debuggin purposes
EP2FIFOCFG = 0x00; // Configure EP2 FIFO in 8-bit mode
SYNCDELAY;
EP4FIFOCFG = 0x00; // Configure EP4 FIFO in 8-bit mode
SYNCDELAY;
EP6FIFOCFG = 0x00; // Configure EP6 FIFO in 8-bit mode
SYNCDELAY;
// Configure EP8
//EP8FIFOCFG = 0x4C; // Configure EP8 FIFO in 8-bit Auto Commit mode (ZEROLENIN=1)
EP8FIFOCFG = 0x48; // Configure EP8 FIFO in 8-bit Auto Commit mode (ZEROLENIN=0)
SYNCDELAY;
// Set Auto-Commit length to 1 byte
EP8AUTOINLENH = 0x00;
SYNCDELAY;
EP8AUTOINLENL = 0x01;
SYNCDELAY;
//Serial0Init(); // Initialize the Serial Port 0 for the Communication
IOInit();
}
void TD_Poll(void) // Called repeatedly while the device is idle
{
// Serial State Notification that has to be sent periodically to the host
if (!(EP1INCS & 0x02)) // check if EP1IN is available
{
EP1INBUF[0] = 0x0A; // if it is available, then fill the first 10 bytes of the buffer with
EP1INBUF[1] = 0x20; // appropriate data.
EP1INBUF[2] = 0x00;
EP1INBUF[3] = 0x00;
EP1INBUF[4] = 0x00;
EP1INBUF[5] = 0x00;
EP1INBUF[6] = 0x00;
EP1INBUF[7] = 0x02;
EP1INBUF[8] = 0x00;
EP1INBUF[9] = 0x00;
EP1INBC = 10; // manually commit once the buffer is filled
}
// recieving the data from the USB Host and send it out
if (!(EP1OUTCS & 0x02)) // Check if EP1OUT is available
{
WriteByteS0(EP1OUTBUF[0]);
EP1OUTBC = 0x04;
}
}
This is all I have changed from the original code. Except the WriteByteS0 function which now outputs to the digital IO Pins of Port D. In the original example EP8 was used to transfer data to the host, which I am trying to use for Slave Fifo IN to get my data from the FPGA to the Host.
I tried different input bytes, but the pattern transmitted does not change. So I wondered, whether I need the SLCS# signal to activate the FD00-7 Pins. Normally the Pin PA.7 is usable as digital IO, FlagD or SLCS#. At the moment the PORTACFG is configured that PA.7 is used as digital IO. What is the state of the SLCS# internally, if the signal is not routed outside? I did not find any information about that in TRM and in datasheet either.
I appreciate help of any kind and will put the timing recorded by oscilloscope online tomorrow.
Best regards
|