Electronic – Using Microchip’s dsPIC33E USB Starter Kit

microchippicusb

I'm a student and I'm starting a project in which I'm working with the Microchip's dsPIC33E USB Starter Kit.
I used some samples taken from this site
for initiating, sending and receiving packets. There is no screen in this board, so I'm printing what I need on the computer screen with a terminal software IVT VT220.

My first problem is printing more then one line to the screen – if having 2 print commands in the same code, it'll print only the first, then will do the rest of the code, just without the second printing command.
For example this code:

// some code
putrsUSBUSART("first print");
putrsUSBUSART("second print");
//the rest of the code

will print "first print", and then will do the rest of the code.

The second problem I have is sending and receiving messages in different modes. When I'm using loopback mode, I'm able to transmit a message and then receive it. By checking the rx register it looks like the message has been transferred correctly. However, when changing the mode to normal mode and doing exactly the same process, it still looks like the message I've received is valid (although working with one device only! So it suppose to work fine only in loopback, not in normal mode. or maybe it doesn't work at all in both modes?).

Any suggestions why this things happen???

Best Answer

I think the putrsUSBUSART(); function is probably non-blocking and has a check for the peripheral being busy. When you try to send the second string it checks and finds the peripheral is busy so simply skips.
I recall another "sendUSB" type function working in this way in the USB libraries.

For a quick test of the above, try adding a delay between the two function calls to see if it solves the issue (this is not a permanent solution - there is probably a function to check for this but this should do just to check)

From what I can see, the dsPIC33F starter kit relies on another PIC with a USB peripheral to do the USB comms (AFAIK none of the dsPICs have a USB peripheral)
It also looks like the demo firmware is set up to emulate a COM port for serial comms. I couldn't find any documentation for the code, but I did find this:

The instructions for this demo can be found at C:\dsPIC33E PIC24E USB Starter Kit Demo\Documentation\Getting Started\Getting Started - Running the Device - CDC - Basic Demo. See the Running the Demo section.

I'm assuming all the necessary documentation is going to be in the "Documentation" folder. It should have details of the functions used in the demo application, so you can check how they work. You could also just check the function code itself.