|
|
View previous topic :: View next topic |
Author |
Message |
MariaDiaz
Joined: 02 Aug 2007 Posts: 2
|
Problems reading from SPP |
Posted: Thu Aug 02, 2007 4:30 am |
|
|
Hello!
I am trying to transfer data between a PC and a FPGA, for this I use a PIC18F4550, because it has SPP (Streaming Parallel Port). I can use normal ports to read and write to the FPGA without problems, but when I use the SPP peripheral I can only write. When from the PC I write data to the OUT endpoint configured for SPP the PIC outputs the correct data, but when I try to read from the IN endpoint the PIC doesn't read anything (I have checked the pins with an oscilloscope).
In order to use SPP I had to modify the CCS firmware so that the endpoint buffers are configurate as specify in the DataSheet. I did this for both endpoints and I have check it for several times, but it doesn't work. Since the USB SIE controls the SPP, it must be either a configuration error or an error in the way the USB firmware controls the endpoint.
This is an example of what I had modified:
Code: |
#ifdef SPP_CUSTOM
if (en==SPP_ENDPOINT) EP_BDxADR_O(en)=0xFFFF;
else
#endif
EP_BDxADR_O(en)=addy;
|
instead of Code: | EP_BDxADR_O(en)=addy; | (if we are using my custom SPP code, the endpoint with the SPP_ENDPOINT number will be configured with the FFFF address, like Microchip says).
Code: |
#ifdef SPP_CUSTOM
if(en==SPP_ENDPOINT) i|=0x30;
#endif
EP_BDxST_O(en)=i;
|
instead of (set the KEN and INCDIS bits).
And similar changes whenever the endpoint registers are written, to insure the SPP endpoint is always configured for SPP usage.
My code, basically does this:
Code: |
int *sppcon=0xF65;
int *sppcfg=0xF63;
*sppcfg=0x32;
// *sppcfg=0x50; //I want to use this, but changed to 0x32 to be like Microchip's example.
*sppcon=0x02;
setup_adc_ports (NO_ANALOGS);
//setup_timer_0 (RTCC_DIV_256|RTCC_INTERNAL);
set_tris_d(0xff);
set_tris_e(0);
set_tris_a(0);
set_tris_b(0);
usb_init(); //initialitze USB
usb_task();
usb_wait_for_enumeration();
*sppcon=0x03; //Activate SPP
while (TRUE)
{
//do other stuff.
}
|
Has anybody had any success in modifying the CCS-supplied firmware for SPP use? Any clue as to what I am doing wrong? |
|
|
Spider-Yam
Joined: 26 Aug 2007 Posts: 1
|
Possible solution |
Posted: Sun Aug 26, 2007 11:21 am |
|
|
Have you made sure that when you set the KEN and INCDIS the UOWN bit is also set for the buffer descriptor of the IN endpoint? The CCS code does not set it for IN endpoints, only for OUT endpoints, since setting it means you are ready for transfer (an OUT endpoint is ready to receive, an IN endpoint has data and is ready to send it) and OUT endpoints are ready for transfers immediately, but IN endpoints aren't until you put a packet (unless you use the SPP, which is always ready).
Like so:
Code: |
#ifdef SPP_CUSTOM
if(en==SPP_ENDPOINT) EP_BDxST_I(en)=0xF0;
else
#endif
EP_BDxST_I(en)=0x40;
|
You probably only bothered to set KEN and INCDIS and had Code: | EP_BDxST_I(en)=0x70; | for the SPP endpoint. |
|
|
MariaDiaz
Joined: 02 Aug 2007 Posts: 2
|
Thanks! |
Posted: Mon Aug 27, 2007 2:37 pm |
|
|
Thank you so much for such useful information. It works!!! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|