Good Evening to all of you!
I am seeking for your advice and help for the following issue I encounter:
I am trying to modify the usb_dev_bulk example code and use it in a proof-of-concept application. It is the very first time that I develop uC code for USB.
In that application, data from SSI3 (configured as Freescale SPI Mode 0) are written to an array and that array's contents are sent over USB to the host PC at regular time intervals.
As a "heartbeat", I use Timer4 configured to overflow 10 times per second; this gives the desired sampling rate for the SPI device that is attached to the uC.
(I followed advice about alternatives to SysTick given to me in this thread; the aim is to push that up to 1000 or even 10000 times per second.)
Moreover, I am running a USB monitoring software tool to monitor raw data traffic on the USB lines.
What I have noticed so far is the following:
When running the usb_dev_bulk example code along with the Win32 application on my PC, I can monitor the TX and RX data successfully, exactly as they appear in the Win32 application. As you may recall, that application gets ASCII data from the PC and toggles the case of alphabetic characters, while leaving everything else intact.
My altered code includes a modified version of the EchoNewDataToHost() function that does not read anything from the host PC but just sends data to the host PC upon request in the Timer4 ISR. That function requires a pointer to the USB bulk structure g_sBulkDevice that is defined in usb_bulk_structs.c file.
// Global pointer to the USB device
tUSBDBulkDevice* pvDevice;
...
In function main() :
pvDevice = USBDBulkInit(0, &g_sBulkDevice);
When running my altered version, although I pass that pointer when calling function SendDataToHost(), I found out while stepping through the code that this pointer does not have the correct value for reasons that I really do not understand. Data are not present on the TX channel of the USB:
SendDataToHost(pvDevice, g_RX_buffer, NO_OF_BUF_SAMPLES*(NO_OF_SPI_BYTES-1)); // pvDevice does not point where it should be (&g_sBulkDevice)
Please find attached all the project files and I will thank you to advise me.