alvin.ma
Joined: 04 Sep 2009 Posts: 10
|
USB CDC communication problem between PIC18F4550 and PC |
Posted: Mon May 10, 2010 7:29 pm |
|
|
Hi all,
I found that there is a missing byte found when receiving data from PIC18F4550 (in USB CDC).
Problem description:
When C# program is receiving data from 18F4550 in which firmware is written by CCS USB CDC function, there is missing byte found in the received string (around 1 byte lost out of 1 thousand bytes received). It is very strange that missing byte always happened when the data is sent out periodically but not in a burst (see the two C# transmission method in below).
To check whether it is hardware or software problem, same C# program and MCU hardware is used but the MCU firmware is replaced by C18 (modified from CDC -Basic Demo in Microchip's MCHPFSUSB framework). This time no missing byte is found. It is likely the problem come from CCS complier in handling heavy USB IN and OUT tranmission. Is that right? Any suggestion to solve this problem?
Transmission method
PC side (Simple serial port program written in C#):
1. send out 7byte data (e.g. "012345D") in every millisecond and display what is received in the text box. Missing byte found in the received string for CCS USB CDC function.
2. send out a burst of data 7byte x 1000 (e.g. "012345D012345D01245D........") in every second and display what is received in text box. No missing byte found in the received string for CCS USB CDC function.
MCU program (complied by PIC C complier V4.093):
Code: |
void main()
{
.....
.....
.....
while(TRUE)
{
if (usb_cdc_khbit())
{
//send out "012345K" when receiving "D".
while(usb_cdc_getc()!='D') {}
printf(usb_cdc_putc, "012345K");
}
}
}
|
Could anyone help me please?
Thank you! |
|